Calculation of $\int\frac1{\tan \frac{x}{2}+1}dx$ Calculation of $\displaystyle \int\frac{1}{\tan \frac{x}{2}+1}dx$
$\bf{My\; Try}::$ Let $\displaystyle I = \displaystyle \int\frac{1}{\tan \frac{x}{2}+1}dx$, Now let $\displaystyle \tan \frac{x}{2}=t\;,$ Then $\displaystyle dx=\frac{2}{1+t^2}dt$
So $\displaystyle I = 2\int\frac{1}{(1+t)\cdot (1+t^2)}dt$
Now Using Partial fraction, 
$\displaystyle \frac{1}{(1+t)\cdot (1+t^2)} = \frac{A}{1+t}+\frac{Bt+C}{1+t^2}\Rightarrow 1=A(1+t^2)+(Bt+C)(1+t)$
Now put $(1+t)=0\Rightarrow t=-1\;,$ We get $\displaystyle 1=2A\Rightarrow A = \frac{1}{2}.$
Now Put $(1+t^2)=0\Rightarrow t^2=-1\;,$ We Get $1=Bt^2+(B+C)t+C$
So $\displaystyle 1=\left(-B+C\right)+(B+C)$. So Solving equation...$B+C=0$ and $-B+C=1$
So $\displaystyle B=-\frac{1}{2}$ and $\displaystyle C=\frac{1}{2}$
So $\displaystyle I = 2\int\frac{1}{(1+t)\cdot (1+t^2)}dt = \int\frac{1}{1+t}dt+\int\frac{-t+1}{1+t^2}dt$
So $\displaystyle I = \frac{1}{1+t}dt-\frac{1}{2}\int\frac{2t}{1+t^2}dt+\int \frac{1}{1+t^2}dt$
So $\displaystyle I = \ln \left|1+t\right|-\frac{1}{2}\ln \left|1+t^2\right|+\tan^{-1}(t)+\mathcal{C}$
So $\displaystyle I = \ln \left|1+\tan \frac{x}{2}\right|-\frac{1}{2}\ln \left|1+\tan^2 \frac{x}{2}\right|+\frac{x}{2}+\mathcal{C}$
Can we solve it without using partial fraction? If yes then please explain to me.
Thanks

Set $t=\dfrac{x}{2}$, then multiply the integrand by $\cos t$, we get
\begin{equation}
\frac{2\cos t}{\cos t+\sin t}
\end{equation}
then let
\begin{equation}
I=\int\frac{2\cos t}{\cos t+\sin t}dt
\end{equation}
and
\begin{equation}
J=\int\frac{2\sin t}{\cos t +\sin t}dt
\end{equation}
Find $I+J$ and $I-J$, where $I-J$ can be found by using
\begin{equation}
\int\frac{f'(x)}{f(x)}dx=\ln\left|f(x)\right|+C
\end{equation}
We have
\begin{equation}
I+J = 2t+C
\end{equation}
and
\begin{equation}
I-J = 2\ln|\cos t +\sin t|+C
\end{equation}
So
\begin{equation}
I =\int\frac{1}{\tan \frac{x}{2}+1}dx = \frac{x}{2}+\ln \left|\sin \frac{x}{2}+\cos \frac{x}{2}\right|+C
\end{equation}
