Solution:
Key idea: The derivative of cotx is −cosec2x. So the numerator is minus the derivative of the denominator, and the substitution t=1+cotx leads to −∫tdt.
Step 1 — Substitute.
We put the denominator equal to t.
t=1+cotx
Differentiating both sides gives the new differential.
dt=−cosec2xdx
So the numerator with dx is −dt.
cosec2xdx=−dt
Step 2 — Integrate in terms of t.
We replace the numerator and the denominator, and take the minus sign outside.
∫1+cotxcosec2xdx=−∫tdt
−∫tdt=−log∣t∣+C
Step 3 — Return to x.
We put back t=1+cotx.
−log∣t∣+C=−log∣1+cotx∣+C
Therefore, ∫1+cotxcosec2xdx=−log∣1+cotx∣+C (wherever cotx=−1).