Graphing Piecewise Functions

This tutorial explains how to graph piecewise functions step by step. We examine their graphs, domains, ranges, and key properties. You may also use free graph paper to sketch the graphs by hand.

Definition of a Piecewise Function

A piecewise function is a function defined by different formulas on different intervals of its domain.

Example 1

\[ f(x) = \begin{cases} -x, & x \le 2 \\ x, & x > 2 \end{cases} \]

The domain of this function is all real numbers since a formula is defined for every value of \(x\).

Example 2

\[ f(x) = \begin{cases} 2, & x > -3 \\ -5, & x < -3 \end{cases} \]

This is a piecewise constant function. The domain is all real numbers except \(x = -3\).

Example 3

\[ f(x) = |x| \]

Using the definition of absolute value:

\[ f(x) = \begin{cases} x, & x \ge 0 \\ -x, & x < 0 \end{cases} \]

The domain is all real numbers.

Example 4

\[ f(x) = |x + 6| \] \[ f(x) = \begin{cases} x + 6, & x \ge -6 \\ -(x + 6), & x < -6 \end{cases} \]

This function is defined for all real numbers.

Example 5

\[ f(x) = \begin{cases} x^2 - 3, & x \le -10 \\ -2x + 1, & -10 < x \le -2 \\ -x^3, & 2 < x < 4 \\ \ln x, & x > 4 \end{cases} \]

The function is undefined on the interval \((-2, 2]\) and at \(x = 4\).

Example 6

\[ f(x) = \begin{cases} -1, & x \le -2 \\ 2, & x > -2 \end{cases} \]

Solution

The domain is all real numbers. The range is: \[ \{-1,\, 2\} \]

Graph of piecewise function in Example 6

Example 7

\[ f(x) = \begin{cases} x^2 + 1, & x < 2 \\ -x + 3, & x \ge 2 \end{cases} \]

The domain is all real numbers, and the range is: \[ (-\infty, +\infty) \]

Graph of piecewise function in Example 7

Example 8

\[ f(x) = \begin{cases} \frac{1}{x}, & x < 0 \\ e^{-x}, & x \ge 0 \end{cases} \]

The horizontal asymptote is \(y = 0\).

Graph of piecewise function in Example 8

Example 9

\[ f(x) = \begin{cases} -1, & x \le -1 \\ 1, & -1 < x \le 1 \\ x, & x > 1 \end{cases} \]

The domain is all real numbers and the range is: \[ \{-1\} \cup [1, +\infty) \]

Graph of piecewise function in Example 9

More references: Graphing Functions