What is an antiderivative for $\frac{1}{1+3\cos^{2}x}$? Define $f:\mathbb R \rightarrow \mathbb R$ by $f(x)=\frac{1}{1+3\cos^{2}x}$.
Since $f$ is continuous, $f$ has an antiderivative. That is, there exists some function $F:\mathbb R \rightarrow \mathbb R$ such that $F^{\prime}=f$.
Using the substitution $u=\tan x$ and doing some work, we find that a possible antiderivative of $f$ is the function $g$ defined by $g(x)=\frac{1}{2}\tan^{-1}\frac{\tan x}{2}$.
However, the problem with $g$ is that it's not defined at odd multiples of $\pi/2$, while the $F$ we're seeking is defined on $\mathbb R$.
So, what is $F$ and how do we find it?
(Or is there a mistake somewhere in my argument above?)
 A: For each odd integer $k$, define $f_k:((k-2)\pi/2,k\pi/2) \rightarrow \mathbb R$ by $f_k(x)=\frac{1}{1+3\cos^{2}x}$.
As you've found, an antiderivative of $f_k$ is $g_k:((k-2)\pi/2,k\pi/2) \rightarrow \mathbb R$ defined by $g_k(x)=\frac{1}{2}\tan^{-1}\frac{\tan x}{2}$.
And as you've also correctly stated, we know by the FTC that $f$ must have an antiderivative $F$.
So, we guess that such a function $F$ can be constructed by "moving up or down" the functions $g_k$ and "stitching" them together, and also "filling in the holes" at each odd multiple of $\pi/2$.
By examining the graphs of each $g_k$, we come up with this guess:
For each odd integer $k$, define $F$ by
$$F(x)=\begin{cases}
\left(k-1\right)\frac{\pi}{2}, & \text{ for }x=\left(k-2\right)\frac{\pi}{2},\\
\frac{1}{2}\tan^{-1}\frac{\tan x}{2}+k\frac{\pi}{4}, & \text{ for }x\in\left(\left(k-2\right)\frac{\pi}{2},k\frac{\pi}{2}\right)\\
k\frac{\pi}{2}, & \text{ for }x=k\frac{\pi}{2}.
\end{cases},$$
To show that the above guess is correct, we can verify that $F^{\prime}=f$ (this will involve more work).

Similar questions: 1, 2, 3. See also Jeffrey and Rich (1994, "The Evaluation of Trigonometric Integrals Avoiding Spurious Discontinuities") and Jeffrey (1994, "The Importance of Being Continuous").
