Solution:
Key idea: Write everything in sin x \sin x sin x and cos x \cos x cos x , split off a known integral (∫ cosec x d x = log ∣ cosec x − cot x ∣ + C \displaystyle\int \operatorname{cosec} x\,dx = \log|\operatorname{cosec} x-\cot x| + C ∫ cosec x d x = log ∣ cosec x − cot x ∣ + C ), then put t = cos x t = \cos x t = cos x and use partial fractions on the rest.
Step 1 — Rewrite the denominator.
We write tan x = sin x cos x \tan x = \dfrac{\sin x}{\cos x} tan x = cos x sin x and take sin x \sin x sin x out as a common factor.
sin x + tan x = sin x + sin x cos x = sin x ( 1 + cos x ) cos x \begin{aligned}
\sin x+\tan x &= \sin x+\dfrac{\sin x}{\cos x} \\
&= \dfrac{\sin x(1+\cos x)}{\cos x}
\end{aligned} sin x + tan x = sin x + cos x sin x = cos x sin x ( 1 + cos x )
I = ∫ cos x sin x ( 1 + cos x ) d x I = \int \dfrac{\cos x}{\sin x(1+\cos x)}\,dx I = ∫ sin x ( 1 + cos x ) cos x d x
Step 2 — Split the numerator.
We write cos x = ( 1 + cos x ) − 1 \cos x = (1+\cos x)-1 cos x = ( 1 + cos x ) − 1 , so one part cancels with the factor 1 + cos x 1+\cos x 1 + cos x .
I = ∫ ( 1 + cos x ) − 1 sin x ( 1 + cos x ) d x = ∫ cosec x d x − ∫ d x sin x ( 1 + cos x ) \begin{aligned}
I &= \int \dfrac{(1+\cos x)-1}{\sin x(1+\cos x)}\,dx \\
&= \int \operatorname{cosec} x\,dx-\int \dfrac{dx}{\sin x(1+\cos x)}
\end{aligned} I = ∫ sin x ( 1 + cos x ) ( 1 + cos x ) − 1 d x = ∫ cosec x d x − ∫ sin x ( 1 + cos x ) d x
Step 3 — Prepare the second integral for t = cos x t = \cos x t = cos x .
We multiply the top and bottom by sin x \sin x sin x and use sin 2 x = ( 1 − cos x ) ( 1 + cos x ) \sin^2 x = (1-\cos x)(1+\cos x) sin 2 x = ( 1 − cos x ) ( 1 + cos x ) .
∫ d x sin x ( 1 + cos x ) = ∫ sin x d x sin 2 x ( 1 + cos x ) = ∫ sin x d x ( 1 − cos x ) ( 1 + cos x ) 2 \begin{aligned}
\int \dfrac{dx}{\sin x(1+\cos x)} &= \int \dfrac{\sin x\,dx}{\sin^2 x(1+\cos x)} \\
&= \int \dfrac{\sin x\,dx}{(1-\cos x)(1+\cos x)^2}
\end{aligned} ∫ sin x ( 1 + cos x ) d x = ∫ sin 2 x ( 1 + cos x ) sin x d x = ∫ ( 1 − cos x ) ( 1 + cos x ) 2 sin x d x
Step 4 — Substitute t = cos x t = \cos x t = cos x .
We put cos x = t \cos x = t cos x = t , so sin x d x = − d t \sin x\,dx = -dt sin x d x = − d t . The minus sign turns the subtraction in Step 2 into an addition.
I = log ∣ cosec x − cot x ∣ + ∫ d t ( 1 − t ) ( 1 + t ) 2 I = \log|\operatorname{cosec} x-\cot x|+\int \dfrac{dt}{(1-t)(1+t)^2} I = log ∣ cosec x − cot x ∣ + ∫ ( 1 − t ) ( 1 + t ) 2 d t
Step 5 — Find the partial fractions.
We write 1 ( 1 − t ) ( 1 + t ) 2 = A 1 − t + B 1 + t + C ( 1 + t ) 2 \dfrac{1}{(1-t)(1+t)^2} = \dfrac{A}{1-t}+\dfrac{B}{1+t}+\dfrac{C}{(1+t)^2} ( 1 − t ) ( 1 + t ) 2 1 = 1 − t A + 1 + t B + ( 1 + t ) 2 C , so 1 = A ( 1 + t ) 2 + B ( 1 − t ) ( 1 + t ) + C ( 1 − t ) 1 = A(1+t)^2+B(1-t)(1+t)+C(1-t) 1 = A ( 1 + t ) 2 + B ( 1 − t ) ( 1 + t ) + C ( 1 − t ) .
Then we put t = 1 t = 1 t = 1 , t = − 1 t = -1 t = − 1 and compare the t 2 t^2 t 2 terms.
t = 1 : 1 = 4 A A = 1 4 t = − 1 : 1 = 2 C C = 1 2 t 2 terms : A − B = 0 B = 1 4 \begin{aligned}
t = 1:\quad 1 &= 4A \\
A &= \dfrac{1}{4} \\
t = -1:\quad 1 &= 2C \\
C &= \dfrac{1}{2} \\
t^2\text{ terms}:\quad A-B &= 0 \\
B &= \dfrac{1}{4}
\end{aligned} t = 1 : 1 A t = − 1 : 1 C t 2 terms : A − B B = 4 A = 4 1 = 2 C = 2 1 = 0 = 4 1
Step 6 — Integrate the partial fractions.
We use ∫ d t 1 − t = − log ∣ 1 − t ∣ \displaystyle\int \dfrac{dt}{1-t} = -\log|1-t| ∫ 1 − t d t = − log ∣1 − t ∣ and ∫ d t ( 1 + t ) 2 = − 1 1 + t \displaystyle\int \dfrac{dt}{(1+t)^2} = -\dfrac{1}{1+t} ∫ ( 1 + t ) 2 d t = − 1 + t 1 .
∫ d t ( 1 − t ) ( 1 + t ) 2 = − 1 4 log ∣ 1 − t ∣ + 1 4 log ∣ 1 + t ∣ − 1 2 ( 1 + t ) = 1 4 log ∣ 1 + t 1 − t ∣ − 1 2 ( 1 + t ) \begin{aligned}
\int \dfrac{dt}{(1-t)(1+t)^2} &= -\dfrac{1}{4}\log|1-t|+\dfrac{1}{4}\log|1+t|-\dfrac{1}{2(1+t)} \\
&= \dfrac{1}{4}\log\left|\dfrac{1+t}{1-t}\right|-\dfrac{1}{2(1+t)}
\end{aligned} ∫ ( 1 − t ) ( 1 + t ) 2 d t = − 4 1 log ∣1 − t ∣ + 4 1 log ∣1 + t ∣ − 2 ( 1 + t ) 1 = 4 1 log 1 − t 1 + t − 2 ( 1 + t ) 1
Step 7 — Put back t = cos x t = \cos x t = cos x .
We replace t t t by cos x \cos x cos x and add the constant of integration.
I = log ∣ cosec x − cot x ∣ + 1 4 log ∣ 1 + cos x 1 − cos x ∣ − 1 2 ( 1 + cos x ) + C I = \log|\operatorname{cosec} x-\cot x|+\dfrac{1}{4}\log\left|\dfrac{1+\cos x}{1-\cos x}\right|-\dfrac{1}{2(1+\cos x)} + C I = log ∣ cosec x − cot x ∣ + 4 1 log 1 − cos x 1 + cos x − 2 ( 1 + cos x ) 1 + C
Therefore, ∫ d x sin x + tan x = log ∣ cosec x − cot x ∣ + 1 4 log ∣ 1 + cos x 1 − cos x ∣ − 1 2 ( 1 + cos x ) + C \displaystyle\int \dfrac{dx}{\sin x+\tan x} = \log|\operatorname{cosec} x-\cot x|+\dfrac{1}{4}\log\left|\dfrac{1+\cos x}{1-\cos x}\right|-\dfrac{1}{2(1+\cos x)} + C ∫ sin x + tan x d x = log ∣ cosec x − cot x ∣ + 4 1 log 1 − cos x 1 + cos x − 2 ( 1 + cos x ) 1 + C , where sin x ≠ 0 \sin x \ne 0 sin x = 0 and cos x ≠ 0 \cos x \ne 0 cos x = 0 .