I'm trying to find a periodic solution for the following inhomogeneous equation:

u'' − u = cos^2(t).

I'm thinking that in order for the solution to be periodic it must be equal just with the particular solution(for the complementary we put the constants C1=C2=0)

Also I can write cos^2(t) as cos^2(t)=(1+cos2t)/2 and then I can choose the particular solution to be of the form u_p(x)=-1/2 +Asin(t)+Bcos(t).

After I diff and substitute into the initial equation I get the answer -1/2 +1/3*cos2t which is not correct.

How can I solve this?Also if I can leave cos^2(t) as this and find a solution of the form

Acos^(t)+Bsin^2(t) will it still be correct?