# Trigonometry substitution issue with sign

When solving an integral such as $$\displaystyle\int\frac{dx}{\sqrt{x^2+4}}$$, you eventually end up with

$$\ln\lvert\sec\theta+\tan\theta\rvert+C.$$

The next step is to rewrite this in terms of $$x$$. My book does the following: $$x=2\tan\theta$$, so by drawing a triangle, it can be seen that $$x$$ is the opposite side, $$2$$ the adjacent one, and finally, $$\sqrt{2^2+x^2}$$ the hypotenuse. Therefore, $$\sec\theta=\frac{\sqrt{2^2+x^2}}2.$$ The problem that I see however is that $$\sqrt{2^2+x^2}$$ is the magnitude of the hypotenuse, so this has lost a possible negative sign since it is not necessarily true that

$$\sec\theta = \frac{|r|}{2}.$$

How can this be omitted?

When you make the substitution $$x=2\tan \theta$$, you have to be careful to specify the domain of $$\theta$$: the substitution is only valid if $$\theta$$ has a small enough domain for $$\tan \theta$$ to be continuous. The simplest possible choice of domain is probably $$-\frac{\pi}{2} < \theta < \frac{\pi}{2}$$. Note that the range of $$2\tan \theta$$ on this domain is the entire real line, so taking $$\theta$$ in this domain doesn't lose any generality.

But when $$-\frac{\pi}{2} < \theta < \frac{\pi}{2}$$, we always have $$\sec \theta > 0$$. So in fact, if you make this choice of domain, it is always true that $$2 \sec \theta=\sqrt{x^2+4}$$, without any sign issues.

It's instructive to think about what happens if you choose a different domain for $$\theta$$. If $$\sec \theta > 0$$ on that domain, nothing will change. If $$\sec \theta < 0$$ on that domain, then

$$\int \frac{dx}{\sqrt{x^2+4}}=\int \frac{\sec^2 \theta \,d\theta}{-\sec \theta}=-\int \sec \theta \,d\theta$$

because $$\sqrt{x^2+4}$$ is still positive. So the integral in terms of $$\theta$$ evaluates to $$-\ln|\sec \theta +\tan \theta|+C$$. Then, when we rewrite in terms of $$x$$, we again have $$\sec \theta=-\sqrt{x^2+4}$$, so the integral in terms of $$x$$ is

$$-\ln\left|-\sqrt{x^2+4}+x\right|+C=-\ln\left(\sqrt{x^2+4}-x\right) +C\, ,$$

because $$\sqrt{x^2+4} > x$$ for all $$x$$.

But then

\begin{align*} -\ln\left(\sqrt{x^2+4}-x\right)&=\ln\left(\frac{1}{\sqrt{x^2+4}-x}\right)\\ &=\ln\left(\frac{\sqrt{x^2+4}+x}{(\sqrt{x^2+4})^2-x^2}\right)&\text{(multiplying by the conjugate)}\\ &=\ln\frac{\sqrt{x^2+4}+x}{4}\\ &=\ln(\sqrt{x^2+4}+x)-\ln 4 \, . \end{align*}

So we get the nearly same result whatever domain we choose, but the constant term may be different.

• That makes sense, thanks. Is my answer that I put a reason for your excersise regarding “why this will not change the eventual value of the integral.” Thanks – TheImproperIntegral May 3 at 22:37
• That's part of it. There are two different places the minus sign shows up, and in the end they almost cancel each other out (that is, they cancel out up to an additive constant which gets absorbed into the constant of integration). – Micah May 4 at 3:50

Let's work through it from the beginning $$x=2\tan\theta, dx=2\sec^2\theta d\theta.\\ \int \frac{dx}{\sqrt{x^2+4}}=\int\frac{2\sec^2\theta d\theta}{\sqrt{4\tan^2\theta+4}}=\int\frac{2\sec^2\theta d\theta}{|2\sec \theta|}=\int|\sec\theta|d\theta=\int\sec\theta d\theta\\ =\ln(\tan\theta+\sec\theta)+C.$$

Where the modulus sign can be removed because we can assume $$\theta\in(-\frac{\pi}{2},\frac{\pi}{2})$$ to get all the values of $$x$$.

Again, when using $$2\sec\theta=\pm\sqrt{x^2+4}$$, we know that $$\theta\in(-\frac{\pi}{2},\frac{\pi}{2})$$, so the minus sign can be ignored.

If you try to use other ranges of $$\theta$$, the negative sign(if any) in the above steps should cancel out, and you can get the same result.

Is this perhaps a possible solution?

$$\int{\frac{dx}{+\sqrt{x^2+2^2}}}=\int{\frac{dx}{+2\sqrt{sec^2(\theta)}}}=\int{\frac{2sec^2(\theta)}{2\mid sec(\theta)\mid}}d\theta=\int{\mid{sec(\theta)}}\mid d\theta >0$$

• My mistake... there isn’t one:) – TheImproperIntegral May 4 at 19:05