Skip to content

Piecewise-defined Functions

Piecewise Functions

A piecewise-defined function is a function that uses different rules for different parts of its domain. This means the domain is divided into smaller "pieces," and each piece is governed by a separate mathematical expression. These individual rules together define the complete function.

Definition

A piecewise function \( f(x) \) can be written as:

\[ f(x) = \begin{cases} f_1(x) & \text{if } x \in I_1, \\ f_2(x) & \text{if } x \in I_2, \\ \vdots & \vdots \\ f_n(x) & \text{if } x \in I_n, \end{cases} \]

where \( I_1, I_2, \ldots, I_n \) are different subsets of the domain, and \( f_1(x), f_2(x), \ldots, f_n(x) \) are the mathematical rules (expressions) defining \( f(x) \) on those subsets.


Examples

  1. \[ f(x) = \begin{cases} x^2 & \text{if } x \geq 0, \\ x & \text{if } x < 0. \end{cases} \]
    • For \( x \geq 0 \), the rule is \( f(x) = x^2 \).
    • For \( x < 0 \), the rule is \( f(x) = x \).
  2. \[ f(x) = \begin{cases} 2x + 3 & \text{if } x \leq 1, \\ 5x - 2 & \text{if } x > 1. \end{cases} \]
    • For \( x \leq 1 \), the function is defined by \( f(x) = 2x + 3 \).
    • For \( x > 1 \), the function is defined by \( f(x) = 5x - 2 \).
  3. \[ f(x) = \begin{cases} -x & \text{if } x < 0, \\ 0 & \text{if } x = 0, \\ x & \text{if } x > 0. \end{cases} \]
    • For \( x < 0 \), the rule is \( f(x) = -x \).
    • At \( x = 0 \), the function takes the value \( f(x) = 0 \).
    • For \( x > 0 \), the rule is \( f(x) = x \).
  4. \[ f(x) = \begin{cases} 1 & \text{if } 0 \leq x < 2, \\ 2 & \text{if } 2 \leq x < 4, \\ 3 & \text{if } 4 \leq x \leq 6. \end{cases} \]

    Here:

    • \( f(x) = 1 \) when \( 0 \leq x < 2 \),
    • \( f(x) = 2 \) when \( 2 \leq x < 4 \),
    • \( f(x) = 3 \) when \( 4 \leq x \leq 6 \).
  5. A shipping company charges based on weight:

    \[ C(w) = \begin{cases} 50 & \text{if } w \leq 5 \, \text{kg}, \\ 100 & \text{if } 5 < w \leq 10 \, \text{kg}, \\ 200 & \text{if } w > 10 \, \text{kg}. \end{cases} \]
    • For weights up to \( 5 \, \text{kg} \), the cost is 50.
    • For weights between \( 5 \, \text{kg} \) and \( 10 \, \text{kg} \), the cost is 100.
    • For weights above \( 10 \, \text{kg} \), the cost is 200.

Each example illustrates how we can divide the domain of the function into intervals and assign a specific rule for each interval. Piecewise functions are particularly useful in modeling real-world scenarios where different rules apply in different situations.

How to evaluate a piecewise function

To understand how to evaluate a piecewise-defined function, let's go step by step with an example.

Consider the function \( f(x) \), defined in pieces as follows:

\[ f(x) = \begin{cases} x - 1 & \text{if } x < -1, \\ 2x & \text{if } -1 \leq x < 1, \\ 3 - x & \text{if } x \geq 1. \end{cases} \]

This function is divided into three parts:

  1. \( x - 1 \) is used when \( x < -1 \).
  2. \( 2x \) is used when \( -1 \leq x < 1 \).
  3. \( 3 - x \) is used when \( x \geq 1 \).

Now, let's evaluate \( f(x) \) at specific points.


