Review question

# Can we sketch the graph of $y = |x| + |x-1| + |x-4|$? Add to your resource collection Remove from your resource collection Add notes to this resource View your notes for this resource

Ref: R9130

## Solution

By considering the ranges $x < 0$, $0 \le x < 1$, $1 \le x < 4$ and $x \ge 4$, show that the graph of $\begin{equation*} y = \big|x\big| + \big|x-1\big| + \big|x-4\big| \end{equation*}$

consists of four line segments and give the equation of each segment. Sketch the graph.

Let’s look at the four regions described.

#### Region 1: $x < 0$

In this case, $x$, $x-1$ and $x-4$ are all negative so $\begin{equation*} y = \big|x\big| + \big|x-1\big| + \big|x-4\big| = -x - (x-1) - (x-4) = -3x + 5. \end{equation*}$

#### Region 2: $0 \le x < 1$

When we are in this region, $x$ is positive but $x-1$ and $x-4$ are negative so $\begin{equation*} y = \big|x\big| + \big|x-1\big| + \big|x-4\big| = x - (x-1) - (x-4) = -x + 5. \end{equation*}$

#### Region 3: $1 \le x < 4$

In this case, $\begin{equation*} y = \big|x\big| + \big|x-1\big| + \big|x-4\big| = x + (x-1) - (x-4) = x + 3. \end{equation*}$

#### Region 4: $x \ge 4$

Finally, in this region, $\begin{equation*} y = \big|x\big| + \big|x-1\big| + \big|x-4\big| = x + (x-1) + (x-4) = 3x - 5. \end{equation*}$

Thus, the graph of $y$ consists of four line segments. This leads to the following sketch.

Notice that the line segments join up at their ends. Why must this be the case for a function like this?

Calculate the roots of the equations

1. $\big|x\big| + \big|x-1\big| + \big|x-4\big| = 6 - \dfrac{1}{3}x$,

If we add the line $y = 6 - \dfrac{1}{3}x$ to our sketch in our mind’s eye, we can see that we expect two solutions, one negative, one positive.

#### Region 1: $x < 0$

In this region, the equation to solve becomes $\begin{equation*} -3x + 5 = 6 - \frac{x}{3} \iff \frac{8x}{3} = -1 \iff x = -\frac{3}{8}. \end{equation*}$

As this lies in the region $x < 0$, this is a valid solution.

#### Region 2: $0 \le x < 1$

The equation to solve can be written as $\begin{equation*} -x + 5 = 6 - \frac{x}{3} \iff \frac{2x}{3} = -1 \iff x = -\frac{3}{2}. \end{equation*}$

As this does not fall in the region under consideration ($0 \le x < 1$), there is no solution in this region.

#### Region 3: $1 \le x < 4$

In this region, the equation to solve becomes $\begin{equation*} x + 3 = 6 - \frac{x}{3} \iff \frac{4x}{3} = 3 \iff x = \frac{9}{4}. \end{equation*}$

As this is part of the region $1 \le x < 4$, this is the second solution to the original equation.

#### Region 4: $x \ge 4$

Finally, in this region, we are to solve $\begin{equation*} 3x - 5 = 6 - \frac{x}{3} \iff \frac{10x}{3} = 11 \iff x = \frac{33}{10}. \end{equation*}$

As $\dfrac{33}{10} < 4$, the solution does not fall in the region under consideration, and hence this is not a solution to the equation.

Thus, the two solutions to the equation are $\begin{equation*} x = -\frac{3}{8} \quad\text{and}\quad x = \frac{9}{4}. \end{equation*}$

By sketching the line $y = 6 - \frac{1}{3}x$ we could probably have seen that the solutions had to fall in regions 1 and 3 and saved ourselves some work.

1. $\big|x\big| + \big|x-1\big| + \big|x-4\big| = \dfrac{1}{x}$.

Once again, if we imagine adding the line $y = \dfrac{1}{x}$ to our sketch, we can see that we expect one positive solution to this.

#### Region 1: $x < 0$

It’s clear there are no solutions in this region, since $\dfrac{1}{x}$ is negative here.

#### Region 2: $0 \le x < 1$

The value $x = 0$ cannot be a solution. When $0 < x < 1$, the equation becomes $\begin{equation*} -x + 5 = \frac{1}{x} \iff -x^2 + 5x - 1 = 0. \end{equation*}$ The quadratic formula implies that $\begin{equation*} x = \frac{-5 \pm \sqrt{5^2 - 4 \times (-1) \times (-1)}}{2 \times (-1)} = \frac{-5 \pm \sqrt{25 - 4}}{-2} = \frac{5 \mp \sqrt{21}}{2}. \end{equation*}$ It is clear that $\begin{equation*} \frac{5 + \sqrt{21}}{2} > \frac{5}{2} > 1 \end{equation*}$ so that one of the two solutions does not fall into the region of interest. As for the other, $\begin{equation*} \frac{5 - \sqrt{21}}{2} \le \frac{5 - 4}{2} = \frac{1}{2} < 1 \end{equation*}$ and $\begin{equation*} \frac{5 - \sqrt{21}}{2} > \frac{5 - 5}{2} = 0 \end{equation*}$

and so this falls into the region of interest and it is a valid solution.

From a sketch, we would not expect to find any more solutions, but to be sure we’ll check.

#### Region 3: $1 \le x < 4$

The equation becomes $\begin{equation*} x + 3 = \frac{1}{x} \iff x^2 + 3x - 1 = 0 \end{equation*}$ and so $\begin{equation*} x = \frac{-3 \pm \sqrt{3^2 - 4 \times 1 \times (-1)}}{2} = \frac{-3 \pm \sqrt{9 + 4}}{2} = \frac{-3 \pm \sqrt{13}}{2}. \end{equation*}$

As $3 < \sqrt{13} < 4$, it is plain that neither of these values falls into the region under consideration.

#### Region 4: $x \ge 4$

Finally, in the fourth region, the equation can be written as $\begin{equation*} 3x - 5 = \frac{1}{x} \iff 3x^2 - 5x - 1 = 0 \end{equation*}$ and so $\begin{equation*} x = \frac{-(-5) \pm \sqrt{(-5)^2 - 4 \times 3 \times (-1)}}{2 \times 3} = \frac{5 \pm \sqrt{25 + 12}}{6} = \frac{5 \pm \sqrt{37}}{6}. \end{equation*}$ As $\sqrt{37} > 6$, it follows that $\begin{equation*} \frac{5 - \sqrt{37}}{6} < \frac{5 - 6}{6} < 0 \end{equation*}$ so that this possible solution falls outside of the region of interest. For the other, as $\sqrt{37} < 7$, $\begin{equation*} \frac{5 + \sqrt{37}}{6} < \frac{5 + 7}{6} = 2 \end{equation*}$

the solution also falls outside of the region of interest.

Thus there is just a single solution to the equation, namely $\begin{equation*} x = \frac{5 - \sqrt{21}}{2}. \end{equation*}$