0
$\begingroup$

After plotting this function on desmos, I understood that this absolute expression is actually a piecewise function.
Hence this: $$f(x)=|x+1|+|x-1|$$is the same as $$f(x)=\left\{\begin{align}2x\quad&\text{if }x>1\\-2x\quad &\text{if }x<-1\\2\quad &\text{if}-1<x<1\end{align}\right.$$

But is there a way to do this algebraically instead of plotting?

$\endgroup$
1
  • $\begingroup$ In this case $f(x)$ is the sum of the distances from the points $-1$ and $1$ on the number line - a fact which helped me to work problems like this through (and this remains true also in the complex plane). $\endgroup$ – Mark Bennet Dec 22 '20 at 7:48
5
$\begingroup$

The way to see this is as follows: you must observe that $$|f(x)| = \begin{cases} f(x), & f(x) \geq 0 \\ -f(x), & f(x) < 0\text{.} \end{cases}$$ It does not matter where the equality sign goes (i.e., $\geq$ as opposed to $>$, or $<$ as opposed to $\leq$) in the vast majority of situations.

We thus have $$|x + 1| = \begin{cases} x + 1, & x + 1 \geq 0 \\ -(x+1), & x + 1 < 0 \end{cases} = \begin{cases} x + 1, & x \geq -1 \\ -x - 1, & x < -1 \end{cases}$$ $$|x - 1| = \begin{cases} x - 1, & x - 1 \geq 0 \\ -(x - 1), & x - 1 < 0 \end{cases} = \begin{cases} x - 1, & x \geq 1 \\ -x + 1, & x <1\text{.} \end{cases}$$ Next, we must add these functions together.

First, observe that $|x + 1|$ is defined piecewise over the intervals $(-\infty, -1)$ and then $[-1, \infty)$. These are indicated by the blue and red below respectively.

For $|x - 1|$, we must look at $(-\infty, 1)$ and then $[1, \infty)$. These are indicated by the orange and green below respectively.

Apologies for my art skills.

enter image description here

Given the above, it is clear that the sum of $|x + 1|$ and $|x- 1|$, as a piecewise function, must have three components:

  • The blue-orange one, in $(-\infty, -1)$
  • The red-orange one, in $[-1, 1)$
  • The red-green one, in $[1, \infty)$.

The blue-orange component is when $x < -1$, or $|x + 1| = -x - 1$ and $|x - 1| = -x + 1$. Thus the sum of these is $-x - 1 + (-x + 1) = -2x$.

The red-orange component is when $-1 \leq x < 1$, or $|x + 1| = x + 1$ and $|x - 1| = -x + 1$. Thus the sum of these is $x + 1 + (-x + 1) = 2$.

The red-green component is when $x \geq 1$, or $|x + 1| = x + 1$ and $|x - 1| = x - 1$. Thus the sum of these is $x + 1 + (x - 1) = 2x$.

$\endgroup$
2
$\begingroup$

Plotting can give hints on what to do, but they're not conclusive.

The especially interesting points for $|f(x)|$ are those where $f$ “changes sign". In your case you have two of them, namely $-1$ and $1$.

So you can start to see what happens when $x<-1$: here we have $x+1<0$ and also $x-1<0$, so $$ f(x)=-(x+1)-(x-1)=-2x $$ When $-1\le x\le 1$, we have $x+1\ge0$ and $x-1\le 0$, so $$ f(x)=(x+1)-(x-1)=2 $$ When $x>1$, we have $x+1>0$ and $x-1>0$, so $$ f(x)=(x+1)+(x-1)=2x $$ Conclusion: $$ f(x)=\begin{cases} -2x & x<-1 \\[6px] 2 & -1\le x\le 1 \\[6px] 2x & x>1 \end{cases} $$ Where to put the special points? Don't worry, it's irrelevant. You could as well divide the cases into $$ x\le -1 \qquad -1<x<1 \qquad x\ge 1 $$ and the function wouldn't change, of course.

$\endgroup$
1
$\begingroup$

\begin{align}\lvert x+1\rvert+\lvert x-1\rvert&=\begin{cases}x+1+\lvert x-1\rvert&\text{if }x\ge-1\\ -x-1+\lvert x-1\rvert&\text{if }x<-1\end{cases}=\\&=\begin{cases}x+1+ x-1&\text{if }x\ge-1\land x\ge1\\x+1- x+1&\text{if }x\ge-1\land x<1\\ -x-1+ x-1&\text{if }x<-1\land x\ge1\\ -x-1- x+1&\text{if }x<-1\land x<1\end{cases}=\\&=\begin{cases}2x&\text{if } x\ge1\\2&\text{if }-1\le x<1\\ -2x&\text{if }x<-1\end{cases}\end{align}

$\endgroup$
3
  • $\begingroup$ Thank you for the answer; I'm trying to understand this. But it'd be helpful if you can elaborate this a bit? $\endgroup$ – ray_lv Dec 22 '20 at 5:47
  • $\begingroup$ You solved this for 3 cases, I think. But how did you know there should be 3 cases in the first place, and how did you select the domain for each case? $\endgroup$ – ray_lv Dec 22 '20 at 5:49
  • 2
    $\begingroup$ @ray_lv He didn't necessarily know there would be three cases. In the first equation there are two cases. Then each of those two cases makes two more cases and there are four cases. One of those cases is impossible: $x<-1\land x\ge1$ is always false, so you can eliminate that case. That leaves three cases. Simplify each of them. $\endgroup$ – David K Dec 22 '20 at 6:22
1
$\begingroup$

We know $f(x) \geq 0$.

And, $$ \begin{align} \{f(x)\}^2 & = (x+1)^2 + (x-1)^2 + 2 \lvert x + 1 \rvert \cdot \lvert x - 1 \rvert \\ & = 2(x^2 + 1) + 2 \lvert x^2 - 1 \rvert \\ & = \begin{cases} 2(x^2 + 1) + 2(x^2 - 1) = 4x^2 ~~~~~ \text{if } x^2 \geq 1, \\ 2(x^2 + 1) - 2(x^2 -1) = 4 ~~~~~ \text{if } x^2 \leq 1. \end{cases} \end{align} $$

Because $f(x) \geq 0$, hence,

$$ f(x) = \begin{cases} 2|x| ~~~~~ \text{if } |x| \geq 1, \\ 2 ~~~~~ \text{if } |x| \leq 1. \end{cases} $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.