TITLE: Integration substitution: How does Wolfram Alpha come up with this step?
QUESTION [7 upvotes]: I have to integrate 
$$
\int \frac{1}{(\sin  x) (\cos  x)} \, dx
$$
I looked at the Wolfram Alpha step by step solution to figure out how to do it.
First, it rewrites the integral as:
$$
\int (\csc x) (\sec x) \, dx
$$
This step I understand, but then it substitutes:
For the integrand $\csc x\cdot\sec x$, substitute $u=\tan(x)$ and $\mathrm{d}u=\sec^2(x)\mathrm{d}x$:
$$
\int \frac{1}{u} \, du
$$
My question is, how does it know to substitute $\tan x$ for $u$, and $\sec^2x$ for $\mathrm{d}x$? And how does that simplifies to $1/u~\mathrm{d}u$?

REPLY [19 votes]: Rewrite it as:
$$\frac 1{(\sin x)(\cos x)} = \frac 1 {\frac{\sin x}{\cos x}\cos^2x} = \frac 1 {\tan x \cdot \cos^2x} = \frac 1 {\tan x} \cdot \frac 1 {\cos^2x}$$
Now, since you know the derivative of the tangent, you substitute $u = \tan x$. You have that $\mathrm du = \frac 1 {\cos^2x} \mathrm dx$. I'm confident that you can continue from here.

REPLY [13 votes]: Since
$$
\frac{1}{\cos x \sin x} =\frac{\cos x }{\sin x}+\frac{ \sin x}{\cos x}
$$
you easily deduce that
$$
\int\frac{1}{\cos x \sin x} {\rm d} x=\ln |\sin x|-\ln |\cos x|+C=\ln |\tan x|+C
$$
for any constant $C$.

REPLY [2 votes]: Is the standard change when the integrand is a rational function of $\sin^2$, $\cos^2$ and $\sin\cos$. Check yourself that $\sin^2$, $\cos^2$ and $\sin\cos$ can be written in function of $\tan$ without square roots starting from $1+\tan^2=\sec^2$.