# Integration substitution: How does Wolfram Alpha come up with this step?

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$?

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.

• This answered my question, thanks! – LoLei Dec 6 '14 at 10:44
• @LorenzLeitner: I'm glad I could be of help! – rubik Dec 6 '14 at 10:45
• Just as a side note, tan substitution is very useful for many trigonometric integrals – Guest 86 Dec 20 '14 at 19:14

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$.

• This is an even easier method, thanks! – LoLei Dec 6 '14 at 10:45
• @LorenzLeitner You are welcome! – Olivier Oloa Dec 6 '14 at 10:52

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$.