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π‘₯+1βˆ’4<π‘₯<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π‘₯βˆ’1βˆ’6≀π‘₯≀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=βˆ’144βˆ’1=βˆ’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,3βˆ’2≀π‘₯<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.

Join Nagwa Classes

Attend live sessions on Nagwa Classes to boost your learning with guidance and advice from an expert teacher!

  • Interactive Sessions
  • Chat & Messaging
  • Realistic Exam Questions

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