{{ option.icon }} {{ option.label }} arrow_right
menu_book {{ printedBook.name}}
arrow_left {{ state.menu.current.label }}
{{ option.icon }} {{ option.label }} arrow_right
arrow_left {{ state.menu.current.current.label }}
{{ option.icon }} {{ option.label }}
arrow_left {{ state.menu.current.current.current.label }}
{{ option.icon }} {{ option.label }}
Mathleaks
Use offline
Expand menu menu_open
Systems of Linear Equations

Graphing Piecewise and Step Functions

{{ 'ml-article-collection-answers-hints-solutions' | message }}
tune
{{ topic.label }}
{{tool}}
{{ result.displayTitle }}
{{ result.subject.displayTitle }}
navigate_next

Channels

Direct messages

The aim of this lesson is to graph functions that are defined differently for different parts of their domains.

Catch-Up and Review

Here are a few recommended readings before getting started with this lesson.

Challenge

How Many Cans Are There in the Fridge?

Mark always likes to have cans of his favorite soft drink in the refrigerator so that he can enjoy a cold drink whenever he wants.

At the beginning of the week, he had 11 cans in the fridge. Over the week, Mark wrote down each time cans were consumed or added.

  • On Monday, Mark drank 1 can.
  • On Wednesday, Mark bought 2 cans at a convenience store and put them into the fridge.
  • On Friday, Mark had a party and a total of 10 cans were consumed.
  • On Saturday, Mark bought a 12-pack of soda from a supermarket and put them away in the refrigerator.
a How can the number of cans in the fridge be written as a function?
b Graph the number of cans in the refrigerator over the week.

Discussion

Piecewise Functions

A piecewise function is a function that is defined differently for different parts of its domain. These functions are commonly defined using intervals or inequalities. Consider the following example.
This function is defined as one linear function for values of x less than 0, and a different linear function for values of x that are at least zero. The graph of f is obtained by graphing the two rays. It should be noted that both rays represent the same function.
Piecewise Example
For every function, each input can correspond to only one output. Therefore, when two pieces of a piecewise function share a limit value, only one of the pieces can be defined for that value. It can be seen in the example function for f that only the second piece is defined for x=0. Additionally, it is possible for a piecewise function to be undefined for some intervals.
When plugging an input into a piecewise function, it is important to determine which expression should be used to find the correct output. This will be practiced in the next example.

Pop Quiz

Practice Finding Values

A piecewise function f is shown below. For every given value of x, find the correct value of f(x). Round the result to two decimal places, if necessary.

Find the value of f(x)

Discussion

Graphing Piecewise Functions

When graphing a piecewise function, each piece must be considered separately. First, a piece is graphed for the values of its domain. Then an end — or ends — of the piece are marked with one of the following.

  • A closed circle for an x-value for which the function is defined.
  • An open circle for an x-value for which the function is undefined.
Consider the following piecewise function.
Now, each piece will be considered one at a time. Then, the graphs will be combined.
1
First Piece
expand_more

The first piece is f(x)=4x+6. This is a linear function written in slope-intercept form. The function can be graphed by using the y-intercept and the slope.

Slope-intercept 1

Now, since the function is limited to inputs less than or equal to -1, the line will be graphed until it reaches x=-1. Since the inequality x-1 is non-strict, the function is defined for x=-1 and the circle will be closed.

Slope-intercept 1
2
Second Piece
expand_more

A similar process can be repeated to graph the second piece f(x)=-x+3. First, the line will be graphed.

This piece is defined for values of x greater than -1. This means that the line will be drawn starting at x=-1. Also, since the inequality is strict, the circle will be open.

3
Combining the Graphs
expand_more

Finally, the pieces will be graphed together in the same coordinate plane to complete the graph. It is important to pay attention to the limit points, since each value of x must be assigned to only one value of the function.

Example

Going to the Beach

On his summer vacation, Heichi often rides his bike to a nearby beach. Today he is going to meet a friend there.
surfing USA part 2
After leaving his house, Heichi bikes at 15 miles per hour for one hour until he reaches the beach. He spends 5 hours at the beach, then goes back to his house at 10 miles per hour. He arrives at back home an hour and a half after leaving the beach.
a Write a piecewise function that describes Heichi's distance from home as a function of time.
b Graph the function written in Part A.
c Describe the domain and range of the function written in Part A.

Answer

a
b
Answer Graph
c The domain consists of the number of hours betweeen 0 and 7.5 hours. The range is all the possible distances between 0 and 15 miles from his house.

