Finding the Integral \(\int \tan ^{2}x\,\sec x\,dx\).

Find \(\int \tan ^{2}x\sec x\,dx\).

Solution Here, tan \(x\) is raised to an even power and sec \(x\) to an odd power. We use the identity \(\tan ^{2}x=\sec ^{2}x-1\) to write \[ \begin{eqnarray*} \int \tan ^{2}x\sec x\,dx &=&\int (\sec ^{2}x-1)\sec x\,dx=\int ( \sec ^{3}x-\sec x)~dx\nonumber\\[4pt] &=&\int \sec ^{3}x\,dx-\int \sec x\,dx\tag{2} \end{eqnarray*} \]

Next we integrate \(\int \sec ^{3}x\,dx\) by parts. Choose \[ \begin{array}{rcl@{\qquad}c@{\qquad}rcl} u &=&\sec x &\hbox{and}& dv &=&\sec ^{2}x\,dx \\[3pt] du &=&\sec x\tan x\,dx &\hbox{}& v &=&\int \sec ^{2}x\,dx=\tan x \end{array} \]

Then \[ \begin{array}{@rcl@{\quad}l} \int \sec ^{3}x\,dx &=&\sec x\,\tan x-\int \tan ^{2}x\,\sec x\,dx & {\color{#0066A7}{\int udv = uv-\int vdu}}\\ &=&\sec x\,\tan x-\int ( \sec ^{2}x-1) \,\sec x\,dx & {\color{#0066A7}{\hbox{\(\tan ^{2}{x=}\sec ^{2}{x-1}\)}}} \\ &=&\sec x\,\tan x-\int \sec ^{3}x\,dx+\int \sec x\,dx & {\color{#0066A7}{\hbox{Write the integral as the}}} \\ &&& {\color{#0066A7}{\hbox{sum of two integrals.}}} \\ 2\int \sec ^{3}x\,dx &=&\sec x\,\tan x+\int \sec x\,dx & {\color{#0066A7}{\hbox{Add \(\int \sec ^{3}x~dx\) to both sides.}}} \\ \int \sec ^{3}x\,dx &=&\dfrac{1}{2}[ \sec x\,\tan x+\ln \vert \sec x+\tan x\vert ] & {\color{#0066A7}{\hbox{Solve for \(\int \sec ^{3}x~dx\);} }}\\ &&&{\color{#0066A7}{\hbox{\(\int \sec x~dx=\ln \left\vert \sec {x+}\tan {x}\right\vert\).}}} \end{array} \]

Now we substitute this result in (2). \[ \begin{eqnarray*} \int \tan ^{2}x\sec x\,dx &=&\int \sec ^{3}x\,dx-\int \sec x\,dx\\[4pt] &=& \dfrac{1}{2}\left[ \sec x\,\tan x+\ln \vert \sec x+\tan x\vert \right] -\ln \vert \sec x+\tan x\vert +C \nonumber \\[4pt] &=&\dfrac{1}{2}\left[ \sec x\tan x-\ln \,\vert \sec x+\tan x\vert \right] +C \end{eqnarray*} \]