2
$\begingroup$

For example I have the function $f(x) = |x^2-1| = \sqrt{(x^2-1)^2}$

$\int \sqrt{(x^2-1)^2}dx = \frac{x(x^2-3)\sqrt{(x^2-1)^2)}}{3 (x^2-1)}+constant$

But plotted it looks like this: Plot 1. There are values < 0. I have to take the absolute value again to get the correct function. Plot 2 Why do I have to do it again? I integrated $|x^2-1|$ and not $x^2-1$

Edit: Part 2

  • 0
    The anti-derivative must be valid over the range of integration. It is not defined at $x=\pm 1$, so to use it directly, you must constrain your range to lie within one of the three ranges X<-1, $x\in [-1,1]$, or x>1. If your range does not fit within one of these, you need to split the range accordingly and sum the results.2012-11-08

3 Answers 3

3

$x^2-1$ is positive outside of the interval $[-1,1]$.

Therefore,

$|x^2-1| = \left\{ \begin{array}{rl} -x^2+1, & -1 \le x \le 1, \\ x^2-1, & \textrm{ otherwise}.\end{array}\right.$

Or more completely

$|x^2-1| = \left\{ \begin{array}{rl} x^2-1, & \textrm{ if } x < -1, \\ -x^2+1, & \textrm{ if } -1 \le x \le 1, \\ x^2-1, & \textrm{ if } x > 1.\end{array}\right.$

Then, you integrate. We'll put the constant of integration first, because there's some trickeration involved.

$\int |x^2-1|\ dx = C + \left\{ \begin{array}{rl} \frac{1}{3}x^3-x+c_1, & \textrm{ if } x < -1 \\ -\frac{1}{3}x^3+x+c_2, & \textrm{ if } -1 \le x \le 1,\\ \frac{1}{3}x^3-x, & \textrm{ if } x > 1. \end{array}\right.$

Now, what are $c_1$ and $c_2$? Well, if we omitted those, then we would have discontinuities at the points $x=-1$ and $x=1$. So we need to account for a "shift" to make sure the functions are continuous, and indeed, continuous in the first derivative.

Why is there no $c_3$? Because I put the constant of integration first, and we have to choose one branch to be the "anchor". I could have put $c_1$ and $c_2$ on any branch, but I wrote it like this for convenience.

The derivatives are easy to check because the constant terms get blown out. So we must have $\frac{d}{dx}\left(\frac{1}{3}x^3-x\right) = \frac{d}{dx}\left(-\frac{1}{3}x^3+x+c_2\right)$ at $x=1$. This becomes

$x^2-1 = -x^2+1 \implies 1^2-1=-1^2+1 \implies 0 = 0$

which is true, so our derivative is continuous.

Then, we must have $\frac{1}{3}x^3-x = -\frac{1}{3}x^3+x+c_2$ at $x=1$. This means that $\frac{1}{3}-1 = -\frac{1}{3}+1 +c_2 \implies c_2 = \frac{2}{3}-2 = -\frac{4}{3}.$

Repeating this process, we want

$\frac{1}{3}x^3-x+c_1 = -\frac{1}{3}x^3+x-\frac{4}{3}$

at $x = -1$. We can solve again for $c_1$ to obtain

$\frac{1}{3}-1+c_1 = -\frac{1}{3}+1-\frac{4}{3} \implies c_1 = 0.$

Testing for continuity of the derivatives is the same as before.

This is exactly what W|A gives, except my result is shifted a bit. But that's OK, because that difference gets thrown into the integration constant, $C$.

In general, the interpretation $|x| = \sqrt{x^2}$, while correct, will sometimes only get you so far. In particular, it is possible to compute different symbolic anti-derivatives of a function such that they are equivalent, and in fact equal, over a subset of the domain of $x$, but not equivalent/not equal over other sub-domains. In such a case, it is erroneous to say that an answer that works on a specific subdomain is the "right answer." In fact, it is only the right answer precisely where it is the right answer, and nowhere else.

In these situations, we need to look at other possible interpretations, if we hope to get an answer that is the "right answer" in more places -- and perhaps everywhere. In this case, the global right answer (that is, the answer that is correct over all of the reals) is the piecewise solution.

  • 0
    @Gunnar I have added to my answer to address the "mistake" that you are looking for. Basically you are differentiating a function over a region where it is not defined everywhere.2012-11-07
1

WA is giving a function whose derivative equals your $f$ everywhere except at two discontinuities. WA's algorithm for antidifferentiating must do different things depending upon what interval of $x$-values are under consideration. If you take WA's function and view it as a piecewise funciton with three pieces, you do indeed have an antiderivative except at the points where the discontinuities are. All you need to do to get the continuous antiderivative that you are expecting is shift the right-most piece of the graph that WA gave up, and shift the left piece down.

This can be accomplished by adding a step function to WA's answer.

$\frac{x(x^2-3)\sqrt{(x^2-1)^2)}}{3 (x^2-1)}+2/3\frac{|x-1|}{x-1}+2/3\frac{|x+1|}{x+1}$

This function is still undefined at $x=\pm1$, but the two-sided limit exists at each point, so it can be "glued" back together there:

$\begin{cases}2/3,&x=1\\-2/3,&x=-1\\\frac{x(x^2-3)\sqrt{(x^2-1)^2)}}{3 (x^2-1)}+2/3\frac{|x-1|}{x-1}+2/3\frac{|x+1|}{x+1},&\text{else}\end{cases}$


In response to a comment of th OP in a different answer, when you differntiate WA's antiderivative: $\frac{x(x^2-3)\sqrt{(x^2-1)^2)}}{3 (x^2-1)}$ using the chaing rule, quotient rule, etc., you are violating the conditions for the use of those rules, because you are applying them to a function that is not continuous. This function with this formula is not defined at $x=\pm1$. And that is the "mistake" that OP is looking for.

1

To evaluate $\int_a^b |x^2-1|dx$ there are 6 possibilities depending on where $a,b$ lie. I am assuming $a\leq b$ in the following, if $a>b$ then use $\int_a^b = -\int_b^a$.

If $a,b \in (-\infty,-1]$ or $a,b \in [1,\infty)$, then $\int_a^b |x^2-1|dx= \frac{1}{3} (b^3-3b-a^3+3a)$.

If $a,b \in (-1,1)$, then $\int_a^b |x^2-1|dx= \frac{1}{3} (a^3-3a-b^3+3b)$.

If $a\in (-\infty,-1], b \in (-1,1)$, then $\int_a^b |x^2-1|dx= \frac{1}{3} (4-a^3+3a-b^3+3b)$.

If $a\in (-1,1), b \in [1,\infty)$, then $\int_a^b |x^2-1|dx= \frac{1}{3} (4+a^3-3a+b^3-3b)$.

If $a \in (-\infty,-1]$, $b \in [1,\infty)$, then $\int_a^b |x^2-1|dx= \frac{1}{3} (8-a^3+3a+b^3-3b)$.