# Primitive of a continuous function over $\Bbb R$

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. 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)$$

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

Yes, it is possible. First compute in a standard way

Integrate[3/(5-4 Cos[x]),x]
(*2 ArcTan[3 Tan[x/2]]*)
Plot[2 ArcTan[3 Tan[x/2]],{x,-10π,10π}]


Now try the Rubi package

Get["Rubi"]
Int[3/(5-4 Cos[x]),x]
(*x+2 ArcTan[Sin[x]/(2-Cos[x])]*)
Plot[x+2 ArcTan[Sin[x]/(2-Cos[x])],{x,-10π,10π}]


• Also Integrate[3/(5 - 4 Cos[t]), {t, 0, x}, Assumptions -> x \ [Element] Reals] does the job, producing 2 \ [Pi] IntegerPart[x/(2 \ [Pi])]+3 ([Piecewise] -(2/3) (\ [Pi]-ArcTan[3 Tan[x/2]]) FractionalPart[x/(2 \ [Pi])]<=-(1/2) 2/3 ArcTan[3 Tan[x/2]] -(1/2)<FractionalPart[x/(2 \ [Pi])]<1/2 2/3 (\ [ Pi]+ArcTan[3 Tan[x/2]]) True Feb 14, 2020 at 17:31
• Exactly what I was looking for! Thank you.
– user69708
Feb 14, 2020 at 18:10
• @user64494 Not as simple, but indeed it works. It's the natural way to make the standard solution continuous by hand, by adding a constant on each subinterval. I thought I tried, but I probably forgot the assumption.
– user69708
Feb 14, 2020 at 18:14
• Rubi works also on the algebraic case of Risch algorithm, which is quite impressive: Int[x/Sqrt[x^4 + 10 x^2 - 96 x - 71], x] (example from Wikipedia).
– user69708
Feb 14, 2020 at 18:17

Integrate[f[x], x] gives an antiderivative whose derivative is generically equal to f[x]. From the docs:

For indefinite integrals, Integrate tries to find results that are correct for almost all values of parameters.

A primitive function of a continuous function $$f$$ such as the OP seeks is given by $$F(x) = \int_a^x f(t) \; dt \,.$$

prim = Integrate[3/(5 - 4 Cos[t]), {t, 0, x},
Assumptions -> -Infinity < x < Infinity]


Plot[prim, {x, -30, 30}]
`

• It's enough Assumptions -> -Infinity < x or Assumptions -> x < Infinity in the above. This is the same as x \ [Element] Reals Feb 16, 2020 at 7:18