# Why do I need to switch the sign of the natural log in this trig-sub integration problem?

I'm attempting to integrate the following using trig substituion: $$\int \frac{\sqrt{1+x^2}}{x}dx$$ and I am getting the result: $$-\ln{\lvert \frac{ \sqrt{x^2 + 1} - 1}{x} \rvert} + \sqrt{x^2 + 1} + C$$

However, my answer guide and this yahoo answer both indicate that the $-\ln$ should now be positive, I can't seem to figure out why (although I'm sure it's painfully simple). I thought it might be related to the fact that $\ln{\frac1x} = -\ln{x}$ but I can't wrap my head around it.

I've provided my steps below:

I start with $x=\tan\theta$ and $dx=\sec^2\theta d\theta$

Which brings me to $$\int \frac{\sqrt{1+\tan^2\theta}}{\tan\theta}\sec^2\theta d\theta$$

and then: $$\int \frac{\sec^2\theta(\sec\theta)}{\tan\theta} d\theta$$

.... next I substitute $(1+\tan^2\theta)$ for $\sec^2\theta$ and multiply by the $\sec\theta$ already in the numerator, giving me: $$\int \frac{\sec\theta+\sec\theta\tan^2\theta}{\tan\theta}d\theta$$

I separate this out into two separate fractions, canceling one power of $\tan\theta$ in its respective fraction:

$$\int \frac{\sec\theta}{\tan\theta} + \sec\theta\tan\theta d\theta$$

This can be split into two integrals, and the left side can be rewritten as $\csc\theta$:

$$\int \csc\theta d\theta + \int \sec\theta\tan\theta d\theta$$

Which using known integrals can be determined to be:

$$-\ln{\lvert \csc\theta - \cot\theta \rvert} + \sec\theta + C$$

Creating a triangle to determine $\csc\theta$, $\cot\theta$, and $\sec\theta$ in terms of x yields me:

$$-\ln{\lvert \frac{ \sqrt{x^2 + 1} - 1}{x} \rvert} + \sqrt{x^2 + 1} + C$$

Edit: So it turns out I had the formula for $\int\csc\theta d\theta$ wrong. As user84413 pointed out in the comments, the formula is:

$$\int\csc\theta d\theta=\ln|\csc\theta-\cot\theta|+C=-\ln|\csc\theta+\cot\theta|+C$$

Using this corrected formula for my second to last step, I get the correct answer.

• $\int\csc\theta d\theta=\ln|\csc\theta-\cot\theta|+C=-\ln|\csc\theta+\cot\theta|+C$ – user84413 Sep 22 '15 at 16:52
• oh lord... I copied down the integral of csc with the wrong sign inside the absolute value.... – JonathonG Sep 22 '15 at 17:00
• @user84413 Would you like to make an answer highlighting that I used the wrong formula for $\int\csc\theta d\theta$ ? That way it will be easier for someone finding this page to see what I did wrong. – JonathonG Sep 22 '15 at 17:08
• Thanks - I think your edit to the problem was a good way to handle it. – user84413 Sep 22 '15 at 18:08

Your Second last line is $\displaystyle - \ln\left|\csc \theta-\cot \theta\right|+\sec\theta +\mathcal{C}$

Now Using $\displaystyle \csc^2 \theta-\cot^2 \theta = 1\Rightarrow (\csc \theta -\cot \theta) = \frac{1}{\csc \theta +\cot \theta}$

So we get $\displaystyle = -\ln\left|\frac{1}{\csc \theta+\cot \theta}\right|+\sec \theta+\mathcal{C}$

So we get $\displaystyle = \ln\left|\csc \theta+\cot \theta\right|+\sec \theta+\mathcal{C}$

So $\displaystyle =\ln\left|\frac{\sqrt{1+x^2}+1}{x}\right|+\sqrt{1+x^2}+\mathcal{C}$

$\bf{Solution \; without \; Trig. \; Substution.}$

Let $$\displaystyle I = \int\frac{\sqrt{1+x^2}}{x}dx = \int\frac{1+x^2}{x\sqrt{1+x^2}}dx = \int\frac{1}{x\sqrt{1+x^2}}dx+\int\frac{x}{\sqrt{1+x^2}}dx$$

Now Let $$\displaystyle J = \int\frac{1}{x\sqrt{x^2+1}}dx\;,$$ Put $\displaystyle x = \frac{1}{t}\;,$ Then $\displaystyle dx = -\frac{1}{t^2}dt$

So $$\displaystyle J = -\int\frac{1}{\sqrt{t^2+1}}dt = -\ln\left|t+\sqrt{t^2+1}\right|+C_{1} = -\ln\left|\frac{\sqrt{x^2+1}+1}{x}\right|+\mathcal{C_{1}}$$

And Let $$\displaystyle K=\int\frac{x}{\sqrt{x^2+1}}dx\;,$$ Now put $\displaystyle x^2+1=u^2\;,$ Then $xdx = udu$

So we get $$\displaystyle K = \int\frac{u}{u}du = u+\mathcal{C_{2}} = \sqrt{x^2+1}+\mathcal{C_{2}}$$

So we get $$\displaystyle I = \int\frac{\sqrt{1+x^2}}{x}dx = -\ln\left|\frac{\sqrt{x^2+1}+1}{x}\right|+\sqrt{x^2+1}+\mathcal{C}$$

• Thanks for all that work for the non trig-sub answer. I still had to do this as trig-sub because I am required to demonstrate that method. However, the first half of your answer seems to operate on the assumption that my second to last step was correct, when it in fact was not. I used the wrong formula for $\int\csc\theta d\theta$, see the comments on my question or edited question itself to see what I mean. – JonathonG Sep 22 '15 at 17:16

It is simple is not complex as you are thinking. Look this,$$\int \frac {\sqrt{1+x^2}}x dx=\int \frac {1+x^2}{x\sqrt{1+x^2}}dx=\int \frac 1{x\sqrt {1+x^2}}dx+\int \frac x{\sqrt{1+x^2}}dx$$

For the first integral, substitute $x=\tan z$ which yields $\int \csc z dz$, and for the second, substitute $1+x^2=u$.

I think you can do the remaining.

• This is true, but my problem was that I used the wrong formula for the integral of csc, so I would have gotten the answer wrong if I used your approach as well. I said $\int\csc\theta d\theta=-\ln|\csc\theta-\cot\theta|+C$ instead of $-\ln|\csc\theta+\cot\theta|+C$ – JonathonG Sep 22 '15 at 17:03