Functions • Online textbook lesson

Modulus / Absolute Value Functions

A complete self-study lesson on absolute value, piecewise definitions, graph transformations, domain, range and exam-style sketches.

Before you start

This lesson is designed to be read like a textbook chapter. Work through the examples with paper and pencil before opening the answers.

You should already know

How to sketch basic straight lines and quadratics, find intercepts, and read domain and range from a graph.

By the end you should be able to

Sketch \(y=|f(x)|\), write a modulus function piecewise, solve simple modulus equations and describe domain and range.

Exam focus

IB and IGCSE questions often test whether you understand which part of a graph is reflected and where corners occur.

1. Absolute value as distance

The absolute value of a number is its distance from zero on the number line. Since distance is never negative, an absolute value is always non-negative.

\[ |3|=3,\qquad |-3|=3,\qquad |0|=0. \]

More generally, the absolute value function is defined by

\[ |x|=\left\{\begin{array}{ll}x, & x\ge 0,\\-x, & x<0.\end{array}\right. \]
Key idea: if the input is positive, the modulus leaves it alone. If the input is negative, the modulus changes its sign.
Input \(x\)\(-3\)\(-2\)\(-1\)\(0\)\(1\)\(2\)\(3\)
Output \(|x|\)3210123

2. The graph of \(y=|x|\)

For \(x\ge 0\), \(|x|=x\), so the right-hand side of the graph is the line \(y=x\). For \(x<0\), \(|x|=-x\), so the left-hand side is the line \(y=-x\).

-5-4-3-2-112345-112345xyvertex (0,0)y=|x|y=x before reflection
The graph of \(y=|x|\) is V-shaped. Its vertex is at \((0,0)\), its domain is \(x\in\mathbb{R}\), and its range is \(y\ge 0\).
Common mistake: students sometimes think \(|x|\) means “make \(x\) positive”. A better idea is: \(|x|\) gives the distance of \(x\) from zero.

3. Transforming \(y=f(x)\) into \(y=|f(x)|\)

Now suppose we already have a graph \(y=f(x)\). The graph \(y=|f(x)|\) is found by applying the modulus to the output values.

\[ |f(x)|=\left\{\begin{array}{ll}f(x), & f(x)\ge 0,\\-f(x), & f(x)<0.\end{array}\right. \]
Part of \(y=f(x)\)What happens in \(y=|f(x)|\)Why?
Above the \(x\)-axisStays exactly where it isThe function value is already positive.
On the \(x\)-axisStays fixedZero stays zero: \(|0|=0\).
Below the \(x\)-axisReflects upward in the \(x\)-axisA negative function value becomes positive.
Graph rule: keep the positive part, reflect the negative part upward.

Sketch \(y=|x^2-4|\)

We begin with the graph inside the modulus: \(y=x^2-4\).

1
Find the important points of \(y=x^2-4\).

The vertex is \((0,-4)\). The roots are found from \(x^2-4=0\), so \(x=-2\) and \(x=2\).

2
Decide where the graph is negative.

The parabola is below the \(x\)-axis between its roots, so \(x^2-4<0\) for \(-2

3
Reflect the negative part upward.

The section between \(-2\) and \(2\) is reflected. The original vertex \((0,-4)\) becomes \((0,4)\).

-4-3-2-11234-5-4-3-2-1123456xy(-2,0)(2,0)(0,4)original (0,-4)y=|x²−4|dashed: y=x²−4
The dashed red curve is \(y=x^2-4\). The yellow curve is \(y=|x^2-4|\).

The piecewise definition is

\[ |x^2-4|=\left\{\begin{array}{ll}x^2-4, & x\le -2\text{ or }x\ge 2,\\4-x^2, & -2

Sketch \(y=|x^2-4x+3|\)

This example shows why it is useful to factor first.

1
Factor the quadratic.
\[ x^2-4x+3=(x-1)(x-3). \]

The roots are \(x=1\) and \(x=3\).

2
Find where it is negative.

The quadratic opens upward, so it is below the \(x\)-axis between the roots: \(1

3
Reflect that part upward.

The original minimum is at \((2,-1)\), so after taking the modulus it appears at \((2,1)\).

-112345-112345xyx=1x=3reflected vertexy=|x²−4x+3|
The part of \(y=x^2-4x+3\) between \(x=1\) and \(x=3\) is reflected upward.
\[ |x^2-4x+3|=\left\{\begin{array}{ll}x^2-4x+3, & x\le 1\text{ or }x\ge 3,\\-x^2+4x-3, & 1

4. Be careful: \(y=|f(x)|\) and \(y=f(|x|)\) are different

The modulus can be applied to the output or the input. These two transformations are not the same.

GraphMeaningTransformation
\(y=|f(x)|\)Take the modulus of the outputReflect parts below the \(x\)-axis upward.
\(y=f(|x|)\)Take the modulus of the inputUse the right-hand half of \(y=f(x)\) and reflect it in the \(y\)-axis.
-5-4-3-2-112345-5-4-3-2-1123456xyright half copiedmirror imagey=f(|x|) is symmetric about the y-axisuse x ≥ 0 part of y=f(x)
For \(y=f(|x|)\), the graph is always symmetric about the \(y\)-axis because \(|x|\) gives the same input for \(x\) and \(-x\).

Solve \(|2x-5|=7\)

A modulus equation can be solved by considering the two possible distances from zero.

\[ |2x-5|=7 \quad\Longrightarrow\quad 2x-5=7\text{ or }2x-5=-7. \]
1
\(2x-5=7\Rightarrow 2x=12\Rightarrow x=6\).
2
\(2x-5=-7\Rightarrow 2x=-2\Rightarrow x=-1\).

Therefore, the solutions are

\[ x=-1\quad\text{or}\quad x=6. \]
Important: \(|A|=k\) has two cases only when \(k>0\). If \(k<0\), there are no real solutions.

5. Domain and range

For \(y=|f(x)|\), the domain is usually the same as the domain of \(f(x)\), because we are only changing the outputs after \(f(x)\) has already been calculated.

The range changes because all outputs are non-negative:

\[ y=|f(x)| \quad\Longrightarrow\quad y\ge 0. \]

However, the exact range depends on whether the graph reaches zero and how high it goes. For example:

  • For \(y=|x^2-4|\), the minimum value is \(0\), so the range is \(y\ge 0\).
  • For \(y=|x^2+1|\), the original graph is already above the \(x\)-axis, so \(y=|x^2+1|=x^2+1\) and the range is \(y\ge 1\).

6. Practice questions

  1. Sketch \(y=|x-3|\). State its vertex, domain and range.
  2. Sketch \(y=|x^2-9|\). Write it as a piecewise function.
  3. Solve \(|3x+2|=11\).
  4. Explain the difference between \(y=|f(x)|\) and \(y=f(|x|)\).
  5. Sketch \(y=|(x+1)(x-4)|\). Identify the roots and the point that is reflected upward.
Answers
  1. Vertex \((3,0)\), domain \(x\in\mathbb{R}\), range \(y\ge 0\).
  2. Roots \(-3\) and \(3\). \(|x^2-9|=x^2-9\) for \(x\le -3\) or \(x\ge 3\), and \(9-x^2\) for \(-3
  3. \(3x+2=11\) or \(3x+2=-11\), so \(x=3\) or \(x=-\frac{13}{3}\).
  4. \(|f(x)|\) reflects negative outputs upward. \(f(|x|)\) reflects the right-hand half of the graph in the \(y\)-axis.
  5. Roots are \(-1\) and \(4\). The quadratic opens upward, so the section between \(-1\) and \(4\) is reflected upward. The original vertex occurs at \(x=\frac{3}{2}\).

Checklist before moving on

  • I can explain why absolute value is always non-negative.
  • I can sketch \(y=|f(x)|\) from \(y=f(x)\).
  • I can identify where a graph is below the \(x\)-axis.
  • I can write \(|f(x)|\) as a piecewise function.
  • I know the difference between \(|f(x)|\) and \(f(|x|)\).