Let:
#I_n = int sec^nx dx#
write the integrand as:
#sec^nx = sec^(n-2) sec^2x = sec^(n-2)x d/dx tanx#
and integrate by parts:
#int sec^nx dx = int sec^(n-2)x d(tanx)#
#int sec^nx dx = sec^(n-2)xtanx - int tanx d(sec^(n-2)x)#
#int sec^nx dx = sec^(n-2)xtanx - (n-2) int tanx sec^(n-3)x secx tanx dx#
#int sec^nx dx = sec^(n-2)xtanx - (n-2) int tan^2x sec^(n-2)x dx#
Use now the trigonometric identity:
#tan^2x = sin^2x/cos^2x = (1-cos^2x)/cos^2x = 1/cos^2x-1 = sec^2x -1#
and get:
#int sec^nx dx = sec^(n-2)xtanx - (n-2) int (sec^2x-1) sec^(n-2)x dx#
and using the linearity of the integral:
#int sec^nx dx = sec^(n-2)xtanx - (n-2) int sec^nxdx + (n-2)int sec^(n-2)x dx#
Now #I_n# appears on both sides and we can solve for it:
#I_n = sec^(n-2)xtanx - (n-2) I_n + (n-2)I_(n-2)#
#I_n = (sec^(n-2)xtanx)/(n-1) + (n-2)/(n-1)I_(n-2)#
In particular for #n=4#:
#int sec^4x dx= (sec^2xtanx)/3 + 2/3int sec^2x dx#
#int sec^4x dx= (sec^2xtanx)/3 + 2/3 tanx +C#
#int sec^4x dx= (tanx(sec^2x+2))/3 +C#
#int sec^4x dx= (tanx(1+tan^2x+2))/3 +C#
#int sec^4x dx= (3tanx+tan^3x)/3 +C#