To get the best deal on Tutoring, call 1-855-666-7440 (Toll Free)
Top

Piecewise Function

In mathematics, we often come across with the word ''function". A mathematical function is a type of relation which gives a definite value called output corresponding to a specified input value. A function does have only one single output for each input. Usually the notation f(x) is used to denote a function. There are different types of functions in mathematics. Piecewise function is one of them. We are going to learn piecewise function in this chapter.

A piecewise function is a function whose definition changes piecewise i.e. depending on different values of the independent variable. Say if y = f(x), here, y is the dependent variable and x is the independent variable.

The piecewise function is called so because its graph represents different pieces in it. From the piecewise defined function, we can see that the function can be continuous or not continuous and the function may be differentiable or not differentiable at the junction of different subsets of the domain. This is because the function changes piecewise in the domain for different subsets of the domain. But in general, a piecewise function is a discrete function. Let us go ahead in this page below and learn more about piecewise functions and their properties.

Related Calculators
Calculator Functions Calculate Exponential Function
Calculate Inverse Function calculating gamma function
 

Definition

Back to Top
Imagine you are driving a car long distance on various highways. Due to various reasons like speed restrictions, traffic conditions etc. you will be driving at different speeds at different intervals. In other words, the distances you cover at different intervals of time. The distance is a function of time with the speed as slope. Since the speed varies at different intervals of time, the over all distance will consist of different distance-time functions from one time interval to another. That is the over all distance will be a piece wise function of time.

Similarly in algebra, some functions vary differently in different intervals of the variable and such functions are called piece wise function.

Consider a function ${f}(x)$ over a selected domain of $x_{n}$ divided into n intervals(need not be equal intervals).
If the type of function at any interval is different from that in the succeeding interval, then the over all function is defined as follows.

${f}(x)$ = $f_{1}(x),\ when \ 0< x\leq x_{1}$
= $f_{2}(x),\ when \ x_{1}< x\leq x_{2}$
= $f_{3}(x),\ when \ x_{2}< x\leq x_{3}$
-------------------------------------------------------------
= $f_{n}(x),\ when \ x_(n-1)< x\leq x_{n}$

Here, the domain of the function is the set of all possible values of x and the range of the function is the values of y which we have to find by substituting the values of x in the given function.

Please note that we have arbitrarily selected the inequality symbol but in actual it may be different depending on the direction of the each function piece. However, the right side inequality symbol of any piece and the left side inequality symbol of the next piece must not be same.

Graphing Piecewise Defined Functions:


For the graph of the piecewise function, we must specify each piece of the function and the values of x to use for that particular piece. For graphing the function, we can use the dotted line. As per the definition of the given function, we can draw the graph in the form of pieces and to understand the behavior of the end point. For this, first we have to mark the x-axis for x values or independent values and y-axis or dependent values. Make a table for the values of independent values and dependent values which represents domain and range respectively. Lastly, with the help of these values, draw the graph of the function.

Limits of Piecewise Functions

Back to Top
To find the limit of any piecewise function, we have to find both of the limits as right hand side limit as well as left hand side limit. For this lets take an example:

$y = f(x) = \begin{Bmatrix}
1 &when x = 0 \\
x & when 0 < x and x < 1 \\
2 & when x = 1\\
x^{2} &when 1 < x and x < 2 \\
3 & when x = 2
\end{Bmatrix}$

The limiting value when x approaches to the left side of the 0, i.e. x $\rightarrow$ 0- , then

$\lim_{x \rightarrow 0^{-}}f(x)$ = undefined and f(0) = 1.

The limiting value when x approaches to the right side of the 0, i.e. x $\rightarrow$ 0+ , then

$\lim_{x \rightarrow 0^{+}}f(x)$ = 0 and f(0) = 1.

The limiting value when x approaches to 0 from the either side , then

$\lim_{x \rightarrow 0}f(x)$ = undefined and f(0) = 1.

The limiting value when x approaches to 1 from the left side i.e. x $\rightarrow$ 1- , then

$\lim_{x \rightarrow 1^{-}}f(x)$ = 1 and f(1) = 2.

The limiting value when x approaches to 1 from the right side i.e. x $\rightarrow$ 1+ , then

$\lim_{x \rightarrow 1^{+}}f(x)$ = 1 and f(1) = 2.

The limiting value when x approaches to 1 from the either side , then

$\lim_{x \rightarrow 1}f(x)$ = 1 and f(1) = 2.

Piecewise Linear Functions

Back to Top
In the above definition of a piece wise function if $f_{1}(x),f_{2}(x)...... f_{n}(x)$ are all linear functions then the over all function is called piecewise linear function. The real life example described in the beginning is a piecewise linear function.

In piecewise linear function, each function piece varies at a constant rate, that is with a constant slopes. The graph of a piecewise linear function, therefore, will have different line segments at different intervals.

Steps

Back to Top
We can write a piecewise function, if we know the graph of any piecewise function. So, with the help of the graph of any function, we can find the given equation or given definition of the function and able to write it in the form of pieces.

Let us suppose, that we have a graph of any function, which is given below:
Writing Piecewise Functions

