I want to evaluate the following integral:
$$\int_0^{2\pi}\frac{x\cos x}{1+\cos x}dx$$
In this, first I replace $x$ with $2\pi -x$. $$ I = \pi\int_{0}^{2\pi}{\frac{\cos(x)}{1+\cos(x)}\,\mathrm{d}x}$$ After that I thought that both limits $0$ and $2\pi$ are the same angle for cosine so integration should be zero.
So you are asked to evaluate the integral $\int_0^{2\pi}\frac{x\cos x}{1+\cos x}dx$ and this question comes from a textbook ...
IMHO, there are two options :
this is merely an error, and this happens sometimes, even in good textbooks
the author of the questions wants you to answer that it is not possible to evaluate the given integral, since it is a divergent one !
Here is why ...
The denominator $1+\cos(x)$ vanishes at $x=\pi$ and so, the convergence of this integral would mean the convergence of :
$$\int_0^{\pi}\frac{x\cos x}{1+\cos x}dx\quad\color{red}{\textrm{ and }}\quad\int_\pi^{2\pi}\frac{x\cos x}{1+\cos x}dx$$
But both diverge, because :
$$\frac{x\cos(x)}{1+\cos(x)}\underset{x\to\pi}{\sim}\frac{-\pi}{1-\cos(x-\pi)}\underset{x\to\pi}{\sim}\frac{-2\pi}{(x-\pi)^2}$$
[ The last equivalence comes from $\cos(h)\underset{h\to0}{=}1-\frac{h^2}{2}+o(h^2)$ ]
and we know that $\displaystyle{\int_0^1\frac{dt}{t^\alpha}}$ converges iff $\alpha<1$.
That said, it would be interesting to compute :
$$A=\int_0^{\pi/2}\frac{x\cos(x)}{1+\cos(x)}\,dx$$
which is well defined !
And the answer is $\displaystyle{A=\frac{\pi^2}8-\frac\pi2+\ln(2)}$.