topic badge

9.07 Piecewise graphs

Lesson

A piecewise linear function, as the name suggests, is made up of pieces or line segments, of various linear graphs. For example:

As we can see from the graph, we have three straight line pieces, which in this case are connected together, to create a complete graph over the domain $0\le x<10$0x<10. This makes this particular graph continuous over its range of $x$x values (though this isn't always the case).

Notice that at $x=0$x=0 there is a filled circle, indicating that at $x=0$x=0, we look at the first line segment to find the $y$y value. However, at $x=10$x=10 there is a hollow circle which means that at $x=10$x=10 there is no $y$y value that we can read from the graph, in this case, because this is where our graph stops.

 

Graphs of piecewise linear functions

 

Worked example

Example 1

Sketch a graph of the following piecewise linear function

$y$y $=$= $-x+6$x+6 when  $0\le x<5$0x<5
$1$1 when  $5\le x<8$5x<8
$0.5x-3$0.5x3 when $8\le x<10$8x<10

Think: Sketch each line segment separately as we would a general line, taking care to note the end-points of each section and whether or not they are included. We have many methods we can use to sketch graphs of straight lines, here a useful strategy is to plot the two end-points and join them to form each segment.

Do: Start with the first line segment from $x=0$x=0 to $x=5$x=5. First we'll plot the $y$y-intercept at $\left(0,6\right)$(0,6). Then we'll calculate the value of $y$y when $x=5$x=5, to find the point at which we want to end the drawing of this first line segment. This gives us $\left(5,1\right)$(5,1). As our equation showed $x<5$x<5, we'll need an open circle at the right hand end of the segment.

Next we'll draw the second linear function. We notice it's a horizontal line because we're drawing $y=1$y=1. This means that it will attach straight onto the endpoint of our last segment and we no longer need the open circle. And we'll draw this horizontal line from $x=5$x=5 to $x=8$x=8, with an open circle at the end.

Finally we'll sketch our last line segment. Using our strategy one more, we will calculate the $y$y-coordinate at each $x$x-coordinate of our endpoints, plot the two coordinates and draw the line. So at $x=8$x=8 we have $y=1$y=1, which again means we can attach our final piece to the middle piece at $\left(8,1\right)$(8,1). At $x=10$x=10 we have $y=2$y=2. So at $\left(10,2\right)$(10,2) we'll draw an open circle to match the information given, and we'll draw the line between our two points.

Practice question

question 1

The function $f\left(x\right)$f(x) is defined below:

$f\left(x\right)$f(x) $=$= $x+2$x+2 when $x\ge3$x3
$3$3 when $x<3$x<3
  1. Graph the function.

     

    Loading Graph...
    Cartesian plane
  2. Which of the following statements is true?

    The function is defined and continuous at $x=3$x=3.

    A

    The function is undefined and not continuous at $x=3$x=3.

    B

    The function is defined but not continuous at $x=3$x=3.

    C

    The function is undefined but continuous at $x=3$x=3.

    D

 

Finding the equation of a piecewise linear function

Recall we can find the equation of a linear graph by finding the $y$y-intercept and gradient. This is also the case for piecewise linear functions, where we find the equation of each piece and state the values of $x$x for that section covers.

 

Practice question

question 2

Define the function shown in the graph below.

Loading Graph...

  1. $y$y $=$= $\editable{}$     if $\editable{}$$\le$$x$x$\le$$\editable{}$
    $\editable{}$     if $\editable{}$$<$<$x$x$\le$$\editable{}$

 

Modelling with linear piecewise functions

Sometimes when attempting to create a linear model that describes a relationship between two variables, one linear model is not enough. As one (independent) variable changes, its relationship to the other (dependent) variable may also change. When this occurs, piecewise functions and step graphs can be used, so that multiple linear models can be applied to the one real-life scenario.

Worked example

Example 2

Sketch the piecewise linear function that describes the following:

Consider a runner who is running for exercise. Their exercise regime is to jog as a warm up, then start running, and then end their workout at rest. They begin jogging at a constant pace of $150$150 m/min for the first $2$2 minutes. After $2$2 minutes they start to run at $300$300 m/min. They continue at this speed for another $2$2 minutes before finally stopping and resting for the final $2$2 minutes of their workout.

Think: Let $y$y equal the distance covered by the runner, measured in metres and let $t$t equal the amount of time that the runner has been running, measured in minutes.

The person is moving at a constant speed in each part of their workout, so we can represent each section with a linear graph. Assess the information given for each section to determine the gradient and endpoints of the line segment.

Do: Assuming that no distance has been covered until the timer starts, this means that $y=0$y=0 when $t=0$t=0. So the first line will have a $y$y-axis intercept of $0$0 and a gradient of $150$150 metres per minute. The piecewise function follows this behaviour for $0\le t\le2$0t2.

At the $2$2 minute mark, the runner will have covered a distance of $2\times150=300$2×150=300 metres. We now have the end-points of the first section, $\left(0,0\right)$(0,0) and $\left(2,300\right)$(2,300), so we can plot and join the points to create the segment.

In the second section their speed now increases, which means the slope of the line also increases. The gradient of this second line would be $300$300 metres per minute, the speed at which the runner is now running. So the second line with this gradient can now be drawn between $2\le t\le4$2t4, connecting to the previous line when $t=2$t=2.

We can also find the distance covered at the $4$4 minute mark to plot the end-point. Since the runner's pace has been $300$300 metres per minute, they will have covered $2\times300=600$2×300=600 metres in the $2$2 minutes that they have been running at this pace, covering a total of $300+600=900$300+600=900 metres.

For the final $2$2 minutes of the workout, so for $4\le t\le6$4t6, the runner is resting and is therefore not covering any distance during this time. So a horizontal line can be drawn from the previous line at $t=4$t=4 until $t=6$t=6.

The graph is now complete and represents the given scenario. The equations could also be defined to create the following piecewise function.

$y$y $=$= $150t$150t when  $0\le t<2$0t<2
$300t-300$300t300 when  $2\le t<4$2t<4
$900$900 when $4\le t<6$4t<6

Practice question

question 3

Ken starts travelling at $9$9 am from point $A$A and moves towards point $B$B in a straight line.

The distance between Ken and point $B$B at various times in his journey is shown on the graph below.

A line graph is displayed with the horizontal axis labeled "Time (hours)" marked from 9 to 4 in one-hour increments, and the vertical axis labeled "Distance (km)" marked from 0 to 120 in increments of 20. A line connects several points on the graph, starting at point A at $\left(9,120\right)$(9,120), to $\left(10,70\right)$(10,70), to $\left(12,100\right)$(12,100), to $\left(1.5,100\right)$(1.5,100), to $\left(2,40\right)$(2,40), to $\left(2.5,40\right)$(2.5,40), and ending at point B at $\left(4,0\right)$(4,0).
  1. How far is point $B$B from point $A$A?

  2. How many hours was Ken's journey from point $A$A to point $B$B?

  3. Between what times did Ken travel at the fastest speed?

    $2:30$2:30 pm $-$ $4$4 pm

    A

    $12$12 pm $-$ $1:30$1:30 pm

    B

    $9$9 am $-$ $10$10 am

    C

    $10$10 am $-$ $12$12 pm

    D

    $1:30$1:30 pm $-$ $2$2 pm

    E
  4. What was Ken's fastest speed in km/h?

  5. What was the distance in kilometres travelled by Ken between $1:30$1:30 pm and $4$4 pm?

  6. What is the total distance travelled by Ken from $9$9 am to $4$4 pm?

Question 4

A children's pool is being filled with water. The volume of water $V$V, in litres, after $t$t minutes is given by the piecewise graph below. The pool has a maximum capacity of $1500$1500 L.

Loading Graph...

  1. Estimate the volume of water in litres after $45$45 minutes have elapsed, to the nearest $10$10 litres

  2. Determine the equation that describes the volume of water $V$V in litres after $t$t minutes in the first $45$45 minutes.

  3. After $45$45 minutes, the rate at which the volume of water enters the pool is increased.

    The piecewise relationship after $t=45$t=45 is given by $V=26t-970$V=26t970.

    Determine the value of $t$t (in minutes) until the pool is filled up.

 

Piecewise linear functions with CAS

A CAS calculator can be used to generate graphs and evaluate piecewise functions. Select your brand of calculator below to view instructions to utilise these features.

Casio Classpad

How to use the CASIO Classpad to complete the following tasks regarding piecewise linear functions.

Consider the function $f\left(x\right)$f(x) is defined as:

$f\left(x\right)$f(x) $=$= $-4x+28$4x+28 when $x\ge4$x4
$1.5x+6$1.5x+6 when $-2\le x<4$2x<4
$3$3 when $x<-2$x<2
  1. Create a graph of the function $y=f(x)$y=f(x).

  2. Find the value of the function when $x=3.5$x=3.5.

  3. For what value(s) of $x$x is the function equal to $9$9.

TI Nspire

How to use the TI Nspire to complete the following tasks regarding piecewise linear functions.

Consider the function $f\left(x\right)$f(x) is defined as:

$f\left(x\right)$f(x) $=$= $-4x+28$4x+28 when $x\ge4$x4
$1.5x+6$1.5x+6 when $-2\le x<4$2x<4
$3$3 when $x<-2$x<2
  1. Create a graph of the function $y=f(x)$y=f(x).

  2. Find the value of the function when $x=3.5$x=3.5.

  3. For what value(s) of $x$x is the function equal to $9$9.

 

Use technology to assist in graphing and analysing the piecewise function in the following practice question.

Practice questions

Question 5

Harry goes out for a run. He accelerates from rest up to a desired speed and maintains that speed for some time. Feeling exhausted, his velocity drops until he's back at rest.

The speed $S$S in km/h after $t$t seconds is given by the following piecewise relationship.

$S$S $=$= $0.8t$0.8t when $0\le t<15$0t<15
$12$12 when $15\le t<240$15t<240
$252-t$252t when $240\le t\le252$240t252
  1. Find the speed in km/h after $10$10 seconds have elapsed.

  2. Find the speed in km/h after $50$50 seconds have elapsed.

  3. Find the speed in km/h after $150$150 seconds have elapsed.

  4. Find the speed in km/h after $250$250 seconds have elapsed.

  5. Which of the following graphs describes the piecewise relationship?

    Loading Graph...

    A

    Loading Graph...

    B

    Loading Graph...

    C

    Loading Graph...

    D

Outcomes

ACMGM046

sketch piece-wise linear graphs and step graphs, using technology when appropriate

ACMGM047

interpret piece-wise linear and step graphs used to model practical situations; for example, the tax paid as income increases, the change in the level of water in a tank over time when water is drawn off at different intervals and for different periods of time, the charging scheme for sending parcels of different weights through the post

What is Mathspace

About Mathspace