use integration by parts and let u=cosx and dv=cosxdx

du=-sinx v=sinx

Int(udv)=uv-Int(vdu) so uv=cosx(sinx) and vdu=sinx(-sinx)

so we have:

Int(cos^2(x)=(cosx)(sinx)+Int(sin^2x)

(the (-) became + because of the -sinx, so we add Int(vdu))

Now it looks not better because we have sin^2x instead of cos^2x,

but sin^2x=1-cos^2x since sin^2x+cos^2x=1

So we have

Int(cos^2x)=cosxsinx+Int(1-cos^2x)

=cosxsinx+Int(1)-Int(cos^2x)

So now add the -Int(cos^2x) on the RHS to the one on the LHS

2Int(cos^2x)=cosxsinx+x

so Int(cos^2x)=1/2[cosxsinsx+x] and now add the constant!

final answer

Integral of cos^2x=(1/2)(cosx sinx + x)+C = x/2 + (1/4)sin 2x + C

(because sin x cos x = (1/2)sin 2x)

right??