Finding the antiderivatives of a trigonometric function in two different intervals I wanted to find the antiderivatives of the function $f(x)=\frac{1}{sin(x)+cos(x)+2}$ in $[0,\pi[$ first and then in $[0,2\pi]$. Now, as long as the first set is concerned, I used Weierstrass's substitution to find that $$\int f(x)dx=\sqrt2 \cdot arctan \left(\frac{tan(x/2)+1}{\sqrt2}\right)+c$$ This result seems fine to me since the antiderivatives of $f$ are well defined in $[0,\pi[$. But when we consider $[0,2\pi]$, the antiderivatives are not well defined since $F(x)=\sqrt2 \cdot arctan \left(\frac{tan(x/2)+1}{\sqrt2}\right)$ is not continuous at $x=\pi$, so I ended up saying that in this case $$\int f(x)dx=\emptyset$$ I think the reason why this is true (please correct me if I'm wrong) is that, since our function is defined on an interval ($[0,2\pi]$ in this case), its antiderivatives must differ by a constant everywhere in $[0,2\pi]$, but this obviously doesn't happen when $x=\pi$, i.e taken two antiderivatives, $F$ and $G$, we couldn't write $G(x)=F(x)+c \ \forall x\in[0,2\pi]$, because it wouldn't make any sense when $x=\pi$
 A: the antiderivative you obtain is reliable only in the interval $-\pi < x < \pi$ since the Weierstrass substitution is defined only for this particular interval. Indeed the function $f(x) = \frac{1}{\sin(x)+\cos(x)+2}$ is continuous and so it has a continuous antiderivative on all $\mathbb{R}$.
That being said having the right antiderivative in $(-\pi,\pi)$ is  enough to create the antiderivative on all $\mathbb{R}$ because the function has period $2\pi$.
We will use $f(x-\pi)$ so that the formulation of $\int_0^{x} f(x)dx$ is easier. The indefinite integral is
$$\int f(x-\pi)dx=-\sqrt2  \arctan \left(\frac{1-3\tan(\frac{x}{2})}{\sqrt2}\right), -\pi < x < \pi$$
and so in general
\begin{align}
\newcommand{\floor}[1]{\lfloor #1 \rfloor}\int_0^{x} f(x)dx &= \floor{\frac{x}{2\pi}}\int_{-\pi}^{\pi} f(x-\pi)dx+ \int_{-\pi}^{x-\pi-2\pi\floor{\frac{x}{2\pi}}}f(x-\pi)dx \\
& = \floor{\frac{x}{2\pi}}\sqrt{2}\pi+ \int_{-\pi}^{x-\pi-2\pi\floor{\frac{x}{2\pi}}}f(x-\pi)dx \\
& = \floor{\frac{x}{2\pi}}\sqrt{2}\pi -  \sqrt2  \arctan \left(\frac{1-3\tan(\frac{x-\pi-2\pi\floor{\frac{x}{2\pi}}}{2})}{\sqrt2}\right)+\frac{\pi}{\sqrt{2}}
\end{align}
As you can see on Wolfram this is a continuous function as expected.
There is one final concern: because of the Weirstrass substitution is defined on $(-\pi,\pi)$ you will find some undefined points inside the function above, specifically $x=2n\pi$ for $n \in \mathbb{N}$, but because the antiderivative is continuous you can define these points as the limit of the function  which gives you
$$F(x) = \begin{cases}   
\sqrt{2} n \pi & \mbox{if }  x = 2n\pi \\ 
\floor{\frac{x}{2\pi}}\sqrt{2}\pi -  \sqrt2  \arctan \left(\frac{1-3\tan(\frac{x-\pi-2\pi\floor{\frac{x}{2\pi}}}{2})}{\sqrt2}\right)+\frac{\pi}{\sqrt{2}} & \mbox{otherwise } \end{cases}$$
A: Thanks to @Tortar's answer I think I found out what was missing in my reasoning and now I'm going to explain it. To begin with, we want to find the antiderivatives of $f$ in $[0,\pi[$, and we determined that in this case $$\int f(x)dx=\sqrt2 \cdot arctan\left(\frac{tan(x/2)+1}{\sqrt2}\right)+c$$
So far, so good. Now, in $[0,2\pi]$ our $f$ is continuous and so we expect to find antiderivatives due to Torricelli's theorem. Let $F(x)=\sqrt2 \cdot arctan\left(\frac{tan(x/2)+1}{\sqrt2}\right)+c$ and $G$ be a function such that $G'(x)=f(x) \ \forall x \in[0,2\pi]$. From what I said until now, it follows that $G$ is an antiderivative of $f$ in $[0,\pi[$, so it must differ to $F$ by a constant (the same argument is valid in $]\pi,2\pi])$. So this should give us an hint about the fact that the antiderivatives in $[0,2\pi]$ are "similar" to $F(x)$, which has to be made continuous at $x=\pi$. So let us redefine $F$ in the following way $$F(x)=\begin{cases}\sqrt2 \cdot arctan\left(\frac{tan(x/2)+1}{\sqrt2}\right)+c, \ \ \ x\in[0,\pi[ \\ \frac{\pi}{\sqrt2}+c, \ \ \ x=\pi \\\sqrt2 \cdot arctan\left(\frac{tan(x/2)+1}{\sqrt2}\right)+\sqrt2\pi+c, \ \ \ x\in]\pi,2\pi]\end{cases}$$ Which is indeed (or at least, it should be) an antiderivative of $f$ in $[0,2\pi]$
