Recall that (cosnq+isinnq)=(cosq+isinq)n
In this case we use n=5.
Again we write c for cosq and s for sinq, for brevity and expand that right-hand side using the binomial theorem.
The right-hand side becomes:
(c+is)5=c5+5c4is +10c3(is)2 +10c2(is)3 +5c(is)4 +(is)5.
This simplifies to:
(c+is)5=c5+5isc4- 10c3s2 -i10c2s3 +5cs4 is5
We can now put this new version of the right-hand side into the original equation:
(cos5q+isin5q)=c5+5isc4- 10c3s2 -i10c2s3 +5cs4 +is5
Comparing the real parts then gives us the expansion we wanted:
cos5q=c5- 10c3s2+5cs4.
i.e. cos5q= cos5q- 10cos3q sin2q+ 5cosqsin4q.