Lesson Explainer: Piecewise Functions | Nagwa Lesson Explainer: Piecewise Functions | Nagwa

Lesson Explainer: Piecewise Functions Mathematics

In this explainer, we will learn how to identify, write, and evaluate a piecewise function.

A piecewise function is a function for which different rules are used to find the function’s output over different intervals of the function’s domain. One well-known function that we can write as a piecewise function is the absolute value function, 𝑓(𝑥)=|𝑥|. The graph of 𝑦=𝑓(𝑥) for this function is shown below.

We can see that when 𝑥 is less than 0, the graph of the function is a straight line with a slope of 1, and when 𝑥 is greater than 0, it is a straight line with a slope of 1. When rewriting 𝑓(𝑥) as a piecewise function, the equation of each of these lines is called a subfunction, and the interval over which each line is defined is called a subdomain. Each subdomain is written as an inequality.

Notice that the two lines meet at the origin. At the origin, only one subfunction can be used to find the piecewise function’s output, so we could either say that

  • 𝑓(𝑥)=𝑥 on the subdomain 𝑥0,
  • 𝑓(𝑥)=𝑥 on the subdomain 𝑥>0,

or that

  • 𝑓(𝑥)=𝑥 on the subdomain 𝑥<0,
  • 𝑓(𝑥)=𝑥 on the subdomain 𝑥0.

The equation of a piecewise function is written with a curly bracket to indicate that it is comprised of more than one subfunction, so we could rewrite 𝑓(𝑥)=|𝑥| either as 𝑓(𝑥)=𝑥𝑥0,𝑥𝑥>0,ifif or as 𝑓(𝑥)=𝑥𝑥<0,𝑥𝑥0.ifif

In either case, we could use what we have written to evaluate the function for a specific input value, but when the allocation is arbitrary, it is conventional to include the left endpoint, and exclude the right endpoint, from the subfunctions. Say that we have rewritten 𝑓(𝑥)=|𝑥| in the conventional way as 𝑓(𝑥)=𝑥𝑥<0,𝑥𝑥0,ifif and we want to find the value of 𝑓(10). To decide which subfunction will give us this value, we must determine the subdomain in which 10 lies. We know that 10 lies in the subdomain 𝑥<0, and 𝑓(𝑥)=𝑥 when 𝑥<0.

Evaluating this subfunction at 𝑥=10 gives us 𝑓(10)=(10)=10, which is the same value of 𝑓(10) we would have arrived at had we evaluated the absolute value function as it was originally written.

Definition: Piecewise Function

A piecewise function is a function that consists of multiple subfunctions, with each subfunction defined over an interval of the main function’s domain, called a subdomain. The union of the subdomains is the domain of the piecewise function.

The equation of a piecewise function is written with a curly bracket to indicate that it is comprised of more than one subfunction. An example of a piecewise function is 𝑓(𝑥)=𝑥𝑥<0,𝑥𝑥0,ifif where 𝑓(𝑥)=𝑥 on the subdomain 𝑥<0, and 𝑓(𝑥)=𝑥 on the subdomain 𝑥0.

Sometimes the different parts of a piecewise function’s graph do not meet at a point. For example, consider the following graph of 𝑦=𝑓(𝑥) for a piecewise function. The function’s equation is also shown.

𝑓(𝑥)=34𝑥+14<𝑥<4,2𝑥+84𝑥7.ifif

A closed circle indicates that the function is defined at the point at which it appears, while an open circle indicates that the function is not defined. This means the 𝑥-coordinates of the points where the closed circles appear will be included in the subdomain of the corresponding subfunction, while the 𝑥-coordinates of the points where the open circles appear will not be included.

In our graph, the line segment representing the first subfunction has open circles at both endpoints, so the 𝑥-coordinates of these endpoints will not be included in this subfunction’s subdomain. Thus, the subdomain of the first subfunction, given as an inequality, is 4<𝑥<4.

The line segment representing the second subfunction has closed circles at both endpoints, so the 𝑥-coordinates of these endpoints will be included in this subfunction’s subdomain. Thus, the subdomain of the second subfunction, given as an inequality, is 4𝑥7.

We can find the union of the two subdomains to determine the domain of the main function. Since neither 4 nor 4 are included in the first subfunction’s subdomain, and both 4 and 7 are included in the second subfunction’s subdomain, the main function is defined at both 𝑥=4 and 𝑥=7, but not at 𝑥=4. Therefore, the domain of the main function, given as an inequality, is 4<𝑥7.

