Why does solving this integral using trigonometric substitution lead to the wrong answer

calculusindefinite-integralsintegration

I was solving the integral $$\int \frac{\sqrt{x^2 – 16}}{x} \, dx,$$ and I admittedly attempted to solve it blindly using trigonometric substitution:

$$\begin{align}
&\int \frac{\sqrt{x^2 – 16}}{x} \, dx, \quad \text{let } x = 4\sec\theta \implies dx = 4\sec\theta\tan\theta \, d\theta \quad(\text{meaning} \ \ \theta=\sec^{-1}\frac{x}{4})\\[0.5em]
&\int \frac{\sqrt{16\sec^2\theta – 16}}{4\sec\theta} \cdot 4\sec\theta\tan\theta = \int 4\tan^2\theta \, d\theta = \int 4(\sec^2\theta – 1) \, d\theta = 4\tan\theta – 4\theta + c \\[0.5em]
&4\tan\theta – 4\theta + c \ \ \text{becomes} \ \ \sqrt{x^2-16} – 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr) + c \ \ \text{so} \ \ \fbox{$\int \frac{\sqrt{x^2 – 16}}{x} \, dx = \sqrt{x^2-16} – 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr) + c$}
\end{align}$$

So $\sqrt{x^2-16} – 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr) + c$ is the family of antiderivates of $\frac{\sqrt{x^2 – 16}}{x}$, so if $$F(x) = \sqrt{x^2-16} – 4\sec^{-1}\Bigl(\frac{x}{4}\Bigr),$$ then $$F'(x) = \frac{\sqrt{x^2 – 16}}{x}$$, right? However, as the graph below shows, that's not the case.

[![Graph][1]][1]  [1]: https://i.stack.imgur.com/RSjO6.png

For negative values, the two functions $F'$ and $f$ do not match at all. When setting
$$F(x) = \sqrt{x^2 – 16} – 4\tan^{-1}\biggl(\frac{\sqrt{x^2 – 16}}{4}\biggr),$$ then the two functions do seem to agree.

When I tried to ask an instructor, I was told that we always represent our solutions in terms of either inverse tangent or inverse sine, but not inverse secant. The reason I confidently chose to represent theta as inverse secant is that that's how we always did it, so when I compared my answers to the ones provided, I was extremely confused.

I fear that it might be an issue with the domain of the inverse secant, but I'm not exactly sure how.

Best Answer

First of all, recall that $\sqrt{y^2} = \lvert y\rvert,$ not $y$, because $\sqrt{y^2}$ is a non-negative square root even when $y$ is negative. Also note that $0 \leq \sec^{-1}\left(\dfrac x4\right) < \dfrac\pi2$ if and only if $x \geq 4,$ but $\dfrac\pi2 < \sec^{-1}\left(\dfrac x4\right) \leq \pi$ if and only if $x \leq -4.$ Then

\begin{align} \int \frac{\sqrt{16\sec^2\theta - 16}}{4\sec\theta}\, &\cdot 4\sec\theta\tan\theta \,\mathrm d\theta \\ &= \int \sqrt{16\tan^2\theta}\,\tan\theta \,\mathrm d\theta \\ &= 4 \int \lvert\tan\theta\rvert \tan\theta \,\mathrm d\theta \\ &= \begin{cases} \phantom{-}4 \displaystyle\int\tan^2\theta \,\mathrm d\theta & 0 \leq \theta < \dfrac\pi2,\\ -4 \displaystyle\int\tan^2\theta \,\mathrm d\theta &\dfrac\pi2 < \theta \leq \pi \\ \end{cases} \\ &= \begin{cases} 4 \left( \tan\theta - \theta\right) + C_1 & 0 \leq \theta < \dfrac\pi2,\\ 4 \left(\theta - \tan\theta\right) + C_2 & \dfrac\pi2 < \theta \leq \pi \\ \end{cases} \\ &= \begin{cases} 4 \left(\tan \left(\sec^{-1}\left(\dfrac x4\right)\right) - \sec^{-1}\left(\dfrac x4\right)\right) + C_1 & x \geq 4,\\ 4 \left(\sec^{-1}\left(\dfrac x4\right) - \tan \left(\sec^{-1}\left(\dfrac x4\right)\right)\right) + C_2 & x \leq -4. \\ \end{cases} \end{align}

