# Integral of secant - Where's the mistake?

I can't find what's wrong in my attemp on finding the integral of $f(x)=\sec(x)$

$$\int \sec(x) dx = \int \frac{dx}{\cos(x)} = \int \frac{\cos(x)dx}{\cos^2(x)}=\int\frac{\cos(x)dx}{1-\sin^2(x)}$$ $$\sin(x) = u \\\\\\\\\\\ du = \cos(x) dx$$ $$\int \frac{du}{1-u^2}=\int \frac{A}{1+u} du + \int \frac{B}{1-u} du = \int\frac{A(1-u) B(1+u)}{1-u^2}du$$ $$A=B=\frac{1}{2}$$ $$\frac{1}{2}\int \frac{1}{1+u} du + \frac{1}{2}\int \frac{1}{1-u}du= \frac{1}{2}(\ln(1+\sin(x))+\ln(1-\sin(x))$$

-
Preceed $sec$, $sin$, $cos$ and $ln$ with a \ to get $\sec,\dots ,\ln$. – Git Gud Feb 26 '13 at 23:02

The integral of $\dfrac{1}{1-u}$ is $-\ln(|1-u|)$. You left out the minus sign in front. (This comes in principle from the substitution $t=1-u$.)
Remark: Since differentiation is so easy, it is useful to scan a conjectured antiderivative for correctness. For example, that's the way I would integrate $\sin(1+3t)$. The answer is something like $\cos(1+3t)$. Differentiate. We get $-3\sin(1+3t)$, wrong. Easy fix, multiply by $-\frac{1}{3}$.
Oh, that was dumb! Thanks you very much! While we are at it, any general ideas on how to go from my result to $\ln(\sec(x)+\tan(x))$ ? – milo Feb 26 '13 at 23:15
$\ln(1+\sin(x))-\ln(1-\sin(x)=\ln(\frac{1+\sin(x)}{1-\sin(x)})=\ln(\frac{(1+\sin‌​(x))^{2}}{1-\sin^{2}(x)})=\ln(\frac{(1+\sin(x))^{2}}{\cos^{2}(x)})=2\ln(\frac{1+ \sin(x)}{\cos(x)})$ – Daniel Littlewood Feb 26 '13 at 23:24