Hint

a Determine a function rule for each part of Heichi's trip.
b Graph each piece one at a time.
c Where does the function written in Part A start? Where does it end?

Solution

a To begin with, for the first hour, Heichi bikes at 15 miles per hour. This speed can be used to write the first piece of the desired function. It is important to remember that the distance traveled is the product of the speed and the travel time.
Since Heichi was biking at 15 miles per hour for one hour, he traveled 15 miles in this interval. In the next piece, the value of the function is constant at 15 for the values of t between 1 and 6 because he is just hanging out at the beach for these 5 hours.
Finally, when Heichi goes home, he bikes at 10 miles per hour. Since he is returning home, the distance from his house will decrease. Therefore, the distance traveled is written as the product of -10 and t.
Also, since Heichi arrives at home one and a half hours later, the final value of the last piece should be 7.5 hours after the beginning of the trip. Therefore, the function needs to be translated 7.5 units right by subtracting 7.5 from t before multiplying by -10.
Finally, it is possible to write the complete function rule by adding this final piece.
b To graph the obtained piecewise function, each piece will be graphed one at a time on the same coordinate plane. First, the graph of 15t from 0 to 1 can be drawn by using the slope 15 and the y-intercept 0. Since the limit inequalities are non-strict, the border points will be closed.
First Piece

The second piece of the function is the horizontal line f(t)=15. Also, since the inequality is non-strict, the circle at t=6 will be filled.

Second Piece

Now, the x-intercept can be used to graph the third and final piece. From Part A, it is known that the x-intercept is 7.5.

Third Piece

Finally, the graph of the piecewise function is completed.

Function Graph
c From Part A, it can be seen that the function is defined for times between 0 and 7.5 hours, inclusive. Therefore, the domain of the function consists of all the real numbers in that interval.
The function's output represents how far Heichi is from his house. Looking at the graph, it can be seen that the minimum value of the function is 0, when Heichi is at his house, and the maximum value is 15, when Heichi is at the beach. While he is biking between his house and the beach, all distances from 0 to 15 are reached.

Discussion

Step Functions

A step function is a piecewise function that is defined by a constant value on each part of its domain. As an example, consider the following function.
The graph of a step function consists of horizontal line segments, which can be interpreted as steps. The graph of the given function has four line segments.
Step Function Example

Example

Collecting Boxes Over the Week

As a summer activity, Tearrik participates in charity events for his community. He is volunteering for a food drive event this weekend.

He went to a shopping center multiple times over the week to collect boxes of food for the food drive. On each day, he collected the following number of boxes.

  • 5 boxes on Monday
  • 3 boxes on Tuesday
  • 2 boxes on Wednesday
  • 3 boxes on Thursday
  • 4 boxes on Friday
Write a step function that indicates how many boxes in total Tearrik collected over the week.

Answer

Hint

Use the given days of the week as the domain of the function.

Solution

First, the domain of the function must be determined. The domain can be defined as the given days of the week, starting with the Sunday before Tearrik started collecting the boxes as x=0. Since Tearrik makes his first pickup on Monday, he starts with zero boxes on Sunday x=0.
On Monday, since one day has passed from Sunday, x=1. On this day, Tearrik collected his first 5 boxes.
On the following days, Tearrik collected more boxes. The boxes picked up each day were added to the number of boxes collected previously. Using this information, the pieces can be written in a table.
Day Collected Boxes Boxes in Total x f(x)
Sunday - 0 0x<1 0
Monday 5 0+5=5 1x<2 5
Tuesday 3 5+3=8 2x<3 8
Wednesday 2 8+2=10 3x<4 10
Thursday 3 10+3=13 4x<5 13
Friday 4 13+4=17 5x<6 17
Finally, the function rule of the step function can be written based on the table.

Discussion

Graphing Step Functions

Since step functions are piecewise functions, to graph them, each piece must be considered separately. First, each piece is graphed in its domain as a part of a horizontal line. The end or ends are then marked with one of the following.

  • A closed circle for an endpoint that is included in the function rule.
  • An open circle for an endpoint that is not included in the function rule.
As an example, consider the following step function.
For this example, one piece will be graphed in detail, then the other pieces will be graphed by following a similar process.
1
Graph a Horizontal Line
expand_more

The first piece is defined over the interval 0x<2. This piece will be graphed by drawing a horizontal line at y=1 from x=0 to x=2.

First Piece Horizontal Line
2
Drawing Endpoints
expand_more

