$$\int{\cos^2(x)}dx$$ Where did I go wrong in my evaluation of this integral?
$$=x\cos^2x - \int-2x\sin(x)\cos(x)\,dx$$ $$=x\cos^2x + \int x\sin(2x)\,dx$$ $$=x\cos^2x + \left(\frac {-x\cos(2x)}2 -\int \frac{-\cos(2x)}2\,dx\right)$$ $$=x\cos^2x + \left(\frac {-x\cos(2x)}2 + \frac 12\cdot\frac{\sin(2x)}2\right)$$ $$x\cos^2x-\frac{x\cos(2x)}2+\frac{\sin(2x)}4 + C$$
And this is clearly wrong, but I don't know where I messed up in my calculations. Would anyone mind correcting me somewhere?
Your answer is perfectly correct, albeit it is given in a more complicated form than necessary. A little simplification (replacing the $\cos 2x$ by $2\cos^2 x-1$) will put it in standard form.