Solution:
Key idea: Half-angle forms split the integrand: 1−cosx=2sin22x and sinx=2sin2xcos2x. One part is then integrated by parts, ∫uvdx=u∫vdx−∫(dxdu∫vdx)dx, and the leftover integral cancels the other part.
Step 1 — Split the integrand.
We divide each term of the numerator by 2sin22x.
1−cosxx−sinx=2sin22xx−2sin22x2sin2xcos2x
1−cosxx−sinx=2xcosec22x−cot2x
Step 2 — Integrate the first piece by parts.
We take u=x and v=21cosec22x; since dxdcot2x=−21cosec22x, we have ∫vdx=−cot2x.
∫2xcosec22xdx=x(−cot2x)−∫1⋅(−cot2x)dx
∫2xcosec22xdx=−xcot2x+∫cot2xdx
Step 3 — Combine the two pieces.
We subtract ∫cot2xdx (the second piece); the two equal integrals cancel, so no further integration is needed.
I=−xcot2x+∫cot2xdx−∫cot2xdx
I=−xcot2x+C
Therefore, ∫1−cosxx−sinxdx=−xcot2x+C, wherever cosx=1.