How to factor$ x^2+2xy+y^2 $ I know the formula $x^2 + 2xy + y^2 = (x + y)^2$ by heart and in order to understand it better I am trying to solve the formula myself; however, I don't understand how step 4 is derived from step 3.
$$x^2+2xy+y^2\qquad1$$
$$x^2+xy+xy+y^2\qquad2$$
$$x(x+y) + y(x+y) \qquad3$$
$$(x+y)(x+y) \qquad 4$$
How does one get from step 3 to step 4? I don't know how to do that process.
 A: First consider this:
$3$ apples and $4$ apples make $7$ apples.
You may represent this as: 
$3A+4A=7A$
But let's let  $A=x+y$
$3(x+y)+4(x+y)=7(x+y)$
Or equivalently:
$(3+4)(x+y)$
Now consider:
$x(x+y)+y(x+y)$
Let's let $A=x+y$ like we did in the above.
Now we have:
$xA+yA$
Factor the $A$ out
$=A(x+y)$
plug $A$ back in
$=(x+y)(x+y)$
A: Hopefully some colouring will make things easier to grasp:
$$\color{red}{x}(x+y)+\color{blue}{y}(x+y)=(\color{red}{x}+\color{blue}{y})(x+y)=(x+y)^2.$$
A: Simply, Step 4 is known as factoring by grouping. It is essentially an inverse of distribution, and can be proven by distributing $(a+b)(a+b)$ to get $a(a+b) + b(a+b)$.
(Note: a more complete solution can be found at the following link:
http://www.onemathematicalcat.org/algebra_book/online_problems/facByGrpPf.htm
However, this solution is very complicated and I could barely follow it without paying deep attention. This is the only way I know of to prove factoring by grouping without just distributing.)
A: $$x\color{blue}{(x+y)} + y \color{blue}{(x+y)} \qquad3$$
Let $\color{blue}{b=(x+y)}$
So, now you have. 
$$x\color{blue}{(b)} + y\color{blue}{(b)}  = x\color{blue}{b} +y\color{blue}{b} =\color{blue}{b}x+\color{blue}{b}y $$
Now factor out the $\color{blue}{b}# :
$$\color{blue}{b} (x+y)$$  
Remember, $\color{blue}{b=x+y}$, so substitute:
$$\color{blue}{(x+y)}(x +y)=(x+y)^2$$
A: Hint: go the other way! start with $(x + y)^2$, multiply out to get $x^2 + y^2 + xy + yx$ and then collect like terms to get the normal form $x^2 + 2xy + y^2$. "Multiplying out and collecting like terms" is a decision procedure for this kind of problem.
A: It's simply a common binomial factor. Common factors don't have to be just a variable or a number; they can be any written expression. Suggest that you find a section in a textbook labelled "factor by grouping" and practice several problems there.
Obviously $xb + yb = b(x + y)$. If you see that, your problem is identical with the replacement $b = (x + y)$. 
As a side issue, derivations like this are generally easier to accomplish going from complicated-to-simplified form. Start with $(x + y)^2$ and simplify it; you'll probably find it more straightforward (just expand and FOIL).
