# [Math] How to derive the last term of the expansion of $\cos n\theta$ using De Moivre’s Theorem

complex numbers

If n be odd, then the last term in the expansion of $$\cos n\theta$$ is $$(-1)^{\frac{n-1}{2}}\displaystyle\binom n{n-1}\cos\theta\sin^{n-1}\theta\,.$$

If $$n$$ be even, then the last term in the expansion of $$\cos n\theta$$ is $$(-1)^\frac n2 \sin^n\theta\,.$$

This is what the author of my book asserted regarding the expansion of $$\cos n\theta$$ using De Moivre's Theorem.

Well, expanding $$\cos n\theta$$ from De Moivre's Theorem is quite easy:

$$\cos n\theta= \cos^n\theta – \binom n2 \cos^{n-2}\theta\sin^2\theta+ \binom n4\cos^{n-4}\theta\sin^4\theta – \ldots$$

But I'm not getting how to conclude the last terms as stated by the author.

Could anyone shed light on how the author concluded the last terms for $$n$$ being even and odd?

For $r = 0, 1, \ldots, \lfloor{n/2}\rfloor$, the $r^\text{th}$ term in the expansion of the identity $$2\cos n\theta = (\cos n\theta + i\sin n\theta) + (\cos n\theta - i\sin n\theta) = (\cos\theta + i\sin\theta)^n + (\cos\theta - i\sin\theta)^n$$ (after dividing both sides by $2$) is $$(-1)^r\binom{n}{2r}\cos^{n-2r}\theta\sin^{2r}\theta.$$ If $n$ is odd, say $n = 2k + 1$ ($k \geqslant 0$), the last term is given by $r = k = (n - 1)/2$, and $2r = n - 1$. If, on the other hand, $n$ is even, say $n = 2k$ ($k \geqslant 0$), the last term is given by $r = k = n/2$, and $2r = n$.
In a bit more detail, as requested: $$(\cos\theta + i\sin\theta)^n + (\cos\theta - i\sin\theta)^n = \sum_{m=0}^n \binom{n}{m}\left(i^m + (-i)^m\right)\cos^{n-m}\theta\sin^m\theta,$$ and the RHS can be written as $S_0$ + $S_1$, where $$S_0 = \sum_{r=0}^{\lfloor{n/2}\rfloor} \binom{n}{2r}\left(i^{2r} + (-i)^{2r}\right)\cos^{n-2r}\theta\sin^{2r}\theta,$$ and $$S_1 = \sum_{s=0}^{\lfloor{(n-1)/2}\rfloor} \binom{n}{2s+1}\left(i^{2s+1} + (-i)^{2s+1}\right)\cos^{n-2s-1}\theta\sin^{2s+1}\theta.$$ In $S_0$, the subexpression $i^{2r} + (-i)^{2r}$ can be simplified, thus: $$i^{2r} + (-i)^{2r} = 2(i^2)^r = 2(-1)^r,$$ whereas in $S_1$, we have $$i^{2s+1} + (-i)^{2s+1} = i^{2s+1} - i^{2s+1} = 0.$$ So $S_1 = 0$, and we end up with: $$(\cos\theta + i\sin\theta)^n + (\cos\theta - i\sin\theta)^n = 2\sum_{r=0}^{\lfloor{n/2}\rfloor} (-1)^r\binom{n}{2r}\cos^{n-2r}\theta\sin^{2r}\theta,$$ as was stated earlier.