Solution:
Concept: Half-angle formulas 1+cosx=2cos22x and sinx=2sin2xcos2x split the integrand into two pieces. Integrating one piece by parts produces an integral that cancels the other piece.
Step 1 — Note where the integrand is defined.
We need 1+cosx=0, so x=(2n+1)π; then cos2x=0.
Step 2 — Split the integrand with half-angles.
We replace the denominator and sinx by their half-angle forms and divide each term.
1+cosxx+sinx=2cos22xx+2cos22x2sin2xcos2x
1+cosxx+sinx=2xsec22x+tan2x
So the integral is
I=∫2xsec22xdx+∫tan2xdx
Step 3 — Integrate the first piece by parts.
We take x as the first function and 21sec22x as the second; its integral is tan2x (the chain-rule factor 21 is already there).
∫2xsec22xdx=xtan2x−∫1⋅tan2xdx
Step 4 — Combine the pieces.
We put Step 3 into Step 2. The two integrals ∫tan2xdx have opposite signs and cancel.
I=xtan2x−∫tan2xdx+∫tan2xdx
I=xtan2x+C
Step 5 — Check by differentiating.
The derivative of xtan2x is tan2x+2xsec22x, which is the integrand written as in Step 2.
Therefore, ∫1+cosxx+sinxdx=xtan2x+C, for x=(2n+1)π.