It can be noted that x=0 is included in the domain of the first piece, but x=2 is not. Therefore, the left end of the segment will be marked with a closed circle and the right end with an open circle.

First Piece Endpoints
3
Graph the Other Pieces
expand_more

Then, the same process is repeated for each piece of the function.

Step Function Graph

Example

Saving Tips for a Week

Zain is working as a server in a restaurant for a week before their summer vacation ends.

Plate Fork Knife Emoji

Most of their payment comes from the tips they receive. Zain made note of how much they received in tips, starting from Monday and through their last day working on Saturday.

  • $49.50 on Monday
  • $38.17 on Tuesday
  • $41.45 on Wednesday
  • $58.33 on Thursday
  • $60.55 on Friday
  • $57.00 on Saturday
a Write a step function that describes the tips that Zain received during the week.
b Graph the function written in Part A.

Answer

a
b
Step Function Graph

Hint

a Determine the domain of the function.
b Graph each piece separately.

Solution

a The first thing to consider when writing a function is the domain. The domain of this function is defined as the days of the week, starting from the Sunday before Zain's week of work. This Sunday will be marked as x=0. Each day of the week will correspond to the next consecutive integer.
This indicates that Zain received $0 in tips on Sunday before they start working. On Monday x=1, Zain received $49.50 in tips. This defines the next piece of the function.
Since the function reflects the total amount of money Zain receives in tips, the value of each of the pieces can be determined by adding the new tip value to the total tip amount from the day before. Using this information, the pieces can be written in a table.
Day Tips Received Total Tips x f(x)
Sunday - 0 0x<1 0
Monday 49.50 0+49.50=49.50 1x<2 49.50
Tuesday 38.17 49.50+38.17=87.67 2x<3 87.67
Wednesday 41.45 87.67+41.45=129.12 3x<4 129.12
Thursday 58.33 129.12+58.33=187.45 4x<5 187.45
Friday 60.55 187.45+60.55=248.00 5x<6 248.00
Saturday 57.00 248.00+57.00=305.00 6x<7 305.00
Finally, the step function can be written based on the table.
b To graph a step function, each piece should be graphed separately on the same coordinate plane. The first section is a horizontal line at 0, limited to x=0 and x=1. The first circle will be closed and the second will be open.
First Piece

The next piece is the horizontal segment at 49.50 with a closed endpoint at x=1 and an open endpoint at x=2.

Second Piece

The remaining pieces can be added to the graph by following the same process.

Step Function Graph

Discussion

Greatest Integer Function

The greatest integer function, also known as the floor function, assigns the largest integer that is less than or equal to the value of x. This function is usually written as or Consider the following examples.
It can be noted that if x is an integer, the function returns the same value.
Otherwise, it returns the closest integer at the left of x in a number line.
Greatest Integer Function Examples

Considering more values can help understand how to draw the graph of the function.

x
-1 -1
-0.75 -1
-0.5 -1
-0.25 -1
0 0
0.5 0
1 1
1.25 1
1.75 1
1.99 1
2 2

From the table above, it can be seen that the function only changes its value when a new integer is reached. It can be noted that the greatest integer function is a step function. Its graph is presented as follows.

The domain of the function is the set of all real numbers, but its range is the set of integers. A filled point indicates that the point is part of the graph, while an open point indicates that it is not.

Example

The Price of Parking at the Cinema

Dominika is going to a movie at a local theater on her last day of vacation.

Mall Emoji

The cost to park in the theater lot is $10 for less than an hour. An additional $2.50 is charged for each hour of parking.

a Write the greatest integer function that describes the prices of the mall's parking lot.
b Graph the function obtained in Part A.

Answer

a

b
Greatest Integer Function Graph Answer

Hint

a If $2.50 is charged every hour, only the integer part of the number of hours determines parking charges.
b Start with the graph of the greatest integer function. Then, apply transformations to modify the graph.

Solution

a The first thing to notice to write the function is that $2.50 is charged for each hour of parking. This means that as soon as one hour is reached, $2.50 is added to the total cost of parking. At the two hour mark, the next $2.50 is charged. This can be written by multiplying by 2.5, where x is the parking time in hours.
Additionally, the lot requires an initial payment of $10 for the first 59 minutes of parking. This information can be used to add 10 to the value of the obtained function f1.
This completes the required function, as the price to enter is considered and $2.50 is added as each hour is reached.
b This function can be graphed by modifying the graph of the greatest integer function. Since only the positive values of x are relevant, the graph will be considered only in the first quadrant. This graph is shown as follows.
Greatest Integer Function Graph

