I was trying to compute this integral
$$\int_0^{2\pi} \frac{1}{5+3 \cos x} dx$$
using the substitution method $t = \tan \frac{x}{2}$ suggested in Michael Spivak's book: Calculus 3rd ed., pages 382-383.
So I got the antiderivative
$$\int \frac{1}{5+3 \cos x} dx = \frac{1}{2} \arctan \left(\frac{1}{2}\tan \frac{x}{2}\right)+ C$$
and then using the Fundamental Theorem of Calculus I get
$$\int_0^{2\pi} \frac{1}{5+3 \cos x} dx = \frac{1}{2} \arctan \left(\frac{1}{2}\tan \frac{x}{2}\right)\Big|_0^{2\pi} = 0.$$
However, when I was checking my work in WolframAlpha I get this result:
The area under the curve and the calculation from WolframAlpha makes sense to me.
One thing I noticed is that my antiderivative is not well defined everywhere, so maybe that is the reason why it does not work. But not sure :(
Update: Some members have suggested this answer: Find $\int_0^{2\pi} \frac{1}{4-5\cos x}dx$. Although it answers some of my questions, I was wondering if it is possible to compute an antiderivative defined on $\mathbb R$ that actually works without using complex analysis. :(
Can we compute the integral using an antiderivative defined on $\mathbb R$?
Edit 1: I fixed the value of the antiderivate I got.
Edit 2: Updated my question.
Edit 3: Updated my question again.