# Piecewise Functions

## Piecewise Functions

Hi, and welcome to this video about piecewise functions! In this video, we will explore

- What piecewise functions are
- How piecewise functions are defined
- And how piecewise functions can be used

First, let’s look at the definition of a function. A **function** is a relationship where a single output is assigned to each input.

Many functions belong to **function families** because their equations and graphs all have similar characteristics.

For example, functions in the **linear family** have equations that resemble f of x equals mx plus b and their graphs are straight lines. Functions in the **quadratic family** have equations that look like f of x equals a x squared and their graphs are parabolas.

Piecewise functions are not considered a function family on their own. As the name suggests, they are functions comprised of pieces of other functions.

The first piece we’re going to look at is the absolute value **function**. Functions in the absolute value family have equations that resemble f of x equals the absolute value of x and their graphs all have a characteristic “V” shape. This is the graph and a section of the table of values of f of x equals the absolute value of x :

Instead of a single V, f(x) can also be visualized as pieces of two linear functions. On the left, f of x equals negative x and on the right, f of x equals x.

As we “read” the graph from left to right, we are on the function f of x equals negative x until x=0. At that point, the function definition changes to f of x equals x.

The domain of the absolute value function is all real numbers. Normally, both f of x equals negative x and f of x equals x also have domains of all real numbers, but if we were to graph them together, the graph would look like this and we would no longer have a function.

So each piece needs to be defined on a section of its domain in order to define a piecewise function. If the left function is only defined for negative x-values and the right is only defined for positive x-values (and we put the 0 into one of them – more on that in a minute), we can define this as a single piecewise function.

One way to visualize this is to graph both **linear** functions and erase the sections that are not part of the absolute value function.

Let’s take a quick break and practice describing a couple of piecewise functions in terms of what their pieces look like and where those pieces are defined.

First up is the greatest integer function, f of x equals the floor of x. This is also called the floor function or stair step function.

This function is made up of pieces of constant functions that are 1 unit wide.

Next, we have the sawtooth function, f of x equals x minus the floor of x. This function is also called the castle rim function.

This function is made up of pieces of parallel linear functions that are one unit long

The format for defining piecewise functions has this general form:

There are two criteria for naming piecewise functions:

- Reading the pieces from top-to-bottom in the list corresponds to reading the graph from left-to-right. So the first piece in the list is the left piece on the graph.
- The domains of the pieces must “add up to” the domain of the entire function.

Let’s start by rewriting our absolute value function in this form:

Here’s the list of expressions that define each piece from left to right:

f of x is equal to the subset of minus x, which is an unknown quantity, and x, which is also an unknown quantity.

Now let’s take a minute to consider the domain of each piece.

f of x equals the absolute value of x has a domain of all real numbers. We can input any number we want and get a single output.

But, we have to be careful with our piecewise definition when we consider x=0. Why? Because 0 is a defined point on both pieces, but we only need to include it once.

If we write the function like this:

f of x is equal to the subset of negative x when x is less than zero and x when x is greater than zero

then neither piece includes 0 and the domain is incomplete.

If we write it like this:

f of x is equal to negative x when x is less than or equal to zero and x when x is greater than or equal to zero.

then we are not defining a function, because we’re saying that f(x) equals both -x and x at x=0 (even though the output would technically be the same in this case).

Since 0 is in the domain of both pieces, we simply choose which piece to put it in. Both of these equations correctly define the function:

All of our examples so far have depicted piecewise functions with domains of all real numbers. The pieces do not need to connect and they do not need to extend to plus or minus infinity.

Take a look at this function and try to define it with an equation (and yes that single point is a part of it!):

f of x is equal to x when x is greater than negative seven and less than negative three; one when x is equal to negative 1; square root of x when x is greater than or equal to zero and less than four; and x when x is greater than six and less than or equal to seven.

Like other functions, piecewise functions can be used to tell stories. This is the story of a car journey Bob took last week:

d of t is equal to fifty t when t is greater than or equal to zero and less than or equal to three; one hundred fifty when t is greater than three and less than three point five; twenty-five t plus sixty-two point five when t is greater than or equal to three point five and less than seven point five; two hundred fifty when t is greater than or equal to seven point five and less than eight; and negative sixty-two point five t when t is greater than or equal to eight and less than or equal to twelve

Let’s see how many of these review questions we can answer about Bob’s journey before we go:

How long did the journey last? **12 hrs**

What’s the farthest distance Bob drove from his home? **250 mi**

How long did it take him to get there? **7.5 hrs**

What was Bob doing from 3-3.5 hrs? **not moving**

When did Bob turn toward home? at the **8 hr** mark

When was Bob driving the fastest? from hr 8 to hr 12 he traveled **62.5 mph**

What was Bob’s average speed from 0 to 8 hrs? **31.25 mph**

Thanks for watching, and happy studying!