Let’s now look at some examples of evaluating piecewise functions at specific values.

Example 1: Evaluating a Piecewise Function at a Given Point

Given the function 𝑓(𝑥)=6𝑥2𝑥<6,9𝑥16𝑥8,5𝑥+4𝑥>8,ififif find the value of 𝑓(4).

Answer

We can see that the function we have been given, 𝑓(𝑥), is a piecewise function. Recall that a piecewise function is a function that consists of multiple subfunctions, with each subfunction defined over an interval of the main function’s domain, called a subdomain.

We want to evaluate this piecewise function at 𝑥=4. To do this, we need to determine which subdomain, if any, 4 is in. The main function has three subdomains given as inequalities:

  • 𝑥<6,
  • 6𝑥8,
  • 𝑥>8.

We can see that 4 is in the subdomain 6𝑥8, and we know that 𝑓(𝑥)=9𝑥1 when 6𝑥8.

Now that we know which subfunction gives the function’s output, we can evaluate this subfunction at 𝑥=4. Doing so, we get 𝑓(4)=9(4)1=9(16)1=1441=145.

In conclusion, we can say that the value of 𝑓(4) for our piecewise function is 145.

In the example that follows, we will evaluate a piecewise function using the concept of composite functions.

Example 2: Evaluating a Point of a Piecewise Function

Consider the function 𝑓(𝑥)=𝑥+4𝑥>4,2𝑥1𝑥4,3𝑥<1.ififif

Find 𝑓[𝑓(2)].

Answer

In this problem, we are given the piecewise function 𝑓(𝑥). Remember, a piecewise function is a function that consists of multiple subfunctions, with each subfunction defined over an interval of the main function’s domain, called a subdomain.

Here, we are asked to determine 𝑓[𝑓(2)]. The function 𝑓[𝑓(𝑥)] is a composite function, which can alternatively be written as (𝑓𝑓)(𝑥). To evaluate 𝑓[𝑓(𝑥)] at a specific value of 𝑥, we first evaluate 𝑓(𝑥) at this value of 𝑥. Then we evaluate 𝑓(𝑥) again, this time using the output we just got as our input value.

Thus, to determine 𝑓[𝑓(2)], we need to start by finding 𝑓(2). We can see that 2 is in the subdomain 1𝑥4, and we know that 𝑓(𝑥)=2𝑥 when 1𝑥4.

Evaluating this subfunction at 𝑥=2, we get 𝑓(2)=2(2)=4.

The function 𝑓[𝑓(𝑥)] evaluated at 𝑥=2 is 𝑓[𝑓(2)]. So, since we know that 𝑓(2)=4, this tells us that 𝑓[𝑓(2)]=𝑓(4).

To decide which subfunction gives the function’s output for an input value of 4, we must determine which subdomain, if any, 4 is in. We can see that it is in the subdomain 1𝑥4, and we know for values of 𝑥 in this subdomain, 𝑓(𝑥)=2𝑥.

Evaluating this subfunction at 𝑥=4 tells us that 𝑓(4)=2(4)=8.

Therefore, we know that the value of 𝑓[𝑓(2)] for our piecewise function is 8.

Next, we will evaluate a piecewise function for three different input values so that we can complete a table of values.

Example 3: Completing a Table of Values for a Piecewise Function

Find the missing table values for 𝑔(𝑥)=2𝑥<2,32𝑥<3,2𝑥3.ififif

𝑥303
𝑔(𝑥)

Answer

We are given the piecewise function 𝑔(𝑥). Recall that a piecewise function is a function that consists of multiple subfunctions, with each subfunction defined over an interval of the main function’s domain, called a subdomain. To fill in the missing values in the table, we must decide which subfunction to use for three different input values, or three different values of 𝑥: 3, 0, and 3.

To do this, we need to determine which subdomains, if any, 3, 0, and 3 are in. The main function has three subdomains given as inequalities:

  • 𝑥<2,
  • 2𝑥<3,
  • 𝑥3.

Let’s begin by deciding which subfunction to use when the input value is 3. Since the subdomain 𝑥<2 is the one in which 𝑥=3 is included, we know the subfunction that gives the function’s output for this input value. Thus, we should evaluate the subfunction 𝑔(𝑥)=2 at 𝑥=3 to get 𝑔(3)=2.

