MatheramaMatherama
← Relations and Functions
Relations and Functions·Section 6·7 min read

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)f(x) can be written as:

f(x)={f1(x)if x∈I1,f2(x)if x∈I2,⋮⋮fn(x)if x∈In,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 I1,I2,…,InI_1, I_2, \ldots, I_n are different subsets of the domain, and f1(x),f2(x),…,fn(x)f_1(x), f_2(x), \ldots, f_n(x) are the mathematical rules (expressions) defining f(x)f(x) on those subsets.


Examples

f(x)={x2if x≥0,xif x<0.f(x) = \begin{cases} x^2 & \text{if } x \geq 0, \\ x & \text{if } x < 0. \end{cases}
  • For x≥0x \geq 0, the rule is f(x)=x2f(x) = x^2.
  • For x<0x < 0, the rule is f(x)=xf(x) = x.
f(x)={2x+3if x≤1,5x−2if x>1.f(x) = \begin{cases} 2x + 3 & \text{if } x \leq 1, \\ 5x - 2 & \text{if } x > 1. \end{cases}
  • For x≤1x \leq 1, the function is defined by f(x)=2x+3f(x) = 2x + 3.
  • For x>1x > 1, the function is defined by f(x)=5x−2f(x) = 5x - 2.
f(x)={−xif x<0,0if x=0,xif x>0.f(x) = \begin{cases} -x & \text{if } x < 0, \\ 0 & \text{if } x = 0, \\ x & \text{if } x > 0. \end{cases}
  • For x<0x < 0, the rule is f(x)=−xf(x) = -x.
  • At x=0x = 0, the function takes the value f(x)=0f(x) = 0.
  • For x>0x > 0, the rule is f(x)=xf(x) = x.
f(x)={1if 0≤x<2,2if 2≤x<4,3if 4≤x≤6.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)=1f(x) = 1 when 0≤x<20 \leq x < 2,
  • f(x)=2f(x) = 2 when 2≤x<42 \leq x < 4,
  • f(x)=3f(x) = 3 when 4≤x≤64 \leq x \leq 6.

A shipping company charges based on weight:

C(w)={50if w≤5 kg,100if 5<w≤10 kg,200if w>10 kg.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 kg5 \, \text{kg}, the cost is 50.
  • For weights between 5 kg5 \, \text{kg} and 10 kg10 \, \text{kg}, the cost is 100.
  • For weights above 10 kg10 \, \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)f(x), defined in pieces as follows:

f(x)={x−1if x<−1,2xif −1≤x<1,3−xif x≥1.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−1x - 1 is used when x<−1x < -1.
  2. 2x2x is used when −1≤x<1-1 \leq x < 1.
  3. 3−x3 - x is used when x≥1x \geq 1.

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


Steps to Evaluate the Function

  1. For x=−2x = -2:

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

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

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

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

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

Key Takeaway

To evaluate a piecewise function:

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

Graph of a piecewise defined function§

To graph the given piecewise function:

f(x)={x+1if x≥1,1−xif x<1,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≥1x \geq 1 (f(x)=x+1f(x) = x + 1)

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

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

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

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


Case 2: x<1x < 1 (f(x)=1−xf(x) = 1 - x)

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

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

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

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


Key Points

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

Final Graph

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

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

graph

Section 6 of 18 · Relations and Functions

Mark this section complete when you have worked through its proofs.