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?
 A: $(a+b)^2=(a+b)(a+b)=a^2+ab+ba+b^2=a^2+2ab+b^2$
A: 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.$$
A: Graphical interpretation
The image shows the area of a square with side length of a+b. Here you can see, how the small 4 areas become the square.

A: Here's how the $2xh$ term appears
$$
(x+h)^{2}=(x+h)(x+h)
$$
$$
=x(x+h)+h(x+h)
$$
$$
=x^{2}+xh +xh +h^{2}
$$
$$
=x^{2}+2xh+h^{2}
$$
Here are the steps for finding the derivative of $f(x)=x^{2}$
\[
\lim_{h\to 0} \frac{f(x+h)-f(x)}{h}=\lim_{h\to 0} \frac{(x+h)^{2}-x^{2}}{h}
\]
\[
=\lim_{h\to 0} \frac{x^{2}+2xh+h^{2}-x^{2}}{h}=\lim_{h\to 0} \frac{2xh+h^{2}}{h}
\]
\[
=\lim_{h\to 0} [2x+h]=2x+0=2x
\]
A: The above answers are correct but if I understood you correctly, I think you may be confused about what the function is expecting.  We know $$f(x) = x^2$$ meaning whatever input I give you, I want you to square it. So $f(x + h)$  means the "input" is $x + h$ and we want to square this and so we have 
$$(x + h)^2 = x^2 + 2xh + h^2$$
Again, this is simple stuff you probably already know but the way I read your question, I thought it was this part that you needed clarification with.
A: The logic behind derivative is tangent line. To draw that line you need two points on the graph. As that two points get closer together, your line became the tangent line.
So to answer your question,
    $$
f(x+h)=(x+h)^2=x^2+2xh+h^2
$$
is just the second point on your graph.
A: \begin{align*}
(a+b)(a + b) &= a(a + b) + b(a + b)\quad &(\text{addition distributes over multiplication})\\
&= aa + ab + ba + bb\quad &(\text{multiplication distributes over addition})\\
&= a^2 + ab + ba + b^2\quad &(xx = x^2)\\
&= a^2 + ab + ab + b^2\quad &(\text{multiplication is commutative})\\
&= a^2 + 2ab + b^2
\end{align*}
A: The reason why you're having problems is because you wrote the problem wrong.
The derivative is not
$$\lim_{h \to 0} \frac{f(x+h)^2-f(x)^2}{h}$$
but actually
$$\lim_{h \to 0} \frac{f(x+h)-f(x)}{h}$$
You're confusing $f(x) = x^2$ with $f(x)^2$. These are not the same thing.
$f(x) = x^2$ means that for any argument $x$ you put in the function, you square that input. $f(x)^2$ means you're squaring the result after you plug in $x$ into the function, or the output.
That's why $f(x+h) = (x+h)^2 = x^2 + 2xh + h^2$.
A: Here is the underlying geometric intuition:
Let $a, b > 0$ be real numbers.
Let there be given a square $S$ with side length $a+b$ so that the area of
$S$ equals $(a+b)^{2}$. Then within $S$
we have two small squares $S', S''$ such that the area of $S'$ equals $a^{2}$ and the area of $S''$ equals $b^{2}.$ Meanwhile we also have two small rectangles $R, R'$ of the same area $ab.$ 
Therefore the area $(a+b)^{2}$ of $S$ equals the sum $a^{2} + b^{2}$ of the areas of $S'$ and $S''$ plus the sum $ab + ab = 2ab$ of the areas of $R$ and $R'$, i.e.
$$(a+b)^{2} = a^{2} + b^{2} + 2ab.$$  
