Multiple answers in evaluation of a definite integral. Consider this definite integral
$$I=\int_0^{2\pi}\dfrac{x\cos x}{1 +\cos x}dx$$
Method 1
$$I=\int_0^{2\pi}\dfrac{x\cos x}{1 +\cos x}dx.....(1)$$
$$I=\int_0^{2\pi}\dfrac{(2\pi-x)\cos (2\pi-x)}{1 +\cos (2\pi-x)}dx.....(2)$$
Adding (1) and (2)
$$2I=\int_0^{2\pi}\dfrac{2\pi \cos x}{1 +\cos x}dx$$
$$I=\pi \int_0^{2\pi}\dfrac{\cos x}{1 +\cos x}dx$$
$$I=2\pi \int_0^{\pi}\dfrac{\cos x}{1 +\cos x}dx.....(P1)$$
$$I=2\pi\int_0^{\pi}\dfrac{1+\cos x-1}{1 +\cos x}dx$$
$$I=2\pi \int_0^{\pi}1-\dfrac{1}{1 +\cos x}dx$$
$$I=2\pi \int_0^{\pi}1dx-2\pi \int_0^{\pi}\dfrac{1}{1 +\cos x}dx$$
$$I=2\pi[x]_0^\pi -2\pi \int_0^{\pi}\dfrac{1}{2\cos ²\dfrac{x}{2}}dx$$
$$I=2\pi ² - \pi \int_0^{\pi} \sec  ²\dfrac{x}{2}\ dx$$
$$\displaystyle I=2\pi ² - 2\pi \left[ tan \dfrac{x}{2}\right]_0^{\pi} $$
$$\displaystyle I=2\pi ² - 2\pi \left[ \infty - 0 \right] $$
$$I=-\infty$$
Method 2
$$I=\int_0^{2\pi}\dfrac{x\cos x}{1 +\cos x}dx.....(1)$$
$$I=\int_0^{2\pi}\dfrac{(2\pi-x)\cos (2\pi-x)}{1 +\cos (2\pi-x)}dx.....(2)$$
Adding (1) and (2)
$$2I=\int_0^{2\pi}\dfrac{2\pi \cos x}{1 +\cos x}dx$$
$$I=\pi \int_0^{2\pi}\dfrac{\cos x}{1 +\cos x}dx$$
$$I=\pi\int_0^{2\pi}\dfrac{1+\cos x-1}{1 +\cos x}dx$$
$$I=\pi \int_0^{2\pi}1-\dfrac{1}{1 +\cos x}dx$$
$$I=\pi \int_0^{2\pi}1dx-\pi \int_0^{2\pi}\dfrac{1}{1 +\cos x}dx$$
$$I=\pi[x]_0^{2\pi} -\pi \int_0^{2\pi}\dfrac{1}{2\cos ²\dfrac{x}{2}}dx$$
$$I=2\pi ² - \dfrac{\pi}{2} \int_0^{2\pi} \sec  ²\dfrac{x}{2}\ dx$$
$$\displaystyle I=2\pi ² - \pi \left[ tan \dfrac{x}{2}\right]_0^{2\pi} $$
$$\displaystyle I=2\pi ² - \pi \left[ 0-0\right] $$
$$I=2\pi ²$$

$$(P1)-->\ \int_0^{2a} f(x)dx=2\int_0^af(x)dx$$if $f(2a-x)=f(x)$
I have checked these methods several times, but can't find any mistake. Method 1 seems to be wrong as the given answer was $2\pi ²$. What could be the mistake?
 A: Actually, the first method is correct and the second method is wrong. To see what is happening here, notice that the integrand is almost proportional to $\frac{1}{(x-\pi)^2}$, precisely in the following sense:
$$ \lim_{x \to \pi} (x-\pi)^2 \frac{x \cos x}{1+\cos x}
= -2\pi. $$
So the integrand diverges to $-\infty$ as $x\to\pi$.
$\hspace{8.5em}$
As far as improper integrability is concerned, having discontinuity points at which $|f(x)|$ diverges to $\infty$ is not necessarily a threat for the convergence of the improper integral $\int f(x) \, dx$. In your case, however, we know that$\int_{\pi-\delta}^{\pi+\delta} \frac{1}{(x-\pi)^2} \, dx = \infty$ for any $\delta > 0$, hence the integral in question does not converge by comparison test.
To see what is wrong in your second approach, note that $u = \tan(x/2)$ has discontinuity at $x = \pi$, hence cannot be used as a valid substitution over the interval $[0, 2\pi]$. (Of course, it can be used as a substitution over the interval $[0,\pi)$, which is why your first approach is valid.)
$\hspace{8.5em}$