Next, since the greatest integer function is multiplied by 2.5, each value of y is multiplied by 2.5, vertically stretching the spaces between each horizontal segment.

Greatest Integer Function Graph Multiplied

Then, since 10 is added to the product, each segment is translated vertically 10 units up.

Greatest Integer Function Graph Multiplied and Addition

Finally, the scope of the coordinate plane will be adjusted so that more steps of the graph can be seen.

Greatest integer function graph after transformations and with skipped values

Example

Math Graphing Assignment

During his summer vacation, Ignacio went to private math lessons. After learning about the greatest integer function, Ignacio was asked by his math tutor to graph the numbers y greater than or equal to

Teacher Asks a Question
Help Ignacio with his answer and graph the inequality

Answer

Answer Graph

Hint

Graph the greatest integer function. Then, determine the solution set by shading the appropriate region.

Solution

The first step to graph an inequality is to graph the border function. The border function of the given inequality is given by the greatest integer function. This function is a step function whose output is the greatest integer less than or equal to the input x. Note that the inequality is non-strict, so the horizontal lines are drawn as solid lines.

Greatest Integer Function Graph
Now a random point can be used to test which region satisfies the inequality. Any point that does not lie on the border function can be chosen. For this example, (2,0) will be used.

Since the point does not satisfy the inequality, the region on the other side of the border function is solution set of the inequality.
Shaded Region
Finally, it is important to verify if the borders of the vertical segments between each horizontal segment are solid or dashed, to avoid confusion whether the points that lie on this line satisfy the inequality or not. To verify this, as with the initial solution region, a test point will be selected and substituted into the inequality. In this case, (1,0.5) will be used.

Since the point does not satisfy the inequality, the vertical segments should be dashed.
Dashed Vertical Segments Graph

Finally, the following is the complete graph of the inequality that the teacher asked for.

Answer Graph

Closure

Cans in the Fridge

At the beginning of this lesson, it was asked that a function for the number of soda cans in Mark's refrigerator be written. Mark starts the week with 11 cans in the fridge and then does the following.

  • On Monday, Mark drank 1 can.
  • On Wednesday, Mark bought 2 cans at a convenience store and put them into the fridge.
  • On Friday, Mark had a party and a total of 10 cans were consumed.
  • On Saturday, Mark bought a 12-pack of soda from a supermarket and put them away in the refrigerator.
a How can the number of cans in the fridge be written as a function?
b Graph the number of cans in the refrigerator over the week.

Answer

a
b
Step Function Graph

Hint

a First, determine the domain of the function.
b What kind of functions have constant outputs for each part of their domain?

Solution

a The first thing to do when writing a function is to determine its domain. In this case, the domain can be written as the number of days passed from the beginning of the week, starting from Sunday as x=0. With the given information, it is possible to write the first part of the piecewise function.
Mark drank one can of soda on Monday. Therefore, he has now 111=10 cans left in the fridge that day. Also, since he neither drank nor bought any soda on Tuesday, the function's output is still 10 until Wednesday, when x=3.
Mark bought 2 cans on Wednesday, meaning that there are 10+2=12 cans of soda in the fridge that day. Since he neither bought nor drank any of the soda in the refrigerator on Thursday, he has 12 cans until Friday.
At Friday's party, a total of 10 cans were drunk. Therefore, he has 1210=2 cans left in the refrigerator for Saturday. Then, on Saturday, he bought a 12-pack of soda cans, making it for 2+12=14 cans in the refrigerator for that day. Because no more information was given, the whole function rule can now be written.
b Since every part of this function is a constant value, this is a step function. The graph of a step function consists of horizontal lines limited to specific inputs. It is important to remember the values for which the inequality for x is strict or non-strict.
Step Function Graph


arrow_left
arrow_right
{{ 'mldesktop-placeholder-grade-tab' | message }}
{{ 'mldesktop-placeholder-grade' | message }} {{ article.displayTitle }}!
{{ grade.displayTitle }}
{{ 'ml-tooltip-premium-exercise' | message }}
{{ 'ml-tooltip-programming-exercise' | message }} {{ 'course' | message }} {{ exercise.course }}
Test
{{ focusmode.exercise.exerciseName }}
{{ 'ml-btn-previous-exercise' | message }} arrow_back {{ 'ml-btn-next-exercise' | message }} arrow_forward
arrow_left arrow_right
close
Community