- Home
- >
- Piecewise Functions – Definition, Graph, and Examples

Contents

# Piecewise Functions – Definition, Graph & Examples

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:

- Definition of the piecewise function.
- Learning how to evaluate piecewise-defined functions at given intervals.
- Graphing and interpreting piecewise functions.

## 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

1, for x = 0

-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 x > 0, f(x) is equal to 2x.
- When x = 0, f(x) is equal to 1.
- When x < 0, f(x) is equal to -2x.

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:

- Double-check where x lies in the given interval.
- Evaluate the value using the corresponding function.

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

2x, for x > 0

1, for x = 0

-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:

- It helps to identify how each function would look like.
- For inclusive intervals (ie x ≥ 0), including the endpoints.
- For exclusive intervals (ie x < 0), exclude the endpoints by using unfilled dots.

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:

- Linear functions such as f(x) = 3x -1, y = 4x, and more.
- Quadratic functions such as y = -3x
^{2}+ 4x, f(x) = 2x^{2}– 1, and more. - Cubic functions such as f(x) = 4x
^{3}+ 1, y = -x^{3}-1, and more.

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

1, for x = 0

-2x, for x < 0

When x > 0 and x < 0, **f(x) returns a linear function**. Find at least two pairs of points that satisfy each function and use them to construct the two linear graphs.

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).

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.

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

5, for x = 0

x/6, for x < 0

a. f(-36)

b. f(0)

c. f(49)

__Solution__

- When x = -36 (or less than 0), the expression for
**f(x)**is**x/6**. Let’s evaluate**f(-36)**using the expression. Hence, we have**f(-36) = -36/6 = -6**. - When x = 0,
**f(x) is a constant**. This means that we have**f(0) = 5**. - When x = 49 (and consequently, greater 0), the expression for
**f(x)**is**√****x**. Let’s evaluate**f(49)**using the expression. Hence, we have**f(49) =****√****49****= 7**.

*Example 2*

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

2x , for x ≠ 0

1, 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.

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

5, for 0 < x < 2

x/2 , for x ≥ 2

__Solution__

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

- When x ≤ 0,
**f(x)**becomes a quadratic function with a parabola that passes through the origin and (-2, 4). Since it only applies for 0 and negative numbers, we will only half of the parabola. - When 0 < x < 2,
**f(x)**will a represent a constant which is a horizontal line passing through**y = 5**. Make sure to leave (0,5) and (2,5) unfilled since they are not part of the solution. - When x ≥ 2,
**f(x)**is a function and will pass through (2, 1) and (6,3).

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

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.

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:

- For a table of 1 to 5 guests, we can express that as 1 ≤ x ≤ 5 in terms of x. Since it would cost each guest $6, the total for
**x**guests is**6x**. - Now, for a table with 6 or more people, we can express the interval as x ≥ 6. For this interval,
**f(x)**will**always be equal to 60**.

We can now summarize this into a piecewise function:

6x, for 1 ≤ x ≤ 5

50, for x ≥ 6

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