Solution:
Key idea: The numerator sec2xdx is the differential of tanx, so the substitution tanx=t gives the standard form, ∫t2+a2dt=logt+t2+a2+C.
Step 1 — Choose the substitution.
We put tanx=t because its derivative sec2x already stands in the numerator.
tanx=t
sec2xdx=dt
Step 2 — Rewrite the integral in t.
Since tan2x=t2 and 4=22, the root becomes t2+22.
I=∫t2+22dt
Step 3 — Apply the standard form.
We use ∫t2+a2dt=logt+t2+a2, with a=2.
I=logt+t2+4+C
Step 4 — Return to x.
We replace t by tanx.
I=logtanx+tan2x+4+C
Therefore, ∫tan2x+4sec2xdx=logtanx+tan2x+4+C, wherever cosx=0.