Piecewise Functions

Piecewise Functions#

Definition#

Definition

A piecewise function is a function whose domain is broken up into several subintervals and a different rule is used to define the function on each subinterval.

Example 1#

A piecewise defined function

Movie theaters frequently offer discounted ticket prices for shows that start before 4:00 pm. If we let \(p(t)\) represent the price of a ticket for a movie that starts at time \(t\), then we could use the following notation to describe the scenario where a ticket costs 6 dollars if the movie starts before 4:00 pm and costs 10 dollars if the movie starts at 4:00 pm or later.

\[\begin{split} p(t) = \begin{cases} \$6 & \hbox{if $t<$ 4:00 pm} \\ \$10 & \hbox{if $t\geq $ 4:00 pm} \end{cases} \end{split}\]

Example 2#

Evaluate a piecewise function

Evaluate the following piecewise function at \(-1\), \(0\) and \(1\).

\[\begin{split} f(x) = \begin{cases} x^2 + 1 & \hbox{if $x < 0$} \\ 3 & \hbox{if $x = 0$} \\ \sqrt{x+4} & \hbox{if $x > 0$} \end{cases} \end{split}\]
Step 1:   Evaluate \(f(-1)\).

Since \(-1 < 0\), use \(f(x) = x^2 + 1\) to evaluate \(f(-1)\).

\[f(-1) = (-1)^2 + 1 = 2\]
Step 2:   Evaluate \(f(0)\).

Since \(x = 0\), \(f(0) = 3\).

Step 3:   Evaluate \(f(1)\).

Since \(1 > 0\), use \(f(x) = \sqrt{x+4}\) to evaluate \(f(1)\).

\[f(1) = \sqrt{1+4} = \sqrt{5}\]

Example 3#

Evaluate a piecewise function

Evaluate the following piecewise function at \(4\), \(5\) and \(6\).

\[\begin{split} g(x) = \begin{cases} \dfrac{x^2 - 25}{x-5} & \hbox{if $x\neq 5$} \\ 0 & \hbox{if $x = 5$} \end{cases} \end{split}\]
Step 1:   Evaluate \(g(4)\).

Since \(4 \neq 5\), use \(g(x) = \dfrac{x^2 - 25}{x-5}\) to evaluate \(g(4)\).

\[g(4) = \frac{4^2 - 25}{4-5} = 9\]
Step 2:   Evaluate \(g(5)\).

Since \(x = 5\), \(g(5) = 0\).

Step 3:   Evaluate \(g(6)\).

Since \(6 \neq 5\), use \(g(x) = \dfrac{x^2 - 25}{x-5}\) to evaluate \(g(6)\).

\[g(6) = \frac{6^2 - 25}{6-5} = 11\]