Trigonometric Integral : $\int\frac{1}{\sin x+ 3\cos x}dx$ I would appreciate if somebody could help me with the following problem
Q: How to integrate this integral
$$\int\frac{1}{\sin x+ 3\cos x}dx$$

\begin{align*}
\int \frac 1 {\sin x +3\cos x}\ dx &= \int \frac 1 {2\sin \frac x 2\cos \frac x 2 +3\cos^2 \frac x 2 - 3 \sin^2 \frac x 2}\ dx \\
&= \int \frac 1 {\cos^2 \frac x 2} \cdot \frac 1 {3 + 2\tan \frac x 2 - 3 \tan^2 \frac x 2}\ dx
\end{align*}
Switching $y=\tan \frac x 2 \implies\frac {dy}{dx} = \frac 1 2 \frac 1 {\cos^2 \frac x 2}$
\begin{align*}
\int \frac 1 {\sin x +3\cos x}\ dx 
&= \int \frac 1 {3 + 2y - 3 y^2}2\ dy \\
&= 6\int \frac 1 {(3y-1-\sqrt{10})(3y-1+\sqrt{10})} \ dy \\
&= \frac 3 {\sqrt{10}}\int \frac 1 {3y-1-\sqrt{10}} - \frac 1 {3y-1+\sqrt{10}} \ dy \\
\end{align*}
I'll leave the rest.
