How to solve $\int \tan^2(x) \sec (x) \ dx$? How should one solve the following integral? $$\int \tan^2(x) \sec (x) \ dx$$
I can't think of any substitutions to be made involving $\tan^2(x)=\sec^2 (x)-1$ or $\sec^2(x)=\tan^2(x)+1$, which is how I've been solving most of the similar problems in my book until now. What should I do?
 A: Only by doing this in two harder ways did I catch a really nice trick for this problem in particular.
By doing $\tan^2(x)=\sec^2(x)-1$ we get
$$\int \sec(x) \tan^2(x) dx = \int \sec^3(x) dx - \int \sec(x) dx.$$
On the other hand, by integrating by parts with $dv=\sec(x) \tan(x) dx$ and $u=\tan(x)$, we get
$$\int \sec(x) \tan^2(x) dx = \sec(x) \tan(x) - \int \sec^3(x) dx.$$
Adding these equations we get:
$$2 \int \sec(x) \tan^2(x) dx = \sec(x) \tan(x) - \int \sec(x) dx.$$
So you just have to compute the last integral, which I will leave to you.
A: To build on Ian's answer, you may find it easier to integrate $2\sec^3(x)dx$ instead of just $\sec^3(x)dx$.
Hint as to why this might be easier: $\sec x\tan^2x$
A: In terms of sine and cosine you have
$$
\int \frac{\sin^2x}{\cos^3x}\,dx=
\int\frac{\sin^2x}{(1-\sin^2x)^2}\cos x\,dx
$$
With the substitution $t=\sin x$ the integral becomes (after splitting into partial fractions)
$$
\int\frac{t^2}{(1-t^2)^2}\,dt
=
\frac{1}{4}\int\left(
  \frac{1}{t-1}+\frac{1}{(t-1)^2}-\frac{1}{t+1}+\frac{1}{(t+1)^2}
\right)\,dt
$$
which is elementary.
