A continuous function over $\Bbb R$ has a primitive that is also continuous over $\Bbb R$.

However, it often happens with Mathematica and other CAS that the result is not continuous, especially with trigonometric integrals computed with the [Weierstrass substitution](https://en.wikipedia.org/wiki/Tangent_half-angle_substitution). The result can't be correct because from a periodic integrand this substitution leads to a periodic primitive, while the primitive over $\Bbb R$ is not periodic in general.

For instance:

```
In[1]:= Integrate[3/(5 - 4 Cos[x]), x]
Out[1]= 2 ArcTan[3 Tan[x/2]]

```

**My question:**
Is there a way in Mathematica (an option, a package...) to obtain a continuous primitive in this case?

A correct one could be:

$$x + 2 \arctan\left(\frac{\sin x}{2 - \cos x}\right)$$

---

There are publications about this:

* D. J. Jeffrey, "[The Importance of Being Continuous](https://www.jstor.org/stable/2690852)"
* David J. Jeffrey, Albert D. Rich, "[The evaluation of trigonometric integrals avoiding spurious discontinuities](https://dl.acm.org/doi/10.1145/174603.174409)"

See also [this related question](https://math.stackexchange.com/questions/1942983/find-int-02-pi-frac15-4-cos-x-dx) on Math.SE.

I wonder if Mathematica has implementations of the methods mentioned in those articles.