Antiderivative of $\cos(x)\ln(1+\cos(x))$ I'm trying to find the antiderivative of $A(x)=\cos(x)\log(1+\cos(x))$
By using integration by parts I get :
$$\int A(x)\, dx = \sin(x)\ln(1+\cos(x))+\int \frac{\sin^2(x)}{1+\cos(x)} \\ =\sin(x)\ln(1+\cos(x))+\sin(x)\int \frac{\sin(x)}{1+\cos(x)}\\ =\sin(x)  \ln(1+\cos(x))+\sin(x)(-\ln(1+\cos x))=0$$ 
However using formal calculator I find the antiderivative is $x+\sin(x)\ln(\cos(x)+1)-\sin(x)$. I do not see where is my mistake I applied $\int u'v \,dx=uv-\int uv'$ with $u'=\cos(x)$ and $v=\ln(1+\cos(x))$
Thank you

On the second line, you cannot pull the $\sin(x)$ in front of the integral.  You should use 
$$
\sin^2(x)=1-\cos^2(x)=(1+\cos(x))(1-\cos(x)).
$$
