2cosx+2cos^2(x)

=2cosx+2(cosx)^2

differentiate

=-2sinx-4sinx[cosx]'

=-2sinx+4sin^2(x)

but if i instead did

2cosx+2cos^2(x)

=2cosx+2cosxcosx

use product rule

=-4sinxcosx

different answers. did i do something wrong in the first method? it worked perfectly on a different problem, but i got this one wrong.