# Why is this derivation of $\int \sec x$ wrong?

I attempted to find the integral of $\sec x$ via u substitution. This is what I did: $$\int \sec x dx = \int \frac{1}{\cos x} \ dx$$ Let $u = \cos x$

$$du = -\sin x \ dx$$ $$-sinx \int \frac{1}{\cos x} -\sin x \ dx$$ $$-\sin x \int \frac{1}{u} du = -\sin x \ ln|\cos x| + c$$

So why is this wrong? (I know what $\int \sec x \ dx$ is, and I've seen its derivation, but I don't understand where my attempt went wrong.)

• How do you pull $\sin x$ out of the integral? – Moya Feb 24 '15 at 2:43
• Because I needed -sinx for du, so I put -sinx outside the integral to balance the -sinx inside the integral. – Kat Feb 24 '15 at 2:45
• That's not allowed since $\sin x$ depends on $x$, which you're integrating against. Or $\sin x=\sqrt{1-\cos^2(x)}=\sqrt{1-u^2}$, so it depends on $u$ as well. – Moya Feb 24 '15 at 2:47

When you do integration, you can only pull constants out. For example, $\int 2\sin x\, dx = 2 \int \sin x\, dx$, but $\int \sin x\cos x\, dx \neq \sin x \int \cos x\, dx$.

• why can i only pull constants out? – Kat Feb 24 '15 at 2:51
• @Kat look at the exmample I gave. Since $\int \sin x\cos x\, dx = \frac{1}{4}\cos(2x) + C$ and $\sin x \int \cos x\, dx = \sin^2x + D\sin x$, where $C$ and $D$ are constants, the two integrals are not equal. – kobe Feb 24 '15 at 2:55
• oh, I see. Thanks for explaining. – Kat Feb 24 '15 at 3:01

You’ve not carried out the substitution correctly. Since $u=\cos x$ and $du=-\sin x\,dx$, we must have

$$dx=-\frac{du}{\sin x}=-\frac{du}{\sqrt{1-u^2}}\;,$$

and therefore

$$\int\sec x\,dx=\int\frac{du}{u\sqrt{1-u^2}}\;.$$

Even if you were allowed to move a function of $x$ through the integral sign, what you have would not be right: you want a factor of $-\sin x$, so the compensating factor should be $-\dfrac1{\sin x}$, not $-\sin x$. However, this is not a constant, so you cannot move it through the integral sign.