# Why doesn't the derivative of integration by trig substitution match the original function?

For one of my assignments in Calc II, I had to solve ${\displaystyle\int} \frac{\sqrt{x^2-4}}{x} \text{ d}x$. By using Trig substitution where $x = 2 \text{ sec } \theta$, my solution was $\sqrt{x^2-4} - 2\text{ arcsec}\left(\frac{x}{2}\right) + C$. I tested my solution by graphing $\frac{\text{d}}{\text{d}x}\left[\sqrt{x^2-4} - 2\text{ arcsec}\left(\frac{x}{2}\right)\right]$, and it only matched the original function where $x \geq 2$. To match for $x \leq -2$, I had to use $\frac{\text{d}}{\text{d}x}\left[\sqrt{x^2-4} + 2\text{ arcsec}\left(\frac{x}{2}\right)\right]$.

Assuming I solved this correctly, what causes this discrepancy? How can we know if, when, and where this kind of thing will happen? Also, how would we notate the difference? Is it necessary to write the solution as a piecewise function, or does none of this matter anyway? I would think that, if it was because of the square root, the change in sign would be in front of it, but this seems to be because of the arc secant.

Edit Since a comment mentioned using WolframAlpha, I decided to double-check through there, and they do have my same answer under the Step-by-Step Solution, although they then simplified it to arctan somehow. Graphing the derivative of their solution with arctan matches the original function even less, with both a different C and shape. For explicitness, here's my work: $x = 2\sec \theta \Rightarrow \text{d}x = 2 \sec\theta \tan\theta$

$\int \frac{\sqrt{4 \sec^2\theta - 4}}{2 \sec\theta}(2 \sec\theta \tan\theta \text{ d}\theta) = \int 2 \sqrt{\sec^2 \theta-1} \tan\theta \text{ d}\theta = 2 \int \tan^2 \theta \text{ d}\theta$

With trig identity replacement: $2 \int \sec^2 \theta \text{ d}\theta - 2 \int 1 \text{ d}\theta = 2 \tan\theta - 2\theta$

With replacement of $\theta$ back to its original value: $\sqrt{x^2 - 4} - 2\text{ arcsec} \left(\frac{x}{2}\right) + C$

Edit 2 I understand that the square root causes sign issues, but even switching to absolute value doesn't seem to have any effect in the graphing. Here's a link to everything graphed on desmos.

• I beat you to it, deleting my comment! – amWhy Oct 21 '16 at 20:17
• According to Wolfram, your antiderivative is incorrect. – Ken Duna Oct 21 '16 at 20:17
• I hadn't checked with Wolfram before, but in their Step-By-Step, their answer is mine, but with different work, so I updated my answer in response and showed my work. – BrainFRZ Oct 21 '16 at 20:53

## 1 Answer

The trouble is when getting rid of the square root. In general we have $\sqrt{x^2} = |x|$, so $$\sqrt{\sec^2\theta-1} = \sqrt{\tan^2\theta} = \lvert\tan\theta\rvert.$$ So the integrand is really $$\lvert\tan\theta\rvert \tan \theta = \begin{cases} \sec^2\theta - 1 & 0\le\theta<\pi/2,\\ -(\sec^2\theta - 1) & \pi/2<\theta<\pi\\ \end{cases}$$ (where you take $\theta = \operatorname{arcsec} (x/2)$ with $0 \le \theta < \pi$). When reversing the substitution there is also the issue of $$\tan\theta = \begin{cases} \sqrt{\sec^2\theta - 1} & 0\le\theta<\pi/2,\\ -\sqrt{\sec^2\theta - 1} & \pi/2<\theta<\pi\\ \end{cases}$$ so the correct integral has two parts: $$\int \frac{\sqrt{x^2-4}}{x}\,dx = \begin{cases} \sqrt{x^2-4} - 2 \operatorname{arcsec}(x/2) + C_1 & x \ge 2, \\ \sqrt{x^2-4} + 2 \operatorname{arcsec}(x/2) + C_2 & x \le -2. \\ \end{cases}$$

• This doesn't seem to have any effect either. I've updated my answer again with the graphs. – BrainFRZ Oct 21 '16 at 21:07
• @BrainFRZ Edited with more info. – arkeet Oct 21 '16 at 21:10
• Okay, so it does boil down to it needing to be a piecewise function? Does this hold for all integrands with square root? – BrainFRZ Oct 21 '16 at 21:18
• Sorry, I had an error in my post which I just fixed. And generally you will have to deal with things piecewise when sign changes occur (e.g. across $x=0$ in $\sqrt{x^2} = |x|$). – arkeet Oct 21 '16 at 21:25