Solution:
Key idea: We split the fraction into two parts. The first part uses the half-angle identity 1+cosx=2cos22x, and in the second part the numerator is minus the derivative of the denominator.
Step 1 — Split the fraction.
We divide each term of the numerator by 1+cosx.
1+cosx1+sinx=1+cosx1+1+cosxsinx
Step 2 — Integrate the first part.
We use 1+cosx=2cos22x, so the reciprocal is a multiple of sec22x.
1+cosx1=21sec22x
The integral of sec2(kx) is k1tan(kx); here k=21.
∫21sec22xdx=21⋅1/2tan2x
21⋅1/2tan2x=tan2x
Step 3 — Integrate the second part by substitution.
We put the denominator equal to t.
t=1+cosx
Differentiating both sides gives the new differential.
dt=−sinxdx
So the second part becomes −∫tdt.
∫1+cosxsinxdx=−∫tdt
−∫tdt=−log∣1+cosx∣
Step 4 — Add the two parts.
We add the results of Steps 2 and 3 and one constant of integration C.
∫1+cosx1+sinxdx=tan2x−log∣1+cosx∣+C
Therefore, ∫1+cosx1+sinxdx=tan2x−log∣1+cosx∣+C (for cosx=−1).