Now when $x \geq 4,$ then $\tan \left(\sec^{-1}\left(\dfrac x4\right)\right) = \dfrac14 \sqrt{x^2 - 16},$ sure enough, but when $x \leq -4$ then $\dfrac\pi2 < \sec^{-1}\left(\dfrac x4\right) \leq \pi$ (second quadrant), hence $\tan \left(\sec^{-1}\left(\dfrac x4\right)\right)$ is negative (or zero), hence $\tan \left(\sec^{-1}\left(\dfrac x4\right)\right) = -\dfrac14 \sqrt{x^2 - 16}.$ So

$$ \int \frac{\sqrt{x^2 - 16}}{x} \, dx = \begin{cases} \sqrt{x^2 - 16} - 4\sec^{-1}\left(\dfrac x4\right) + C_1 & x \geq 4,\\ \sqrt{x^2 - 16} + 4 \sec^{-1}\left(\dfrac x4\right) + C_2 & x \leq -4. \\ \end{cases} $$

Further notice that when $x \geq 4,$ then $\sec^{-1}\left(\dfrac x4\right) = \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right),$ but when $x \leq -4,$ then $\sec^{-1}\left(\dfrac x4\right) = \pi - \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right),$ so the integral can also be written

\begin{align} \int \frac{\sqrt{x^2 - 16}}{x} \, dx &= \begin{cases} \sqrt{x^2 - 16} - 4 \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right) + C_1 & x \geq 4,\\ \sqrt{x^2 - 16} + 4\left(\pi - \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right)\right) + C_2 & x \leq -4 \\ \end{cases} \\ &= \begin{cases} \sqrt{x^2 - 16} - 4 \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right) + C_1 & x \geq 4,\\ \sqrt{x^2 - 16} - 4 \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right) + C_3 & x \leq -4. \\ \end{cases} \\ \end{align}

If we set $C_1 = C_3 = C$ then we have the solution you might get by other means, $$ \int \frac{\sqrt{x^2 - 16}}{x} \, dx = \sqrt{x^2 - 16} - 4 \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right) + C, $$ but in the context of real analysis it is more accurate to say that we can use different constants in the integral for each connected part of the integral's domain.


Some parts of the calculations that were postponed for the sake of the flow of the answer:

Why is $\sec^{-1}\left(\dfrac x4\right) = \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right)$ when $x \geq 4$?

Let $x \geq 4$ and $\sec^{-1}\left(\dfrac x4\right) = \theta.$ Then $\sec\theta = \dfrac x4$ and $\theta$ is in the first quadrant (since $\dfrac x4 > 0$), so

$$ \tan^2\theta = \sec^2\theta - 1 = \dfrac{x^2}{16} - 1 = \dfrac{x^2-16}{16}, $$

so $\tan\theta = \pm \sqrt{\dfrac{x^2-16}{16}}.$ But since $\theta$ is in the first quadrant, $\tan\theta$ must be positive, so $\tan\theta = \sqrt{\dfrac{x^2-16}{16}}$ and (again, since $\theta$ is in the first quadrant) $$\sec^{-1}\left(\dfrac x4\right) = \theta = \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right).$$

Why is $\sec^{-1}\left(\dfrac x4\right) = \pi - \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right)$ when $x \leq -4$?

Note that when $y \leq -1,$ then $\sec^{-1} y = \pi - \sec^{-1}(-y).$ This comes from the way we define the inverse secant function; like the inverse cosine function, we use the second quadrant for negative values. And if $y \leq -1$ then $-y \geq 1,$ so $\sec^{-1}(-y)$ is a first-quadrant angle, so $\pi - \sec^{-1}(-y)$ is a second-quadrant angle and

$$ \sec\left(\pi - \sec^{-1}(-y)\right) = -\sec\left(\sec^{-1}(-y)\right) = -(-y) = y, $$

as required. Now let $x \leq -4$; then $-x \geq 4$ and (substituting $-x$ for $x$ in the what we worked out above for $x \geq 4$) $$ \sec^{-1}\left(\dfrac {(-x)}4\right) = \tan^{-1}\left(\dfrac{\sqrt{(-x)^2-16}}4\right) = \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right), $$ and $$ \sec^{-1}\left(\dfrac x4\right) = \pi - \sec^{-1}\left(\dfrac {(-x)}4\right) = \pi - \tan^{-1}\left(\dfrac{\sqrt{x^2-16}}4\right). $$

Related Question