Integral $\int \frac{dx}{\tan x + \cot x + \csc x + \sec x}$ $$\int \frac{dx}{\tan x + \cot x + \csc x + \sec x}$$
$$\tan x + \cot x + \csc x + \sec x=\frac{\sin x + 1}{\cos x} +\frac{\cos x + 1}{\sin x} $$
$$= \frac{\sin x +\cos x +1}{\sin x \cos x}$$
$$t= \tan {\frac{x}{2}}$$
On solving ,
$$\frac{1}{\tan x + \cot x + \csc x + \sec x}=\frac{t(1- t)}{1+ t^2}$$
$$\implies \int \frac{\tan {\frac{x}{2}}(1-\tan {\frac{x}{2}})}{1+\tan^2 {\frac{x}{2}}}{dx}$$
I think, I have made the things more difficult. How can I proceed further? Is there any better substitution for it?
 A: $\displaystyle\int \frac{dx}{\tan x + \cot x + \csc x + \sec x}=$
$\displaystyle\int\frac{\sin x\cos x}{1+\sin x+\cos x}\,dx=\int\frac{\sin x\cos x}{1+\sin x+\cos x}\cdot\frac{1-(\sin x+\cos x)}{1-(\sin x+\cos x)}\,dx$
$=\displaystyle\int\frac{\sin x\cos x(1-(\sin x+\cos x))}{1-(\sin x+\cos x)^2}\,dx=\int\frac{\sin x\cos x-\sin^2 x\cos x-\cos^2x\sin x}{-2\sin x\cos x}\,dx$
$\displaystyle=-\frac{1}{2}\int(1-\sin x-\cos x)\,dx=\frac{1}{2}(-x-\cos x+\sin x)+C$
A: $$\begin{aligned}\int \frac{1}{\frac{\sin(x)}{\cos(x)}\:+\:\frac{\cos(x)}{\sin(x)}\:+\:\frac{1}{\sin(x)}\:+\:\frac{1}{\cos(x)}}dx
& = \int \:\frac{\sin \:\left(2x\right)}{2\left(\cos \:\left(x\right)+\sin \:\left(x\right)+1\right)}dx
\\& =\frac{1}{2}\cdot \int \:\frac{\sin \left(2x\right)}{\cos \left(x\right)+\sin \left(x\right)+1}dx
\\& =\frac{1}{2}\cdot \frac{1}{2}\cdot \int \:\frac{\sin \left(t\right)}{\sin \left(\frac{t}{2}\right)+\cos \left(\frac{t}{2}\right)+1}dt
\\& =\frac{1}{2}\cdot \frac{1}{2}\cdot \int \:\sin \left(\frac{t}{2}\right)+\cos \left(\frac{t}{2}\right)-1dt
\\& =\color{red}{\frac{1}{4}\left(-2x+2\sin \left(x\right)-2\cos \left(x\right)\right)+C}
\end{aligned}$$
Applyied substitution: $$\color{blue}{t=2x,\quad \:dt=2dx}$$
A: A trigonometric formula can be used：
\begin{align}
&(\sin x+\cos x+1)(\sin x+\cos x-1)=\sin 2x\\
I&=\int\frac{\sin x\cos x}{\sin x+\cos x+1}dx=\int\frac{1}{2}(\sin x+\cos x-1)dx=\frac{1}{2}(-\cos x+\sin x-x)+C\\
\end{align}
A: $$\begin{aligned}\int \frac{d x}{\tan x+\cot x+\csc x+\sec x}&=\int \frac{\cos x \sin x}{1+\cos x+\sin x} d x \\&= -\frac{1}{2} \int \frac{1-(\cos x+\sin x)^2}{1+\cos x+\sin x} d x \\& = -\frac{1}{2} \int(1-\cos x-\sin x) d x\\&= \frac{1}{2}(-x+\sin x-\cos x)+C\end{aligned}  $$
