Integrating $\tan^2{x}\sec{x}$

I'm revising for an exam and came across this question:
$I = \int{\tan^2{x}\sec{x}} dx$, and I got to a point where I just ended up with the original question:

$$I = \int{\sec^3{x}-\sec x}dx$$

$$I = \int{\sec x \sec^2x}dx - \int{\sec x}dx$$

$$I = \int{u\frac{dv}{dx}}dx - \int{\sec x}dx$$

let $u = \sec x$, $\frac{du}{dx} = \sec x\tan x$

and $\frac{dv}{dx} = \sec^2x$, $v = \tan x$

$$I = uv - \int{v\frac{du}{dx}}dx - \int{\sec x}dx$$

$$I = \sec x\tan x - \int{\tan x\sec x\tan x}dx - \ln{|\sec x + \tan x|}$$

$$I = \sec x\tan x - \int{\tan^2x\sec x}dx - \ln{|\sec x + \tan x|}$$

$$I = \sec x\tan x - I + k - \ln{|\sec x + \tan x|}$$

$$I + I = 2I = \sec x\tan x - \ln{|\sec x + \tan x|} + k$$

$$I = \frac{\sec x\tan x - \ln{|\sec x + \tan x|} + k}{2}$$

$$I = \frac{\sec x\tan x - \ln{|\sec x + \tan x|}}{2} + c$$

Is it ok to do this? I tried doing it on wolframalpha but it used somtehing called the reduction formula which I don't know,and I tried it on my calculator, which can only do definite integration, with the interval $[1,0.1]$ and I got the same answer with my result, but this doesn't proove it is correct.

(Also I didn't really know when to put in the constant ($k$)?)

You can always decide whether an indefinite integral is correct by differentiating the answer to see whether you get back the original function. So, differentiate your answer: do you get $\tan^2x\sec x$? If yes, then what you did was (almost certainly) OK; if not, then not.
• If you know a) how to differentiate $\log x$, b) how to differentiate $\sec x$, c) how to differentiate $\tan x$, and d) the chain rule, then you can differentiate $\log(\sec x+\tan x)$. So which one(s) of a), b), c), d) would be problematic for you? – Gerry Myerson Jun 19 '13 at 9:07