Lesson Explainer: Graphs of Piecewise Functions Mathematics

In this explainer, we will learn how to graph and analyze a piecewise-defined function and study its different characteristics.

A piecewise function consists of multiple subfunctions defined over individual subdomains. The union of the subdomains makes up the overall piecewise function’s domain. The union of the ranges of the subfunctions makes up the range of the overall piecewise function.

The following data about an amusement park’s ticket prices can be modeled with a piecewise function.

Amusement Park Ticket Prices
AgePrice
5–12$8.50
13–18$12
19+$15

The table presents three different ticket prices, which depend on the age of the park visitor. Modeling this will require three different subfunctions. We will also need to think carefully about how to interpret the age categories when selecting the domain of each subfunction. Age 5–12 covers people from the moment the clock strikes midnight at the start of their 5th birthday to the instant before the clock strikes midnight at the start of their 13th birthday. Age 13–18 covers people from the moment the clock strikes midnight at the start of their 13th birthday to the instant before the clock strikes midnight at the start of their 19th birthday. Age 19+ covers people from the moment the clock strikes midnight at the start of their 19th birthday onward.

Let’s define 𝑥 to be the age (in years) of the park visitor and 𝑓(𝑥) to be the price of a visitor’s ticket (in dollars). We can then write a definition of our function 𝑓(𝑥): 𝑓(𝑥)=8.55𝑥<13,1213𝑥<19,15𝑥19.

Now, let’s consider how to graph this function. We will need to examine each subdomain separately.

Park visitors aged 5–12 are all charged $8.50, so the value of 𝑓(𝑥) is equal to 8.5 when 5𝑥<13. This is represented by a horizontal line on our graph with a 𝑦-value of 8.5 and 𝑥-values from 5 (including 5, represented by a solid dot) up to 13 (excluding 13, represented by a hollow dot). We have represented this with the pink line on our graph below.

Park visitors aged 13–18 are all charged $12, so the value of 𝑓(𝑥) is equal to 12 when 13𝑥<19. This is represented by a horizontal line on our graph with a 𝑦-value of 12 and 𝑥-values from 13 (including 13, represented by a solid dot) up to 19 (excluding 19, represented by a hollow dot). We have represented this with the blue line on our graph below.

Park visitors aged 19+ are all charged $15, so the value of 𝑓(𝑥) is equal to 15 when 𝑥19. This is represented by a horizontal line on our graph with a 𝑦-value of 15 and 𝑥-values from 19 (including 19, represented by a solid dot) upward (represented by a ray pointing to the right). Although people do not live forever, the pricing model is defined so that, no matter how old you get, if you are 19 years of age, or older, you will be charged $15 to visit the park. We have represented this with the green ray on our graph below.

Although, in many piecewise functions, the definitions of the subfunctions may be much more complicated than the constant functions in our amusement park example, the principle is the same for graphing them. We need to consider the graph for each subdomain individually, look at what will happen at each end of each subfunction, and graph them alongside each other on the same set of axes.

