Why does $(a+b)^2= a^2+b^2 + 2ab$? Why is the $2ab$ there? When I was doing research on finding the derivative I came across something strange.
If $f(x) = x^2$ you find the derivative by going 
$$\frac{f(x+h)^2-f(x)^2}{h}
=\frac{x^2+2xh+h^2-x^2}{h}.$$
Why is there the $2xh$? Can someone explain the logic behind this? I'm assuming you plus $x$ and $h$ together then square it but why?

The reason is that $(a+b)^2$ is nothing more than shorthand notation for $(a+b)(a+b)$. FOILing this expression gives
$$(a+b)^2 = (a+b)(a+b) = \overbrace{a\cdot a}^{\text{FIRST}} + \overbrace{a\cdot b}^{\text{OUTER}} + \overbrace{b\cdot a}^{\text{INNER}} + \overbrace{b\cdot b}^{\text{LAST}} = a^2 + ab + ba + b^2.$$
$ab=ba$ since order of multiplication doesn't matter for real numbers, so we see that
$$(a+b)^2 = a^2 + ab + ab + b^2 = a^2 + 2ab + b^2.$$
