# Range of absolute value function $g(x) = |4 - x|$

A function $g$ is defined as $g(x)=|4-x|$, find the range of $g$ if its domain is $-3\leq x \leq 6$.

My attempt:

I substitute $-3$ and $6$ into the function and I got $2$ and $7$. And the answer is between $0$ to $7$.

What should I do to get the correct answer ? Thanks in advance.

• I' suggest to you to write $g(x)=\left\{\begin{array}{ll} 4-x,&x\leq4\\ x-4,&x\geq4 \end{array}\right.$ .
– rgm
Feb 5 '17 at 13:21
• I think you meant to write "find the range of $g$ if its domain is $-3 \leq \color{red}{x} \leq 6$." Feb 5 '17 at 13:37
• The absolute value function is not a monotonic function so you cannot tell the range by just looking at the endpoints. Consider another non-monotonic function $f(x)=x^2$ for $-1\leq x\leq 1.$ We have $f(-1)=f(1)=1$ but the range is not $\{1\}.$ Feb 5 '17 at 16:49

Let's begin with the graph of the absolute value function $f(x) = |x|$. Since $|x|$ represents the distance of the number $x$ from $0$, $$|x| = \begin{cases} x && \text{if x \geq 0}\\ -x && \text{if x < 0} \end{cases}$$ Hence, its graph consists of the two rays $y = x, x \geq 0$ and $y = -x, x < 0$. The common endpoint of these two rays is the vertex of the graph, which is located at the origin.
Observe that $|x| = |-x|$ since the points $x$ and $-x$ are equidistant zero. Hence, $$|4 - x| = |-(4 - x)| = |-4 + x| = |x - 4|$$ The graph of $y = |x - 4|$ is obtained from the graph of $f(x)$ by translating the graph of $f(x)$ by four units to the right. You should be able to convince yourself of this by making a table of values for $y = |x|$ and $y = |x - 4|$. Another way to see this is to write the piecewise definition @shn stated in the comments $$|4 - x| = |x - 4| = \begin{cases} x - 4 && \text{if x \geq 4}\\ 4 - x && \text{if x < 4} \end{cases}$$ then graph the rays $y = x - 4, x \geq 4$ and $y = 4 -x, x < 4$.
Restricting the domain $y = |x - 4|$ to $[-3, 6]$ yields the graph of $g(x) = |x - 4|, -3 \leq x \leq 6$.
From its graph, we see that $g$ has minimum value $0$ at $x = 4$ (its vertex) and maximum value $7$ at $x = -3$. Since the function is continuous, it assumes every value between $0$ and $7$ in the interval $[-3, 4]$ and, consequently, in the interval $[-3, 6]$.