Piecewise Functions – Definition, Graph & Examples

Piecewise Functions

There are instances where the expression for the functions depends on the given interval of the input values. When this happens, we call these types of functions piecewise-defined functions.

Piecewise functions are defined by different functions throughout the different intervals of the domain.

We actually apply piecewise functions in our lives more than we think so. Tax brackets, estimating our mobile phone plans, and even our salaries (with overtime pay) make use of piecewise functions.

This is why we’ve allotted a special article for this function. In this article, you’ll learn the following:

What is a piecewise function?

To fully understand what piecewise functions are and how we can construct our own piecewise-defined functions, let’s first dive into a deeper understanding of how it works.

Piecewise function definition

A piecewise function is a function that is defined by different formulas or functions for each given interval. It’s also in the name: piece. The function is defined by pieces of functions for each part of the domain.

2x, for x > 0

As can be seen from the example shown above, f(x) is a piecewise function because it is defined uniquely for the three intervals: x > 0, x = 0, and x < 0.

How to read piecewise functions?

Once we have a given piecewise-defined function, we can interpret it by looking at the given intervals. If we take a look at our example, we can read it as:

When given a piecewise function graph, make sure to observe the given intervals where f(x) has varied graphs. But before we try out examples that involve analyzing piecewise function graphs, let’s go ahead and learn how we can evaluate and graph piecewise functions first.

How to solve piecewise functions?

Now that we’ve learned about this unique function, how do we make sure that we return the right value for the function given x? Here are tips to remember when solving for and evaluating piecewise functions:

Let’s say we want to find f(8) using the piecewise function that we’ve shown.

2x, for x > 0

Since 8 is greater than 0, the function we’ll use to evaluate f(8) is f(x) = 2x. Hence, we have f(8) = 2(8) = 16. This also means that f(-6) = -2(-6) = 12 and f(0) = 1.

How to graph piecewise functions?

As we have mentioned before, piecewise functions contain different functions for each of the given intervals. This means that when graphing piecewise functions, expect to graph different functions for each interval as well.

Here are some quick reminders when graphing piecewise functions:

What are the common functions that you may encounter when graphing piecewise functions? Here are some resources, and feel free to check out the links to refresh your knowledge on some of the commonly used graphs:

These are not the only functions that piecewise functions can use, so make sure also to check your textbook’s library of functions whenever you need to. Let’s try graphing the piecewise function given in the first section.

2x, for x > 0

breaking down piecewise functions

Since both are exclusive inequalities, we leave the dot at the origin unfilled. Now, we are left with the condition when x = 0. Since the value is constant at f(x) =1, let’s a plot a point at (0,1).

graphing piecewise functions

This graph returns the final graph for the given piecewise function. From the graph, we can see that f(x) has a domain of and range of (-∞, ∞) and [0, -∞), respectively.

Piecewise Function Examples

We’ve covered all the essential properties and techniques we can use with piecewise functions, so it’s time for us to check our knowledge with these examples!

Example 1

Evaluate the given piecewise function at the given values of x as shown below.

√x , for x > 0

Solution

Example 2

Graph the piecewise function shown below. Using the graph, determine its domain and range.

2x , for x ≠ 0

Solution

For all intervals of x other than when it is equal to 0, f(x) = 2x (which is a linear function). To graph the linear function, we can use two points to connect the line. Just make sure that the two points satisfy y = 2x. Make sure to leave the point of origin unfilled.

graph of a piecewise function

Since f(x) = 1 when x = 0, we plot a filled point at (0,1). The graph above shows the final graph of the piecewise function.

Since the graph covers all values of x, the domain would be all real numbers or (-∞, ∞). The same reasoning applies to the range of functions. Since it extends in both directions, the range of the function is (-, ) in interval notation.

Example 3

Graph the piecewise function shown below. Using the graph, determine its domain and range.

x 2 , for x ≤ 0

Solution

Let’s first break down the three intervals and identify how the graph of function would look like:

Using this information, we can now graph f(x).

parabola and linear graph in a piecewise function

The image above breaks down the three components of the piecewise function. Let’s go ahead and simplify this graph now so that we can analyze it for its domain and range.

domain and range of piecewise function

Since all values of x extend in both directions, the domain would be all real numbers or (-∞, ∞). Since the graph only covers the values of y above the x-axis, the range of the function is [0, ) in interval notation.

Example 4

Spoken word poetry is being held at the nearby cafe. They charge $6 per person for a table of 1 to 5 guests. They also offer a fixed fee of $50 for a table with 6 or more people. Write a function that relates the number of people,x, and the cost of attending the event, f(x).

Solution

Let’s go ahead and break down the problem and find the expression of f(x) for each interval:

We can now summarize this into a piecewise function:

6x, for 1 ≤ x ≤ 5

This piecewise function represents the cost of f(x) for x number of guests.