Key idea: Write everything in sinx and cosx. Multiplying the numerator and denominator by cosx produces cosxdx, so the substitution t=sinx works, and cos2x=(1−sinx)(1+sinx) gives a rational function of t that we split into partial fractions.
Step 1 — Write the integrand in sin x and cos x.
We use secx=cosx1 and cosecx=sinx1.
1+cosecxsecx=(sinx+1)/sinx1/cosx
1+cosecxsecx=cosx(1+sinx)sinx
Step 2 — Multiply by cos x and substitute.
We multiply the numerator and denominator by cosx and write cos2x=(1−sinx)(1+sinx).
I=∫(1−sinx)(1+sinx)2sinxcosxdx
Now put t=sinx, so dt=cosxdx.
I=∫(1−t)(1+t)2tdt
Step 3 — Set up the partial fractions.
The factor (1+t) is repeated, so it needs two terms.
(1−t)(1+t)2t=1−tA+1+tB+(1+t)2D
Multiplying both sides by (1−t)(1+t)2 gives the identity below.
t=A(1+t)2+B(1−t)(1+t)+D(1−t)
Step 4 — Find A, B and D.
We put t=1, which makes the B and D terms vanish.
1=4A
A=41
We put t=−1, which makes the A and B terms vanish.
−1=2D
D=−21
We compare the coefficients of t2 on both sides: the left side has none, and the right side has A−B.
A−B=0
B=41
Step 5 — Integrate each fraction.
We integrate term by term. Note that ∫1−tdt=−log∣1−t∣, because of the minus sign in front of t.