# How to integrate $\int \sec ^m(x) \tan ^n(x) \, dx$

$$\sec ^2(x)=\tan ^2(x)+1$$ $$\csc ^2(x)=\cot ^2(x)+1$$

We can evaluate integrals of the form:

$$\int \sec ^m(x) \tan ^n(x) \, dx$$

$$\int \csc ^m(x) \cot ^n(x) \, dx$$

with substitution unless $m$ is odd and $n$ is even. What I am interested to know is why am I not able to solve this with substitution if $m$ is odd and $n$ is even. I am aware that I can solve it by integration by parts. But I do not see the underlying reason for why it is not possible when using substitution?

Because when $m$ is even"regardless of $n$", we take the benefit of our knowledge that the $\sec^2(x)$ the anti derivative of $\tan(x)$ so we isolate $\sec^2(x)$ and replace the left with $1+\tan^2(x)$ ....... and when $m$ and $n$ are odds we take the benefit of our knowledge that $\sec(x) \tan(x)$ the anti derivative of $\sec(x)$ so we isolate $\sec(x)\tan(x)$ and replace the $\tan^2(x)=\sec^2(x)-1$ ......... now when $m$ is odd and $n$ is even what is the identity or relation that we is able to be used isolating $\sec^2(x)$ has no meaning if we can't replace the rest of the expressions to tan and isolating $\sec(x)\tan(x)$ has no meaning if we can't replace the rest of the expressions to $\sec(x)$ so what is done as you declared you already know we replace $\tan^2(x)=\sec^2(x)-1$ and continue by parts with the $\sec(x)$ ......... I hope I made it clear, Please feed me back if anything doesn't make sense
What if $m$ is odd, $n$ is even. For example, $m=1, n=0$.
$$\int \sec x\;dx$$ Proceed as the method says. Keep $\sec^2$ and use a pythagorean identity to convert all the rest to $\tan$ ... even if you don't see two secants, you can still do it: $$\int \sec x\;dx = \int \frac{\sec^2 x}{\sec x}\;dx = \int\frac{\sec^2 x}{\sqrt{1+\tan^2 x}} \;dx$$ then substitute $u = \tan x$ to get $$\int \frac{du}{\sqrt{1+u^2}}$$ Then do this one "somehow" and substitute back $$\int \frac{du}{\sqrt{1+u^2}} = \log\big(u+\sqrt{1+u^2}\;\big) + C =\log\big(\tan x + \sqrt{\sec^2 x}\;\big)+ C = \log(\tan x \pm \sec x) + C$$
The difference in these cases ($n$ even and $m$ odd) is that you do not end up with a rational function of $u$ to integrate. You have a square root.