Solution:
Key idea: Half-angle forms turn the fraction into standard integrands: 1+cosx=2cos22x and sinx=2sin2xcos2x.
Step 1 — Split the fraction into two parts.
We divide each term of the numerator separately by the denominator.
1+cosx1+sinx=1+cosx1+1+cosxsinx
Step 2 — Use the half-angle forms.
We replace 1+cosx by 2cos22x and sinx by 2sin2xcos2x.
1+cosx1+sinx=2cos22x1+2cos22x2sin2xcos2x
1+cosx1+sinx=21sec22x+tan2x
Step 3 — Integrate the first term.
Since dxdtan2x=21sec22x, the first term integrates directly.
∫21sec22xdx=tan2x
Step 4 — Integrate the second term.
We use ∫tankxdx=−k1log∣coskx∣, with k=21.
∫tan2xdx=−2logcos2x
Step 5 — Add the two parts.
We add the results of Steps 3 and 4 and include the constant of integration.
I=tan2x−2logcos2x+C
Therefore, ∫1+cosx1+sinxdx=tan2x−2logcos2x+C (equivalently tan2x+2logsec2x+C), wherever cos2x=0.