# Anti-derivative of continuous function $\frac{1}{2+\sin x}$

I use tangent half-angle substitution to calculate this indefinite integral: $$ \int \frac{1}{2+\sin x}\,dx = \frac{2}{\sqrt{3}}\tan^{-1}\frac{2\tan \frac{x}{2}+1}{\sqrt{3}}+\text{constant}. $$

Wolfram Alpha also give the same answer. However, $\frac{2}{\sqrt{3}}\tan^{-1}\frac{2\tan \frac{x}{2}+1}{\sqrt{3}}$ is discontinuous on $(n+1)\pi$ where $n$ is any integer. Why is an anti-derivative of a continuous function discontinuous?

Let's examine the first troublesome positive point, that is, $\pi$. We know that an antiderivative in the interval $(-\pi,\pi)$ is $$ f_0(x)=\frac{2}{\sqrt{3}}\arctan\frac{2\tan(x/2)+1}{\sqrt{3}}+c_0 $$ We also know that an antiderivative in the interval $(\pi,3\pi)$ is of the form $$ f_1(x)=\frac{2}{\sqrt{3}}\arctan\frac{2\tan(x/2)+1}{\sqrt{3}}+c_1 $$ Note that $$ \lim_{x\to\pi^{-}}f_0(x)=\frac{\pi}{\sqrt{3}}+c_0 $$ and $$ \lim_{x\to\pi^{+}}f_1(x)=-\frac{\pi}{\sqrt{3}}+c_1 $$ so in order to get continuity at $\pi$ we have $$ c_1=\frac{2\pi}{\sqrt{3}}+c_0 $$

Do the same for the other intervals.

One thing not emphasized much in the conventional calculus curriculum is that things like
$$
\int \frac{dx} x = \log|x| + \text{“constant”}
$$
are not true unless one takes “constant” to mean **piecewise** constant:
$$
\int \frac{dx} x = \log|x| + \begin{cases} \text{one constant} & \text{if }x>0, \\ \text{another constant} & \text{if }x<0. \end{cases}
$$
and:
\begin{align}
& \int \sec x\,dx \\[4pt]
= {} & \log|\sec x+\tan x| + \cdots \text{what?} \\
& \cdots + \text{a different constant on each interval between vertical asymptotes.}
\end{align}
The comments under the question itself are pretty good so far:

- “egreg” points out that the technique involving the tangent half-angle substitution is valid
**only**on intervals between vertical asymptotes of the function $x\mapsto\tan\frac x 2$. That means it doesn't rule out anything that happens at those points: it doesn't say that there's an answer there or that there's not. - Jeppe Stig Nielsen points out that the antiderivative must be everywhere increasing since the function being integrated is everywhere positive. That means the answer cannot be a periodic function.
- “runaround” and “KCd” remind us that there is such a thing as removable discontinuities.
- You yourself point out that the antiderivative of a continuous function should be continuous.

Now just put all four of these points together and figure out which **“piecewise constant”** will give you a continuous function. That function will be everywhere increasing.