If you have encountered Euler's Formula then it works out like this:
Euler's Formula gives us: #cos x + i sin x = e^(ix)#
So:
#cos(3x)+i sin(3x) = e^(i3x) = (e^(ix))^3 = (cos(x)+i sin(x))^3#
#=cos^3(x)+3cos^2(x) i sin(x) + 3 cos(x) i^2 sin^2(x) + i^3 sin^3(x)#
#=(cos^3(x)-3 cos(x)sin^2(x)) + i(3 cos^2(x) sin(x)-sin^3(x))#
Equating the imaginary parts of both ends, we get:
#sin(3x) = 3 cos^2(x)sin(x)-sin^3(x)#
#= sin(x)(3 cos^2(x)-sin^2(x))#
#=sin(x)(3(1 - sin^2(x))-sin^2(x))# #color(green)([[ "using: " sin^2(x)+cos^2(x) = 1 ]])#
#=sin(x)(3-4sin^2(x))#
#=3sin(x)-4sin^3(x)#
Equating the real parts of both ends, we also get:
#cos(3x) = cos^3(x)-3 cos(x)sin^2(x)#
#=cos(x)(cos^2(x)-3sin^2(x))#
#=cos(x)(cos^2(x)-3(1-cos^2(x)))#
#=cos(x)(4 cos^2(x)-3)#
#=4cos^3(x)-3cos(x)#