Strange things happening with definite integration by substitution There are two ways solving the definite integration by substitution. One is to solve the indefinite integration first, then use the evaluation  theorem. Another is to use the substitution rule for definite integral. However, when I solved some problems, say calculating the following integral:$$\int_0^{2\pi}\frac{dx}{(2+\cos (x)) (3+\cos (x))},$$
the answer is 0 by the first method. But, the graph of the integrand implies that this is impossible. So, what is the problem?
 A: You got the wrong answer.
Use the method similar to partial fractions,
$$\int \frac{dx}{(2+\cos{x})(3+\cos{x})}
=\int \left(\frac{1}{2+\cos{x}}-\frac{1}{3+\cos{x}}\right)dx.$$
Draw the following figure,

we have
$\cos{\frac{x}{2}}=\frac{1}{\sqrt{1+u^2}}$ and
$\sin{\frac{x}{2}}=\frac{u}{\sqrt{1+u^2}}$.
Then $\sin{x}=2\sin{\frac{x}{2}}\cos{\frac{x}{2}}=\frac{2u}{1+u^2}$
and $\cos{x}=\cos^2{\frac{x}{2}}-\sin^2{\frac{x}{2}}=\frac{1-u^2}{1+u^2}$.
In addition,
$u=\tan{\frac{x}{2}}$ and $x=2\arctan{u}$
and $dx=\frac{2}{1+u^2}du$.
Therefore,
$$\int \frac{dx}{(2+\cos{x})}
=\int \frac{\frac{2}{1+u^2}}{2+\frac{1-u^2}{1+u^2}}du
=\int \frac{2}{3+u^2}du
=\frac{2\arctan{\frac{u}{\sqrt{3}}}}{\sqrt{3}}+C
=\frac{2\arctan{\frac{\tan{\frac{x}{2}}}{\sqrt{3}}}}{\sqrt{3}}+C$$
Similarly,
$$\int \frac{dx}{(3+\cos{x})}
=\frac{\arctan{\frac{\tan{\frac{x}{2}}}{\sqrt{2}}}}{\sqrt{2}}+C$$
So
$$\int_{0}^{2\pi} \frac{dx}{(2+\cos{x})(3+\cos{x})}
=\left[\frac{2\arctan{\frac{\tan{\frac{x}{2}}}{\sqrt{3}}}}{\sqrt{3}}
-\frac{\arctan{\frac{\tan{\frac{x}{2}}}{\sqrt{2}}}}{\sqrt{2}}\right]_{0}^{2\pi}
=\left(\frac{2}{\sqrt{3}}-\frac{1}{\sqrt{2}}\right)
\neq 0$$
