<s>[INST] Integrating $\sec^2 x$ from first principles Is it possible to solve $\int \sec^2 x ~dx$ without knowing that $\frac{d}{dx}\tan x = \sec^2 x$?
 [/INST] Yes, this can be done, but the method is far longer than if you know the derivative of $\tan x$ already.  The point is to convert this trigonometric integral into the integral of a rational function, integrate that with partial fractions, and then convert back. We use the substitution $u = \tan(x/2)$, for which 
$$
\sin x = \frac{2u}{1+u^2}, \ \ \ \cos x = \frac{1-u^2}{1+u^2}, \ \ \ dx = \frac{2\,du}{1+u^2}.
$$
(This is called the $\tan(x/2)$-substitution, and is discovered naturally by comparing the trigonometric parametrization of the unit circle and a rational parametrization of the unit circle. See http://en.wikipedia.org/wiki/Tangent_half-angle_substitution.) 
[EDIT: Let me show how to derive those transformation formulas above, especially the one for $dx$ since there is a comment on my answer that it depends on knowing the derivative of $\tan x$ is $\sec^2 x$ already, but that's not really the case. We do need to know that $1 + \tan^2 t = \sec^2 t = 1/\cos^2 t$. Then $\cos^2(x/2) = 1/(1+\tan^2(x/2)) = 1/(1+u^2)$, so from the double-angle formulas for sine and cosine we get
$$
\cos x = 2\cos^2(x/2) - 1 = 2\sec^2(x/2) - 1 = \frac{2}{1+u^2} - 1 = \frac{1-u^2}{1+u^2}
$$
and
$$
\sin x = 2\sin(x/2)\cos(x/2) = 2\tan(x/2)\cos^2(x/2) = \frac{2u}{1+u^2}.
$$
Then differentiate both sides of the equation for $\sin x$ using the quotient rule on the right:
$$
\cos x\,dx = \frac{2(1+u^2)-(2u)(2u)}{(1+u^2)^2}\,du = \frac{2(1-u^2)}{(1+u^2)^2}\,du \Rightarrow dx = \frac{2\,du}{1+u^2}.
$$
]
From the formula for $\cos x$ in terms of $u$ we have $\sec^2 x = 1/\cos^2 x = (1+u^2)^2/(1-u^2)^2$, so 
$$
\int \sec^2 x \,dx = \int \frac{(1+u^2)^2}{(1-u^2)^2}\frac{2}{1+u^2}\,du = \int \frac{2(1+u^2)}{(1-u^2)^2}\,du.
$$
The partial fraction decomposition of that last integrand is 
$$
\frac{2(1+u^2)}{(1-u^2)^2} = \frac{2(1+u^2)}{(1-u)^2(1+u)^2} = \frac{1}{(1-u)^2} + \frac{1}{(1+u)^2}, 
$$
so
\begin{eqnarray*}
\int \sec^2 x\,dx & = & \int\left(\frac{1}{(1-u)^2} + \frac{1}{(1+u)^2}\right)\,du \\ 
& = & \frac{1}{1-u} - \frac{1}{1+u} + C \\
& = & \frac{2u}{1-u^2} + C \\
& = & \frac{2\tan(x/2)}{1 - \tan^2(x/2)} + C.
\end{eqnarray*}
Recall now the addition formula for the tangent function: 
$$\tan(a+b) = \frac{\tan a + \tan b}{1-(\tan a)(\tan b)}.$$ Thus the double-angle formula is $\tan(2a) = 2(\tan a)/(1 - \tan^2 a)$. Therefore, using $a = x/2$, we get
$$
\int \sec^2 x\,dx = \tan\left(2\frac{x}{2}\right) + C = \tan x + C.
$$
</s>