Recall that the negative exponent rule tell us that 𝑎=1𝑎 for any real number 𝑛.

This means that we can rewrite 2 as 2=12=18, so the first missing value in our table is 18.

Next, let’s decide which subfunction to use when the input value is 0. We can see that the subdomain 2𝑥<3 is the one in which 𝑥=0 is included, so we also know what the subfunction for this input value is. We should therefore evaluate the subfunction 𝑔(𝑥)=3 at 𝑥=0 to get 𝑔(0)=3.

Remember, the zero exponent rule states that any nonzero base raised to the power 0 is equal to 1. That is, 𝑎=1 when 𝑎0. This means that we can rewrite 𝑔(0)=3 as 𝑔(0)=1, so the second missing value in our table is 1.

Finally, let’s decide which subfunction to use when the input value is 3. Since the subdomain is 𝑥3 when 𝑥=3, we can also determine the subfunction for this input value. Substituting 3 into the subfunction 𝑔(𝑥)=2 for 𝑥, we get 𝑔(3)=2=8, so the third missing value in our table is 8. Now that we know the three missing values in our table, we can fill in the blank cells so that the table appears as follows:

𝑥303
𝑔(𝑥)1818

We will now turn our attention to graphs. First, we will evaluate a piecewise function for a given input value by using the graph of the function.

Example 4: Evaluating a Point from a Graph of a Piecewise Function

Determine 𝑓(0) using the graph below.

Answer

We can see that our graph is that of a piecewise function, or a function that consists of multiple subfunctions, with each subfunction defined over an interval of the main function’s domain, called a subdomain. This is because the graph consists of five different line segments with either closed circles or open circles at the ends, as well as two points with coordinates of (0,4) and (8,6).

Recall that a closed circle indicates that the function is defined at the point at which it appears, while an open circle indicates that the function is not defined.

We want to evaluate the function that the graph represents at 𝑥=0. To do this, we can see where the graph intersects the line 𝑥=0.

We can see that the line 𝑥=0 passes through the open circle at (0,8) and (0,4). Since the function is not defined at (0,8), we know that the value of 𝑓(0) must be the 𝑦-coordinate of the point (0,4), which is 4.

Finally, we will look at an example of how to evaluate a piecewise function when the given input value is not included in any of the main function’s subdomains.

Example 5: Evaluating a Point from a Graph of a Piecewise Function

Determine 𝑓(1).

Answer

Because our graph consists of parts of two different curves, we know that it is the graph of a piecewise function, or a function that consists of multiple subfunctions, with each subfunction defined over an interval of the main function’s domain, called a subdomain.

We can see that the two curves are joined by an open circle at the point (1,5). Remember that an open circle indicates that the function is not defined at the point at which it appears.

We want to evaluate the function that the graph represents at 𝑥=1. To do this, we can see where the graph intersects the line 𝑥=1.

We can see that the line 𝑥=1 passes through only the open circle at (1,5). Since the function is not defined at (1,5), we know that 1 is not in the function’s domain, so the value of 𝑓(1) is undefined.

Note:

Even though our function is undefined at (1,5), it is defined at various other points. For example, we can see from our graph that the curve on the left passes through the point (1,1), and that the curve on the right passes through the point (5,1). This means that our function is defined for input values of both 1 and 5. In fact, it is defined for an infinite number of input values, because an infinite number of points lie on each of the two curves.

Now let’s finish by recapping some key points.

Key Points

  • A piecewise function is a function that consists of multiple subfunctions, with each subfunction defined over an interval of the main function’s domain, called a subdomain. The union of the subdomains is the domain of the piecewise function.
  • To decide which rule to use when evaluating a piecewise function for a specific input value, we must determine the subdomain in which the input value lies.
  • The graph of a piecewise function can sometimes be used to evaluate the function for a specific input value.
  • A closed circle on a graph indicates that the 𝑥-coordinate of the point at which it appears is included in the domain of the function that the graph represents, while an open circle indicates that the 𝑥-coordinate of the point is not included.
  • When an input value is not included in any of the subdomains of a piecewise function, the function is undefined at that input value.

Download the Nagwa Classes App

Attend sessions, chat with your teacher and class, and access class-specific questions. Download Nagwa Classes app today!

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