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?

• Since when did $f'(x) = \lim_{h \to 0} \frac{f(x+h)^2 - f(x)^2}{h}$? – Yiyuan Lee Aug 19 '14 at 3:57
• You're using a derivative, so you're tacitly assuming that the characteristic of your field is zero, and in particular, not two. – Dorebell Aug 19 '14 at 3:59
• Are you sure it said $f(x + h)^2 - f(x)^2$, as opposed to $f(x + h) - f(x)$? – Elliott Aug 19 '14 at 4:05
• You should have studied $(a+b)^2=a^2+2ab+b^2$ long before seeing a limit or a derivative. – whacka Aug 19 '14 at 4:10
• This video should be helpful – Nick Aug 19 '14 at 4:14

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.

• This was also posted here. – Martin Sleziak Aug 19 '14 at 8:07
• Thank you so much thats what I want to see! An answer that shows the intuition of whats happening is the best. – Ray Kay Aug 19 '14 at 8:51
• @RayKay Nice to hear, that it helps. You are welcome. – callculus Aug 19 '14 at 9:05
• Nice explanation :) :) – Shaddy Jan 24 '16 at 17:11
• @Shaddy Thanks for the comment. – callculus Jul 9 '18 at 19:55

\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*}

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+b)^2=(a+b)(a+b)=a^2+ab+ba+b^2=a^2+2ab+b^2$

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.$$

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$

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$$

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.$$
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.