Steps to Evaluate the Function

  1. For \( x = -2 \):

    • First, decide which condition \( x = -2 \) satisfies. Here, \( x < -1 \).
    • Use the first rule: \( f(x) = x - 1 \).
    • Substitute \( x = -2 \):
    \[ f(-2) = -2 - 1 = -3. \]
  2. For \( x = -1 \):

    • Check which condition \( x = -1 \) satisfies. Here, \( -1 \leq x < 1 \).
    • Use the second rule: \( f(x) = 2x \).
    • Substitute \( x = -1 \):
    \[ f(-1) = 2(-1) = -2. \]
  3. For \( x = 0 \):

    • Determine which condition \( x = 0 \) satisfies. Again, \( -1 \leq x < 1 \).
    • Use the second rule: \( f(x) = 2x \).
    • Substitute \( x = 0 \):
    \[ f(0) = 2(0) = 0. \]
  4. For \( x = 1 \):

    • Identify which condition \( x = 1 \) satisfies. Here, \( x \geq 1 \).
    • Use the third rule: \( f(x) = 3 - x \).
    • Substitute \( x = 1 \):
    \[ f(1) = 3 - 1 = 2. \]
  5. For \( x = 2 \):

    • Check which condition \( x = 2 \) satisfies. Again, \( x \geq 1 \).
    • Use the third rule: \( f(x) = 3 - x \).
    • Substitute \( x = 2 \):
    \[ f(2) = 3 - 2 = 1. \]

Key Takeaway

To evaluate a piecewise function:

  1. Identify which condition the given \( x \)-value satisfies.
  2. Use the corresponding rule (the piece of the function) for that condition.
  3. Substitute the \( x \)-value into the chosen rule to find the result.

Graph of a piecewise defined function

To graph the given piecewise function:

\[ f(x) = \begin{cases} x + 1 & \text{if } x \geq 1, \\ 1 - x & \text{if } x < 1, \end{cases} \]

we plot the graph in two pieces corresponding to the given conditions.


Case 1: \( x \geq 1 \) (\( f(x) = x + 1 \))

For \( x \geq 1 \), the function follows the rule \( f(x) = x + 1 \). Let us calculate some points by substituting sample values of \( x \):

  • When \( x = 1 \), \( f(1) = 1 + 1 = 2 \).
  • When \( x = 2 \), \( f(2) = 2 + 1 = 3 \).
  • When \( x = 3 \), \( f(3) = 3 + 1 = 4 \).

These points are \( (1, 2) \), \( (2, 3) \), and \( (3, 4) \). Plot these points and connect them with a straight line for \( x \geq 1 \).

At \( x = 1 \), the value \( f(1) = 2 \) is valid, so we put a solid circle at \( (1, 2) \).


Case 2: \( x < 1 \) (\( f(x) = 1 - x \))

For \( x < 1 \), the function follows the rule \( f(x) = 1 - x \). Let us calculate some points by substituting sample values of \( x \):

  • When \( x = 0 \), \( f(0) = 1 - 0 = 1 \).
  • When \( x = -1 \), \( f(-1) = 1 - (-1) = 2 \).
  • When \( x = -2 \), \( f(-2) = 1 - (-2) = 3 \).

These points are \( (0, 1) \), \( (-1, 2) \), and \( (-2, 3) \). Plot these points and connect them with a straight line for \( x < 1 \).

At \( x = 1 \), the condition \( x < 1 \) does not include \( x = 1 \). Therefore, the line \( 1 - x \) ends at \( x = 1 \) without including it. We put a hollow circle at \( (1, 0) \) to indicate this.


Key Points

  • The solid circle at \( (1, 2) \) shows that \( f(x) = x + 1 \) is valid at \( x = 1 \).
  • The hollow circle at \( (1, 0) \) indicates that \( f(x) = 1 - x \) is not valid at \( x = 1 \).
  • This distinction ensures clarity when transitioning between the two parts of the function.

Final Graph

  • The graph for \( f(x) = x + 1 \) (\( x \geq 1 \)) starts at \( (1, 2) \) (solid circle) and extends upward.
  • The graph for \( f(x) = 1 - x \) (\( x < 1 \)) starts at \( (1, 0) \) (hollow circle) and extends downward.

By joining these points appropriately, the final piecewise graph is obtained as shown below:

graph