Although this (and similar pages) may appear to be a WalledGarden, this exact page is useful because it helps show the etymology of the term "ReFactor". ---- You can use the distributive law to see that 3(4n + 5) = 12n + 15, and you can use FOIL to see that (n - 3)(n - 5) = n^2 - 8n + 15. But how can you start with the answer and find the factors? It's like Jeopardy: I say, "n^2 - 8n + 15," and you respond (in the form of a question), "What is (n - 3)(n - 5), Alex, uh, I mean Dan?. Here's a way to look at the first problem: 12n + 15 = 3(4n)+ 3(5) = 3(4n + 5) This is called "factoring out a common factor." Note: FOIL is derived from the initials of "First, Outer, Inner, Last", and is a handy acronym which helps a surgeon do things in the right order when performing a Caesarean Section. In mathematics, it seems to be limited to assisting with multiplying two factors which each contain two terms. See also: MatrixAnalysis, CategoryMath The programming concept of ReFactoring is analogous to FactoringPolynomials. You start with an initial mash of information that is difficult to deal with. (Go ahead, look at a non-trivial fifth-degree polynomial and give me the zeros immediately.) You transform the original expression, maintaining mathematical equivalence the whole time, and when you are done factoring, you have a much more tractable representation. (You can just look at a fifth-degree ''factored'' polynomial and immediately read off the zeros.) From there, assuming this equation has some sort of meaning in the real world, you can apply this knowledge to other circumstances or perhaps mix it with other information more easily then if you were trying to use the original mashed-up information. It's a very similar operation, though since programs are typically much larger then a handful of equations, the programming version has significant practical differences. Still, an awful lot of math can be described as a conceptual refactoring of some older topic; arithmetic -> algebra -> calculus, arithmetic -> number theory -> group theory -> category theory (may be wrong on that last one and may not be literal supersets), etc. ---- Factoring a quadratic can be done by inspection in easy cases, but in harder cases you need a method. Finding a value of '''x''' that makes your equation come out to zero is a good way of finding a factor if you use a computer to search for the value. Example: y = x^2 - 8x + 15. Try x=0 -> y = 15 Try x=8 -> y = 15 Try x=4 -> y = -1 (now we have both positive and negative values so there must be a solution) Try x=2 -> y = 3 Try x=3 -> y = 0 We now know that '''(x-3)''' is a factor of '''x^2 - 8x + 15'''. ''If you are going to use approximation methods to find roots to polynomials; a more systematic approach is probably better than guessing.'' The easy way of finding a solution, though, is to use the QuadraticFormula. This lets you find a value '''v''' for '''x''' that makes the quadratic evaluate to zero, and so '''(x-v)''' is a factor. ''What about equations like'' '''x^2 + 4''' ''with two complex solutions?'' The quadratic formula works fine for those. Similar solutions exist for degree-3 and degree-4 polynomials; though the latter two are '''much''' longer equations. For degree-5 and above, no closed-form solutions exist (except in special cases) that only employ addition, subtraction, multiplication, division, and root extraction; additional mathematics must be brought to bear. The book ''Abel's Proof: An Essay on the Sources and Meaning of Mathematical Unsolvability'' (ISBN: 0262661829) treats of this. ---- CategoryMath