Expanding brackets to natural powers When expanding a bracket with a power to get terms in the form $a^n+b^n$, there is a pattern that appears similar to binomial theorem(if not a special case of). For example, 
$$a^2+b^2=(a+b)^2-2ab$$
$$a^3+b^3=(a+b)^3-3(ab)(a+b)$$
$$a^4+b^4=(a+b)^4-4(ab)(a+b)^2+2(ab)^2$$
2, 3, 4 are binomial coefficients from pascals triangle, which makes sense as there are two terms in the bracket, so n choose 2, but I can't really get my head around the $ab$, $a+b$ terms. Is there a name for this where I can find out more about this, or a general method for any finding $a^n + b^n$. 
 A: We derive a  formula for $a^n+b^n$ with the help of the generating function
$Q(z)=\sum_{n=0}^\infty \left(a^n+b^n\right)z^n$.
We obtain
\begin{align*}
Q(z)&=\sum_{n=0}^\infty\left(a^n+b^n\right)z^n=\sum_{n=0}^\infty (az)^n+\sum_{n=0}^\infty(bz)^n\\
&=\frac{1}{1-az}+\frac{1}{1-bz}\tag{2}\\
&=\frac{2-(a+b)z}{1-(a+b)z+abz^2}\\
&=\left(2-(a+b)z\right)\sum_{k=0}^\infty\left((a+b)-abz\right)^kz^k\tag{3}
\end{align*}
In (2) and (3) we apply a geometric series expansion. We see in (3) a representation in terms of $a+b$ and $ab$ and use this relationship to derive a formula for $a^n+b^n$. It is convenient to use the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ of a series.

We obtain from (3) for $n\ge 0$:
  \begin{align*}
\color{blue}{a^n+b^n}&=[z^n]Q(z)\\
&=[z^n]\sum_{k=0}^{\infty}\left((a+b)-abz\right)^kz^k\left(2-(a+b)z\right)\\
&=\sum_{k=0}^n[z^{n-k}]\sum_{j=0}^k\binom{k}{j}(-abz)^j(a+b)^{k-j}\left(2-(a+b)z\right)\tag{4}\\
&=\sum_{k=0}^n[z^k]\sum_{j=0}^{n-k}\binom{n-k}{j}(-abz)^j(a+b)^{n-k-j}\left(2-(a+b)z\right)\tag{5}\\
&=2\sum_{k=0}^{\lfloor n/2\rfloor}\binom{n-k}{k}(-ab)^k(a+b)^{n-2k}\\
&\qquad-\sum_{k=1}^{\lfloor n/2\rfloor}\binom{n-k}{k-1}(-ab)^{k-1}(a+b)^{n-2k+2}\tag{6}\\
&=2\sum_{k=0}^{\lfloor n/2\rfloor}\binom{n-k}{k}(-ab)^k(a+b)^{n-2k}\\
&\qquad-\sum_{k=0}^{\lfloor n/2\rfloor-1}\binom{n-k-1}{k}(-ab)^{k}(a+b)^{n-2k}\tag{7}\\
&\,\,\color{blue}{=\sum_{k=0}^{\lfloor n/2\rfloor}\left(2\binom{n-k}{k}-\binom{n-k-1}{k}\right)(-ab)^k(a+b)^{n-2k}}\tag{8}
\end{align*}

Comment:


*

*In (4) we expand the binomial and apply the rule $[z^p]z^qA(z)=[z^{p-q}]A(z)$. We also restrict the upper limit of the sum with $n$ since indices with $k>n$ do not contribute.

*In (5) we change the order of summation $k\to n-k$.

*In (6) we select the coefficient of $[z^k]$. We also restrict the upper limit of the sum with $\lfloor n/2\rfloor$ since greater indices do not contribute.

*In (7) we shift the index by one to start with $k=0$ in the second sum, too.

*In (8) we collect the sums by noting that we use $\binom{p}{q}=0$ if $p,q$ are non-negative integer with $p<q$.

The sequence $\left(q_{n,k}\right)_{n,k}$ of coefficients in
  \begin{align*}
&Q(z)=\sum_{n=0}^\infty \left(a^n+b^n\right)z^n=\sum_{n=0}^\infty \sum_{k=0}^{\lfloor n/2\rfloor} q_{n,k} (ab)^k (a+b)^{n-2k}z^n\\
\\
&\left(q_{n,k}\right)_{n\geq 0, 0\leq k\leq \lfloor n/2\rfloor}=(1;1;1,-2;1, -3;1, -4, 2;1, -5, 5;\\
&\qquad \qquad  \qquad \qquad \qquad1,-6, 9, -2;\color{blue}{1, -7, 14, -7};\ldots)
\end{align*}
  is archived in OEIS as A132460. We get for instance for $n=7$ the entries $\color{blue}{1,-7,14}$ and $\color{blue}{-7}$, so that
  \begin{align*}
a^7+b^7=(a+b)^7-7ab(a+b)^5+14(ab)^2(a+b)^3-7(ab)^3(a+b)
\end{align*}

