Solution:
Key idea: We integrate by parts: ∫uvdx=u∫vdx−∫(dxdu∫vdx)dx. We take u=x as the first function and v=sec2x as the second, since ∫sec2xdx=tanx.
Step 1 — Find the pieces needed.
We differentiate the first function and integrate the second.
dxdu=1
∫sec2xdx=tanx
Step 2 — Apply the parts formula.
We put these into the formula.
I=xtanx−∫1⋅tanxdx
Step 3 — Finish the remaining integral.
We use ∫tanxdx=log∣secx∣.
I=xtanx−log∣secx∣+C
Therefore, ∫xsec2xdx=xtanx−log∣secx∣+C (equivalently xtanx+log∣cosx∣+C), wherever cosx=0.