Solution:
Concept: If f is differentiable, then ∫ex[f(x)+f′(x)]dx=exf(x)+C. To see why, differentiate exf(x) by the product rule: the result is exf(x)+exf′(x), which is exactly the integrand. So whenever the bracket is a function plus its own derivative, the answer is ex times that function.
Step 1 — Rewrite with half-angles.
The integrand needs 1−cosx=0, so x=2nπ. We use 1−cosx=2sin22x and sinx=2sin2xcos2x, and split the fraction into two parts.
1−cosx1−sinx=2sin22x1−2sin22x2sin2xcos2x
1−cosx1−sinx=21cosec22x−cot2x
Step 2 — Choose f(x).
We take f(x)=−cot2x. The derivative of cotu is −cosec2u, and the chain rule gives a factor 21.
f′(x)=cosec22x⋅21
f′(x)=21cosec22x
Step 3 — Match the pattern.
The integrand is ex[f(x)+f′(x)], so the integral is exf(x).
I=−excot2x+C
Step 4 — Check by differentiating.
The derivative of −excot2x is −excot2x+21excosec22x, which is the integrand written as in Step 1.
Therefore, ∫ex1−cosx1−sinxdx=−excot2x+C, for x=2nπ.