# How to calculate $(a + b)^n$?

I'm trying to review and improve my math using Khan Academy. I'm now beginning to play with derivatives. Calculations like $(x + h)^n$ tend to come up often. I found out empirically that $(a + b)^2 = (a^2 + b^2 + 2ab)$ and a vague memory from school surfaced to confirm this intuition. I'm wondering if there is a method to calculate $(a + b)^n$ for any value of n. If you can also tell me what topic I've missed and should go back to, that would allow me to do do some exercises before carrying on with derivatives.

-
You found $(a+b)^2$ empirically? What does that mean? You tried many values of $a$ and $b$? – Najib Idrissi Jun 27 '11 at 6:24
I did the multiplication manually. $(a + b)^2 = (a + b)(a + b) = a^2 + ab + ba + b^2 = a^2 + b^2 + 2ab$ I could do it for any power but it was very tedious so I suspected there'd be a better way, which has been provided by the answer. – Alex Marandon Jun 27 '11 at 17:26
Okay. I'd rather ask, because some people do very surprising things :) – Najib Idrissi Jun 28 '11 at 15:27

\begin{align}(a+b)^n &= a^n + \binom{n}{1}a^{n-1}b + \binom{n}{2}a^{n-2}b^2 + \dots + \binom{n}{n-1}ab^{n-1} + b^n \\ &= \sum_{r=0}^{n}\binom{n}{r}a^{n-r}b^{r} \\&= \sum_{r=0}^{n}\binom{n}{r}a^{r}b^{n-r}\end{align}