Why is $ \cos^{n+1}(x) - n\sin^2(x)\cos^{n-1}(x)$ equal to $\cos^{n-1}(x)((n+1)\cos^2(x) -n)$ In reading a correction for an exercice, I stumbled on a strange equality.
Suppose $x \in [0, \pi]$, let $f_n(x)= \cos^n(x)\sin(x)$, then the derivative is equal to: 

$$ \cos^{n+1}(x) - n\sin^2(x)\cos^{n-1}(x)=\cos^{n-1}(x)\left[(n+1)\cos^2(x) -n\right]$$

Could someone explain to me, how is the right part of the equation found? 
 A: Note that 
$$ \cos^{n+1}x - n\sin^2x\cos^{n-1}x$$ 
$$=\cos^{n-1}x(\cos^2x-n\sin^2 x)$$
$$=\cos^{n-1}x\left[\cos^2x-n(1-\cos^2 x)\right]$$
$$=\cos^{n-1}x\left(\cos^2x-n+n\cos^2 x\right)$$
$$=\cos^{n-1}x\left[(n+1)\cos^2x-n\right]$$
A: $$\cos^{n+1}(x) - n\sin^2(x)\cos^{n-1}(x)=\\
\cos^{n+1}(x) - n(1-\cos^2(x))\cos^{n-1}(x)=\\
\cos^{n+1}(x) - n\cos^{n-1}(x)+n\cos^{n+1}(x)=\\
$$
A: $$\begin{align}
\cos^{n+1}(x)-n\sin^2(x)\cos^{n-1}(x)&=\cos^2(x)\cos^{n-1}(x)-n\sin^2(x)\cos^{n-1}(x)\\
&=\cos^{n-1}(x)\bigl(\cos^2(x)-n\sin^2(x)\bigr)\\
&=\cos^{n-1}(x)\bigl(\cos^2(x)-n\sin^2(x)+n(\underbrace{\cos^2(x)+\sin^2(x)-1}_{=0})\bigr)\\
&=\cos^{n-1}(x)\bigl((n+1)\cos^2(x)-n\bigr)\\
\end{align} $$
Or
$$\begin{align}
\cos^{n+1}(x)-n\sin^2(x)\cos^{n-1}(x)&=\cos^{n+1}(x)-n(1-\cos^2(x))\cos^{n-1}(x)\\
&=\cos^{n+1}(x)-n\cos^{n-1}(x)+n\cos^{n+1}(x)\\
&=(n+1)\cos^{n+1}(x)-n\cos^{n-1}(x)\\
&=\cos^{n-1}(x)\bigl((n+1)\cos^2(x)-n\bigr)
\end{align} $$
A: We have, $$\cos^{n+1} x - n\sin^2 x \cos^{n-1} x$$ $$= \cos^{n-1} x[ \cos^2 x - n\sin^2 x]$$ $$=\cos^{n-1} x[\cos^2 x-n(1-\cos^2 x)]$$ $$=\cos^{n-1}x[(n+1)\cos^2 x-n]$$
We have just used the identity $\sin^2 x = 1- \cos^2 x$ and simplified to get the answer. Hope it helps.
