Computing a definite integral of a continuous function, using a discontinuous substitution (t formula)? I am trying to calculate:
$$
\int_0^{\pi} \frac{dx}{2+\cos(x)+\sin(x)}
$$
using a t-formula substitution. The issue is, despite being able to find a primitive of:
$$
\sqrt{2}\arctan\left(\dfrac{\tan\left(\frac{x}{2}\right)+1}{\sqrt{2}}\right)
$$
We can't evaluate this given the fact that $\tan(\frac{\pi}{2})$ is undefined.
The original function has no discontinuity at this value.

And the calculated primitive is undefined on regular intervals where it differs only by a constant in sections, therefore meaning that the integral cannot be taken to or across these values directly.

How can I evaluate the above integral given this problem?
 A: There is no real problem, because the primitive (antiderivative) over the interval $[0,\pi]$ is
$$
f(x)=\begin{cases}
\sqrt{2}\arctan\left(\dfrac{\tan\left(\frac{x}{2}\right)+1}{\sqrt{2}}\right) & 0\le x<\pi \\[4px]
\dfrac{\pi}{\sqrt{2}} & x=\pi
\end{cases}
$$
Not over the entire real line, because the antiderivative cannot be periodic, as the integrand is everywhere positive.
How do you get the full antiderivative? The part of the graph from $\pi$ to $3\pi$ has to be “raised” by $\pi\sqrt{2}$ to glue with the part from $-\pi$ to $\pi$ and so on for the next intervals. The part from $-3\pi$ to $-\pi$ has instead to be “lowered”.
The function so obtained is differentiable over the entire real line (being the antiderivative of a continuous function).
A: Avoid the undefined functional value by taking the limit $x\to\pi$
$$
\int_0^{\pi} \frac{dx}{2+\cos x+\sin x}
=\sqrt{2}\arctan\left(\dfrac{\tan\frac{x}{2}+1}{\sqrt{2}}\right)\bigg|_0^{x\to\pi}\\
 =\sqrt2\left( \lim_{y\to\infty} \arctan y-\arctan\frac1{\sqrt2}\right)=
 \sqrt2\left( \frac\pi2 -\arctan\frac1{\sqrt2}\right)
$$
