How does $(x+h)^3 = x^3 + 3x^2h + 3xh^2 + h^3$? Good afternoon my wonderful friends!
Whenever I do this equation I set it up using the difference of two cubes, which is as follows:
$(a+b)^3 = (a+b)(a^2-ab+b^2) = a^3 + b^3$
Whenever I try to use this formula  I always get:
$(x+h) x^2  - xh + h^2$

Simplify:

$x^3 - x^2h + h^2x + x^2h - xh^2 + h^3$
Simplify:

x^3 + h^3$
I don't understand were the three's come from in the final answer: $(x+h)^3 = x^3 + 3x^2h + 3xh^2 + h^3$
 A: $$(x+h)^3=(x+h)(x+h)^2=(x+h)(x^2+2hx+h^2)=$$
$$x^3+2hx^2+h^2x+hx^2+2h^2x+h^3=$$$$x^3+3hx^2+3h^2x+h^3$$
There are quicker ways to do this - the binomial theorem, for example - but I thought that longhand might help you to see a bit better what is going on. Another view: In
$$(x+h)^3=(x+h)(x+h)(x+h)$$ The eventual term in $h$ can get the $h-$factor from any of the three brackets - hence the factor $3$. There is only one way to take an $x$ from each bracket, hence the coefficient of $x^3$ is $1$.
A: Something awry should have jumped out at you when you wrote:
$$\color{blue}{\bf(a+b)^3} = (a+b)(a^2-ab+b^2) = \color{blue}{\bf a^3 + b^3}\;\;?$$
Just as $(a +b)^2 \neq a^2 + b^2$, it's also true that $(a+b)^3 \neq a^3 + b^3$.
So what went wrong? The difference of cubes does not apply here!
Rather, $(a+b)^3 = a^3 + 3a^2 b + 3ab^2 + b^3.$ You can confirm that this is so by expanding the factors: $$(a + b)^3 = (a+b)(a+b)^2 = (a+b)(a^2 + 2ab + b^2) \cdots$$
A: I don't know where you get "$a^2-ab+b^2$" from. Just use distributivity to carry out the multiplications by hand:
\begin{align}
(a+b)^2 &= (a+b)(a+b) = a(a+b)+b(a+b) \\&= a^2+ab+ba+b^2 = a^2+2ab+b^2
\end{align}
Thus,
\begin{align}
(a+b)^3 &= (a+b)(a+b)^2 = (a+b)(a^2+2ab+b^2) = a(a^2+2ab+b^2)+b(a^2+2ab+b^2) \\&= a^3+2a^2 b+ab^2 + ba^2 + 2ab^2+b^3 = a^3 + 3a^2b + 3ab^2 + b^3.
\end{align}
A: $$(a+b)^3 \neq a^3 + b^3$$
for example for $a=1$ and $b=1$ you get $(a+b)^3=(1+1)^3=2^3=8 \neq 2 = 1^3 + 1^3 = a^3 + b^3$
To evaluate $(a+b)^n$ one can use the property of the Pascal's triangle

in your case:
$$(a+b)^3 = (a+b)*(a+b)*(a+b)=(a^2 + ab + ab + b^2) * (a+b)=$$
$$(a^2 + 2ab + b^2)* (a+b) = a^3 + a^2b + 2a^2b + 2ab^2 + b^2a+ b^3 = $$
$$1a^2 + 3a^2b + 3ab^2 + 1b^3$$
You can look at the Pascal's triangle in line 4 (where you have $n = 3$) and see what the coefficient of your expanded polynomial are. You will see that are exactly $1,3,3,1$
I.e. for $n=4$, line $5$ We have the coefficients $1,4,6,4,1$ and indeed $(a+b)^4 = 1a^4 + 4 a^3b + 6a^2b^2 + 4ab^3 + 1b^4$