The piecewise function we defined for the amusement park ticket prices, and have graphed, is only defined for all real 𝑥-values of 5 or more. Therefore, the domain of the overall function can be written as an inequality, 𝑥5, using interval notation as [5,[ or in set notation as {𝑥𝑥5}.

The values that the function can take are only 𝑓(𝑥)=8.5, 𝑓(𝑥)=12, or 𝑓(𝑥)=15. Therefore, the range of the overall function can be written in set notation as {8.5,12,15}.

Now, let’s consider some examples where we have to work with graphs of piecewise-defined functions.

Example 1: Identifying the Type of Function Represented in a Graph

What kind of function is depicted in the graph?

  1. An even function
  2. A logarithmic function
  3. A piecewise function
  4. A polynomial function

Answer

Let’s consider each of the options.

  1. An even function is one for which 𝑓(𝑥)=𝑓(𝑥) for all values of 𝑥 in the domain of 𝑓. This means that even functions are symmetrical about the 𝑦-axis, which is not the case with the given graph. For example, 𝑓(5)=7, but 𝑓(5)=0, so 𝑓(5)𝑓(5); therefore, the function is not even.
  2. The logarithm of a particular value, say 𝑥, is the exponent to which another base number has to be raised to produce 𝑥. Graphs of logarithmic functions have smooth curves which are asymptotic to the 𝑦-axis, as we can see in the examples below, or they may be transformed. The given graph has sharp corners at 𝑥=3 and 𝑥=0, so it is not smooth across its entire domain, and it also has no vertical asymptotes. Also, logarithmic functions are not defined for negative values of 𝑥; in other words, their domain is the set of positive real numbers. The given graph represents a function that has a domain of at least 10<𝑥<8, which includes some negative 𝑥-values, so the given graph does not look like a logarithmic function.
  3. The graph of this function consists of three distinct subfunctions.
    1. For 𝑥-values between and 3, the graph is a straight line with slope 1. We could write the equation for this line in the form 𝑦=𝑚𝑥+𝑏, where 𝑚 is the slope (1) and 𝑏 is the 𝑦-intercept, so 𝑦=𝑥+𝑏. We also see that the line passes through the point (5,0), so 𝑦=0 when 𝑥=5, which enables us to calculate the value of 𝑏 as 5. Hence, we could write the equation as 𝑦=𝑥+5.
    2. For 𝑥-values from 3 to 0, the graph is a horizontal line such that the 𝑦-value is always 2, so we can write the equation of this line as 𝑦=2.
    3. For 𝑥-values from 0 to , the graph is again a straight line with slope 1. This time, we can see that the 𝑦-intercept is 2, so we can write the equation as 𝑦=𝑥+2.
    Although we have not been specifically asked to do this, we could write out the function definition as follows: 𝑓(𝑥)=𝑦=𝑥+5𝑥<3,𝑦=23𝑥<0,𝑦=𝑥+2𝑥0.
    However, from the graph, we can see that the values of the subfunctions are the same as their neighbors at their common endpoints; in other words, the subfunctions join to make a continuous function. It would be equally valid to define the subfunctions as having slightly different subdomains by rearranging which subfunction the points of connection belong to. In this situation, where the allocation is arbitrary, it is conventional to include the left endpoint and exclude the right endpoint from subfunctions.
    The fact that our function has to be defined in terms of a series of subfunctions over specific subdomains makes it a piecewise function.
  4. Polynomial functions involve the addition, subtraction, and multiplication of coefficients and variables with nonnegative integer exponents. The graphs of polynomial functions produce smooth curves and can be defined by a single polynomial equation. The given graph has two points that are not smooth, when 𝑥=3 and 𝑥=0, so it is not the graph of a polynomial function.

Therefore, the function depicted in the graph is a piecewise function (option C).

In our next example, we will examine the endpoints of each subfunction on a graph of a piecewise-defined function to find its domain.

Example 2: Finding the Domain of a Piecewise Function given Its Graph

Determine the domain of the function represented by the given graph.

Answer

The domain of a function is the set of all values where the function is defined. On the graph of a function, the domain is all of the 𝑥-values where the curve is drawn. For a piecewise-defined function, the domain will be the union of the subdomains of each subfunction. This piecewise-defined function has two subfunctions.

The first subfunction is a ray with a hollow dot at (4,1). The hollow dot indicates this subfunction is undefined at 𝑥=4 and, therefore, has a right open interval. The arrow indicates that the subfunction continues indefinitely in the direction of that arrow, here toward negative infinity. Therefore, the first subfunction has a subdomain of ],4[.

The second subfunction is a ray with a hollow dot at (4,2). The hollow dot indicates this subfunction is also not defined for 𝑥=4 and, therefore, has a left open interval. The arrow indicates this subfunction continues indefinitely in the direction of the arrow, which here is toward positive infinity. Therefore, the domain of the second subfunction will be ]4,[.

The union of these subdomains is ],4[]4,[.

The union of these two subdomains will include all real numbers except for 4,{4}.

Graphically, we can find the domain by looking at vertical lines on the graph and seeing where they cross a given function. In this case, the vertical line at 𝑥=4 only intersects the hollow dots of each subfunction.

Neither subfunction is defined for 𝑥=4, which means this piecewise function is not defined at 𝑥=4. Therefore, the domain of this piecewise-defined function will be the set of all real numbers except for 4, {4}.

In the previous example, we saw that the domain of a piecewise-defined function is the union of the subdomains for each of the subfunctions. In our next example, we will show the range of a piecewise-defined function will be equal to the union of the ranges of each subfunction over their respective subdomains.

Example 3: Determining the Range of a Piecewise Function from Its Graph

Find the range of the function.

Answer

On the given graph, we can identify two specific subfunctions making this a piecewise function. The range of a function is the set of all possible output values for a function, given its domain. The range of a piecewise-defined function is the union of the ranges of each subfunction over their respective subdomains.

We can identify values in the range using horizontal lines. If a horizontal line intersects the graph of our function, then the value of the horizontal line is part of the range. For this piecewise function, the horizontal line 𝑦=3 intersects the graph of one of the subfunctions, which means 3 is included in the range of this subfunction.

From the graph, we see the behavior of the subfunction that begins at (4,1) and continues indefinitely toward positive infinity. Any horizontal line above 𝑦=3 will intersect this subfunction and must be included in the range.

Any horizontal line between 𝑦=1 and 𝑦= will intersect this subfunction, making its range [1,[.

It is worth noting here that the other subfunction is the horizontal line 𝑦=1 over its subdomain ],4].

Therefore, 1 is the only value in the set for the range. The range of this subfunction over its subdomain will be {1}.

The union of the ranges for these two subfunctions over their respective subdomains is {1}[1,[.

Therefore, the range of this piecewise-defined function is [1,[.

In our next example, we will use the graph of a piecewise-defined function to find a formal definition of the function.

Example 4: Defining a Piecewise Functions from a Given Graph

Give the piecewise definition of the function whose graph is shown.

Answer

A piecewise function consists of two or more subfunctions. To define a piecewise function, we need an expression for each of the subfunctions and the subdomains for each of the subfunctions. We will first identify how many subfunctions are part of this piecewise function by looking at the behavior of the graph. In this case, there are two subfunctions.

We have a straight line with a negative slope that ends at (2,1) and another straight line that begins at (2,1) and has a positive slope. Each of these lines will form a subfunction of this piecewise function over its respective subdomain. So, we define an equation in terms of 𝑥 for each subfunction and identify their respective subdomains.

The slope-intercept form of a line tells us a line of slope 𝑚 and 𝑦-intercept 𝑏 has the equation 𝑦=𝑚𝑥+𝑏. The slope 𝑚 equals changeinchangein𝑦𝑥.

The straight line with the negative slope has a 𝑦-intercept at 3. The slope is identifiable from the graph without doing any formal calculations. As the 𝑥-value increases by one unit, the 𝑦-value decreases by one unit.

Therefore, changeinchangein𝑦𝑥=11. Hence, 𝑚=1.

Therefore, the first subfunction is defined as 𝑦=𝑥+3𝑦=3𝑥.or

However, we still need to identify the subdomain of this subfunction; we can graph a vertical line at 𝑥=2, and we can confirm that 2 is included in the domain of this piecewise function since it crosses the curve at (2,1).

On the graph, 2 appears to be part of both of the subfunctions’ domains. However, when we are defining a piecewise function, we only include 2 in one of the subfunctions’ domains so their domains do not overlap. This is usually determined by the context of the question. As we only have the graph without any other data, we will just let the first subfunction be defined for the subdomain ],2[.

Therefore, the second subfunction would be defined for the subdomain [2,[.

It would be equally valid to define the subfunctions as having slightly different subdomains by rearranging which subfunction the points of connection belong to. In this situation, where the allocation is arbitrary, it is conventional to include the left endpoint, and exclude the right endpoint from subfunctions.

Now that we have defined each subdomain, we use the graph to write a formula for the second subfunction over its subdomain.

The straight line of the second subfunction models the 𝑦-value increasing by 1 unit as the 𝑥-value increases by 2 units. Therefore, changeinchangein𝑦𝑥=12. We can then identify the 𝑦-intercept graphically by extending the line to see where this subfunction would cross the 𝑦-axis if it was part of the domain.

The 𝑦-intercept of the second subfunction would be 0. Therefore, the formula for the second subfunction is 𝑦=𝑥2.

Combining these two subfunction rules over their respective subdomains defines this piecewise function as (𝑥)=3𝑥𝑥<2,𝑥22𝑥.ifif

In example 5, we will use the graph of a piecewise-defined function to find a formal definition of the function for a piecewise function with more than two subfunctions.

Example 5: Defining a Piecewise Function from a Given Graph Including a Discontinuity

Give the piecewise definition of the function 𝑓 whose graph is shown.

Answer

A piecewise function consists of two or more subfunctions. To define a piecewise function, we need the formula for each of the subfunctions and their respective subdomains. Three distinct behaviors are shown in this graph.

Therefore, we will need to write a total of three expressions and find three subdomains, one for each subfunction.

For straight lines, we can write the equation using the slope-intercept form, 𝑦=𝑚𝑥+𝑏, where 𝑏 is the 𝑦-intercept and 𝑚 is the slope. The slope 𝑚 equals changeinchangein𝑦𝑥.

For this line, the change in 𝑥 is 1 unit right and the change in 𝑦 is 1 unit down. Therefore, changeinchangein𝑦𝑥=11, which simplifies to 𝑚=1. The 𝑦-intercept is 3. Therefore, the expression for this subfunction over its subdomain is 𝑥+33𝑥.or

The subdomain of this subfunction is equal to the set of all input values for this subfunction. The hollow endpoint (2,1) indicates that the upper bound of this subdomain must be an open interval. Therefore, the subdomain would be the open interval from ],2[.

The next subfunction has a closed point at (2,2).

The closed point at (2,2) shows the constant function 𝑦=2, where the subdomain is {2}.

The third subfunction has a hollow dot at (2,3) and continues indefinitely. Therefore, the subdomain of this subfunction is the interval ]2,[.

For this subfunction, the 𝑥-value increases by 2 units as the 𝑦-value increases by 1 unit. Therefore, changeinchangein𝑦𝑥=12. We can then identify the 𝑦-intercept graphically by extending the line to see where this subfunction would cross the 𝑦-axis if it was part of its subdomain.

The 𝑦-intercept for this subfunction is 2. Therefore, the formula for the third subfunction over its subdomain is 𝑦=𝑥2+2.

Combining each of these three subfunctions in the format for piecewise-defined functions: 𝑓(𝑥)=3𝑥𝑥<2,2𝑥=2,𝑥2+22<𝑥.ififif

Our final example further explores how open and closed intervals for subdomains of piecewise-defined functions are graphed.

Example 6: Identifying the Graph of a Piecewise Function from Its Definition

State which of the following graphs represents the function 𝑓(𝑥)=𝑥,𝑥<2,2𝑥+10,𝑥2.

Answer

We are given the piecewise-defined function 𝑓(𝑥)=𝑥,𝑥<2,2𝑥+10,𝑥2.

This piecewise-defined function consists of two subfunctions over specified subdomains. The first subfunction is a quadratic function 𝑦=𝑥 over the subdomain 𝑥<2. To graph this quadratic, we can use the subdomain to create a table of input and output values. We know that the subdomain for this function is values of 𝑥 that are less than 2.

𝑦=𝑥
𝑥𝑦
24
11
00
11
24

Using the table, we can plot these points on a graph. Notice the point (2,4) on the graph is hollow since 𝑥=2 is not included in the subdomain of 𝑦=𝑥.

Sketching a line through these coordinates produces a graph of 𝑦=𝑥 over the subdomain 𝑥<2.

The second subfunction 𝑦=2𝑥+10, is a linear function. Again, we can use the given subdomain to create a table of input and output values to graph this subfunction. For this subfunction, the subdomain is 𝑥2; therefore, the value 𝑥=2 is included in the domain.

𝑦=2𝑥+10
𝑥𝑦
26
34
42
50

Next, plot these points onto the same grid as the first subfunction.

Notice that, for the second subfunction, at 𝑥=2, we include a solid point since 2 is included in the subdomain for 𝑦=2𝑥+10.

Lastly, we sketch a line beginning at (2,6) and extending through (5,0), remembering that this line continues indefinitely in that direction.

By graphing this piecewise-defined function, we have shown that only option D correctly represents this function.

Let’s finish by recapping some basic points.

Key Points

  • A piecewise function consists of multiple subfunctions defined over subdomains.
  • A hollow dot on the curve of a function means the function is not defined at this point.
  • A filled-in dot on the curve of a function means the function is defined at this point.
  • To graph a piecewise-defined function:
    • consider each subfunction on its subdomain separately,
    • look at what happens at the endpoints of each subfunction’s domain,
    • graph each subfunction on the same set of axes.

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy.