Piecewise Definitions of Functions

Video · + 1 min read

(Video) Piecewise Functions

by Eddie Woo

Here's a video by Eddie Woo where he explains piecewise functions and how they work.

Piecewise Functions

A piecewise function is a function that is broken up into two or more pieces, where each piece has a condition.

An example of a piecewise function would be: F(x)={2x;x≥0x;x<0F(x)=\begin{cases}2x;&x\ge0\\x;&x<0\end{cases} This tells us that for any value above or equal to x=0x=0, you graph the line 2x2x. Any value below x=0x=0 you graph the line xx.

Graph of piecewise function above (y=x and y=2x)

Absolute value is actually a piecewise function. You can write it as: y=∣x∣={x;x≥0−x;x<0y=|x|=\begin{cases}x;&x\ge0\\-x;&x<0\end{cases}

A real world example of a piecewise function would be the price of a parking garage. When you go to a parking garage they have a sign that says the first hour is free. Then hours one to two is $2\$2. Then two to four dollars is $6\$6. And so on. Graphically, it would look like:

Piecewise Graph

This kind of graph has discontinuities. The graph is not continuous. There's jumps to get from one piece to the next.

Interactive · 2 questions

Background

When learning about functions, we have covered a bunch of different types of functions. From quadratic to cubic functions, from even and odd functions to function transformations, we have learned a lot about different types of functions and function characteristics. The common factor amongst everything we've learned so far is that these are largely continuous functions. In the next few lessons, we'll learn about piecewise and step functions, that are slightly different from what you've seen in the past. These are discontinuous functions.

What are Piecewise Functions?

Let's break down the term "piecewise function".

piecewise = in piecesfunction = every x has a unique y value\begin{align} \text{piecewise = in pieces} \\ \text{function = every x has a unique y value} \\ \end{align}

So, if we think about it, a piecewise function is a function that is made up of a bunch of broken pieces. Sounds confusing, doesn't it? Let's look at a graph of a piecewise function.

Example of piecewise function graph

Made using Desmos

At first glance, this graph looks really weird! There are a bunch of different colored lines that aren't connected. There are a couple of random points on the graph. There is no discernible pattern to this function!

Notice how I called it a function - it is important to emphasize that the above graph is a function. While it is not a function that we traditionally think of as a function, it follows all the key characteristics of a function. We defined a function as having a unique xx value for every yy value. That means there is a 1:11:1 correspondence. The main difference is that different parts of the domain has a different corresponding equation. That's okay! We want to pay special attention to the domain of each equation. The domain of the entire function is all real numbers.

Let's break down the equations for this piecewise function.

{−xx≤−10.5+14x−1<x<12x1≤x<22+2xx≥2\begin{cases} -x & x \leq -1 \\ 0.5+\frac{1}{4}x & -1<x<1 \\ 2x & 1\leq x<2 \\ 2+\frac{2}{x} & x\geq 2 \end{cases}

Let's look at the red equation\color{red} {\text{red equation}} first. The domain of this part of the function is x≤−1x\leq-1. That means that this piece of the function will go from (−∞,−1](-\infty, -1]. Notice that there is a bracket, as the 11 is included in this piece of the function. We know that because there is a point at (−1,1)(-1,1). The equation of this piece of the function is y=−xy=-x. So, we can see the graphed function for y=−xy=-x, but only to the left of x=−1x=-1.

Now, let's look at the blue equation\color{blue} {\text{blue equation}}. The domain of this piece of the function is −1<x<1-1<x<1, which we can also write as (−1,1)(-1,1). A very important thing to note: the endpoints of this piece of the function are not inclusive. Think about it - if the endpoints were inclusive, then this function would have two yy values each at x=−1x=-1 and at x=1x=1, which would therefore not make it a function. The equation for the blue equation is y=0.5+14xy=0.5 + \frac14x.

Next up, we have the green equation\color{green} {\text{green equation}}. The domain of this part of the function is 1≤x<21\leq x<2. We can write this domain as [1,2)[1,2), inclusive for 11. There is a point on the graph at (1,2)(1,2). The equation for the green line is y=2xy=2x.

Lastly, we are going to talk about the purple equation\color{purple} {\text{purple equation}}. The domain for this function is x≥2x \geq 2, also seen as [2,∞)[2, \infty). So, this equation will go off positively until infinity. Because the domain is inclusive at the endpoint, there is also a point at (2,3)(2,3). The equation of the purple equation is y=2+2xy=2 + \frac{2}{x}.

Let's do some practice to check your understanding.

Evaluate the piecewise function at x=−2x=-2.

Choose one answer

Illustrated · 1 min

Piecewise Functions

Next in our lessons of types of functions, we will learn about piecewise functions.

Piecewise functions: functions that are broken up into pieces!

Image source: by Anusha Rahman

A piecewise function is a function that has different rules (or formulas) for different parts of its domain. Think of it like a “rulebook” that changes depending on the situation. For example, one rule might apply when the input is less than 00, and another rule applies when the input is greater than or equal to 00. The function is written in parts, separated in conditions.

Let's look at an example. Say you're given the following piecewise function:

f(x)=x+2,x<0f(x)=2x,x≥0\begin{align} f(x) = x + 2 , x<0 \\ f(x) = 2x , x \geq 0 \\ \end{align}

This means that if you plug in a number less than 00, you use the first rule, x+2x+2. If you plug in a number 00 or greater, you use the second rule, 2x2x. Piecewise functions are useful when you want to describe situations that change depending on the input!

This concept can be a bit tricky when you first learn it, so let's look at some common mistakes students make, so you can avoid making them in the future!

  • Not following the conditions carefully: Each part of a piecewise function has specific conditions, and it’s important to use the correct rule based on those conditions.
  • Forgetting to include all parts: If a piecewise function has multiple rules, you need to write each rule with its condition. Missing a part or leaving out a condition can make the function incomplete and cause confusion.
  • Not understanding endpoints: If there’s a piecewise function with different rules at an endpoint (like at x=0x=0 in the above example), students sometimes forget to check if the endpoint is included in one rule or the other. Double-check whether the function includes the endpoint (using ≤\leq or ≥\geq) or if it's excluded << or >>.

Type a concept, like “slope” or “photosynthesis”.

↑ ↓ to choose · Enter to openSearch explanations and problems