In the above graph, 
1) We can see to the left of the point x = 1, the line which is the part of the graph is passing through (-1, 0) and (1,2).

2) The equation of that line is y = x + 1.

3) Including x = 1 and to the right of the graph is the part of the line which passing through (1, 0) and (3,2).

4) Hence, we can see that the equation of that line is y = x - 1.



So, the piecewise function of the graph is
$y = f(x) = \left\{\begin{matrix}
x+1 &if x < 1 \\
x-1 &if x \geq 1
\end{matrix}\right.$

Since there is an open circle at (1, 2), the function y = f(x) = x + 1 does not apply to x = 1. But, there is a solid circle at the point (1,0). So, the function y = f(x) = x - 1 does apply to x = 1.

Continuity of Piecewise Functions

Back to Top
While studying the continuity of the piecewise function, we have to know about the continuity of each piece of the function. For this, we can follow the below steps:

1) If g(x) is the function defined on some interval and f(x) is defined on it, then both the functions f(x) and g(x) follows some continuity properties except the end point on that interval.

2) The point at where the two pieces come together is called the end point. The function f(x) is continuous at that point if both the limits of the function agree and equals to the value of the function f at that point.

Absolute Value 

Back to Top
If we have an absolute function in terms of pieces or steps, then that type of function is called the absolute value piecewise function. The piecewise function is the set of instructions in which we define two or more than two values for specific intervals within the domain. If f(x) is an absolute value function, then we can write it as If(x)I. So, any function in this form of If(x)I is called the absolute function and if it can be expressed in terms of pieces, then it is called the absolute value piecewise function.

Graphing Piecewise Functions

Back to Top
To graph a linear piecewise function, make a table of values for the given functions at the vertex points and plot those points. Join all the points by line segments.

Let us consider the following example,

${s}(t)$ = $60t \ when \ 0< x\leq 1$
= $75t, \ when \ 1< t\leq 3$
= $80t, \ when \ 3< t\leq 4$
= $40t,\ when \ 4< t\leq 5$

The table is made as follows.

t
s(t)
0
0
1 60
3 210
4 290
5 330

The ordered pairs that are to be plotted in the graph are, (0, 0), (1, 60), (3, 210), (4, 290) and (5, 330).

The graph of this piecewise function is shown below.

Graphing Piecewise Functions

Piecewise Functions Word Problems

Back to Top
Given below are some of the word problems on piecewise functions.

Practice Problem

Question: In June 2004, a gas plant has the following rate schedule for natural gas usage in double family residences as:
Monthly Customer Charge 7.00 dollars
Distribution Charge
1st 20 therms 0.301/ therm
Next 40 therms 0.121/ therms
Over 40 therms 0.027 / therms
Gas Supply Charge 0.82 / therms
  1. What is the charge for using 50 therms?
  2. What is the charge for using 100 therms?
  3. Construct a function that gives the monthly charge C for x therms of gas?
  4. After calculating all these things graph the function.

Piecewise Functions Examples

Back to Top

Given below are some of the examples on piecewise functions.

Solved Example

Question: f(x) = {(-x - 3 if x <= -3), (x + 3 if -3 < x < 0), (-2x + 3 if 0 <= x < 3), (x - 6 if x >= 3)}
Solution:

As we can see the domain of the function is $(- \infty , \infty)$ on the real axis. And, the subsets of the domain are shown above. By plotting the function, we can see the piecewise nature of the function in a better way.

Different region or the different definitions of the function are plotted in different colors. So, it is easy to notice the different subsets and different definitions of the function in the corresponding subset.

The red line plotted in the figure corresponds to the region x <= -3 f(x) = -x - 3

The orange corresponds to the region -3

The green corresponds to the region 0 <= x < 3 f(x) = -2x + 3

The blue corresponds to the region x >= 3 f(x) = x - 6

The nature of the piecewise function is discussed below.

Check the continuity of the functions at the points x = -3, 0, 3

f(x) at x = -3

f(x) = -x - 3 = -(-3) - 3 = 0

f(x) = x + 3 = -3 + 3 = 0

f(x) at x = 0

f(x) = x + 3 = 0 + 3 = 3

f(x) = -2x + 3 = 0 + 3 = 3

f(x) at x = 3

f(x) = -2x + 3 = -6 + 3 = -3

f(x) = x - 6 = 3 - 6 = -3

From the plot, we can see the function is continuous but the function is not differentiable. This is because, the function is not smooth at the points x = -3, 0, 3



Piecewise Functions Practice Problems

Back to Top

Given below are some of the practice problems on piecewise function. This will help you to understand the concept of piecewise function and improve your practice over piecewise function.

Practice Problems

Question 1: Plot the piecewise function and check the continuity and differentiability of the function.
$f(x) = {(\cos(x) \text{if} x<=0),(3x \text{if} x>0)}$
Question 2: Plot the piecewise function and check the continuity and differentiability of the function.
$f(x) = {(\cos(x) \text{if} x<= 0),(1 + x^2 \text{if} x>=0)}$
Related Topics
Math Help Online Online Math Tutor
*AP and SAT are registered trademarks of the College Board.