# 4.6: Piecewise-defined Functions

In certain situations a numerical relationship may follow one pattern of behavior for a while and then exhibit a different kind of behavior. In a situation such as this, it is helpful to use what is known as a piecewise defined function - a function that is defined in pieces.

In the above example of a piecewise defined function, we see that the (y) values for the negative values of (x) are defined differently than the (y) values for the positive values of (x)

Sometimes we are given a graph and need to write a piecewise description of the function it describes.

The piecewise function pictured above could be described as follows:

Exercises 4.6
Sketch a graph for each of the piecewise functions described below.

A piecewise function is usually defined by more than one formula: a fomula for each interval.

What the above says is that if x is smaller than or equal to 2, the formula for the function is f( x ) = -x and if x is greater than 2, the formula is f( x ) = x. It is also important to note that the domain of function f defined above is the set of all the real numbers since f is defined everywhere for all real numbers.

The above function is constant and equal to 2 if x is greater than -3. function f is also constant and equal to -5 if x is less than -3. It can be said that function f is piecewise constant. The domain of f given above is the set of all real numbers except -3: if x = -3 function f is undefined.

Functions involving absolute value are also a good example of piecewise functions.

Using the definition of the absolute value, function f given above can be written

The domain of the above function is the set of all real numbers.

Another example involving absolute vaule.

The above function may be written as

The above function is defined for all real numbers.

Another example involving more than two intervals.

The above function is defined for all real numbers except for values of x in the interval (-2 , 2] and x = 4.

Example 6: f is a function defined by

Find the domain and range of function f and graph it.

Solution to Example 6:

Function f is defined for all real values of x. The domain of f is the set of all real numbers. We will graph it by considering the value of the function in each interval.

In the interval (- inf , -2] the graph of f is a horizontal line y = f(x) = -1 (see formula for this interval above). Also this interval is closed at x = -2 and therefore the graph must show this : see the "closed point" on the graph at x = -2.

In the interval (-2 , + inf) the graph is a horizontal line y = f(x) = 2 (see formula for this interval above). The interval (-2 , + inf) is open at x = -2 and the graph shows this with an "open point". Function f can take only two values: -1 and 2. The range is given by

Example 7: f is a function defined by

Find the domain and range of function f and graph it.

Solution to Example 7:

The domain of f is the set of all real numbers since function f is defined for all real values of x.

In the interval (- inf , 2) the graph of f is a parabola shifted up 1 unit. Also this interval is open at x = 2 and therefore the graph shows an "open point" on the graph at x = 2.

In the interval [2 , + inf) the graph is a line with an x intercept at (3 , 0) and passes through the point (2 , 1). The interval [2 , + inf) is closed at x = 2 and the graph shows a "closed point". From the graph, we can observe that function f can take all real values. The range is given by (- inf, + inf).

Example 8: f is a function defined by

Find the domain and range of function f and graph it.

Solution to Example 8:

The domain of f is the set of all real numbers since function f is defined for all real values of x.

In the interval (- inf , 0) the graph of f is a hyperbola with vertical asymptote at x = 0.

In the interval [0 , + inf) the graph is a decreasing exponential and passes through the point (0 , 1). The interval [0 , + inf) is closed at x = 0 and the graph shows a "closed point".

As x becomes very small, 1 / x approaches zero. As x becomes very large, e -x also approaches zero. Hence the line y = 0 is a horizontal asymptote to the graph of f.

From the graph of f shown below, we can observe that function f can take all real values on (- inf , 0) U (0 , 1] which is the range of function f.

Example 9: f is a function defined by

Find the domain and range of function f and graph it.

Solution to Example 9:

The domain of f is the set of all real numbers.

In the interval (- inf , -1], the graph of f is a horizontal line y = f(x) = -1. Closed point at x = -1 since interval closed at x = -1.

In the interval (-1 , 1] the graph is a horizontal line. There should a closed point at x = 1 but read below.

In the interval (1 , + inf) the graph is the line y = x. There should an open point at x = 1 since the interval is open at x = 1. But a closed point (see above) and an open point at the same location becomes a "normal" point.

From the graph of f shown below, we can observe that function f can take all real values on <-1>U [1 , + inf) which is the range of function f.

More references and links on graphing. Graphing Functions

## SOLUTION: find the range and domain. f(x)=1/x+2

Set the denominator equal to zero. Remember, dividing by 0 is undefined. So if we find values of x that make the denominator zero, then we must exclude them from the domain.

Subtract 2 from both sides

Combine like terms on the right side

Since makes the denominator equal to zero, this means we must exclude from our domain

which in plain English reads: x is the set of all real numbers except

So our domain looks like this in interval notation

Now to find the range, notice that there isn't an x term in the numerator. So if
, there isn't an x value that will satisfy the equation. So in other words, will never be equal to zero. So this means we must take 0 out of our range.

which in plain English reads: y is the set of all real numbers except

So our range looks like this in interval notation

So we can see that at x=-2 there is a gap (the vertical piece is not part of the graph) and at y=0 there is an asymptote. So this verifies our answer.

## Examples

Set up a piecewise function with different pieces below and above zero:

Find the derivative of a piecewise function:

Use pw to enter  and and then for each additional piecewise case:

## 4.6: Piecewise-defined Functions

We have seen many graphs that are expressed as single equations and are continuous over a domain of the Real numbers. We have also seen the "discrete" functions which are comprised of separate unconnected "points". There are also graphs that are defined by "different equations" over different sections of the graphs. These graphs may be continuous, or they may contain "breaks". Because these graphs tend to look like "pieces" glued together to form a graph, they are referred to as " piecewise " functions (piecewise defined functions), or " split-definition " functions.

A piecewise defined function is a function defined by at least two equations ("pieces"), each of which applies to a different part of the domain. Piecewise defined functions can take on a variety of forms. Their "pieces" may be all linear, or a combination of functional forms (such as constant, linear, quadratic, cubic, square root, cube root, exponential, etc.). Due to this diversity, there is no " parent function " for piecewise defined functions. The example below will contain linear, quadratic and constant "pieces".

Notice that each "piece" of the function has a specific constraint.

From x-values of -∞ to -1, the graph is a straight line.

From x-values of -1 to 1, the graph is constant.

The piecewise function shown in this example is continuous (there are no "gaps" or "breaks" in the plotting).

In this example, the domain is all Reals since all x-values have a plotted value.

Still confused about what is happening in these piecewise defined functions?
Try taking a look at each section as a "separate" graph, and grab your scissors!

Piecewise defined functions may be continuous (as seen in the example above), or they may be discontinuous (having breaks, jumps, or holes as seen in the examples below).

Other Examples of Piecewise Defined Functions:

One of the most recognized piecewise defined functions is the absolute value function.

• increasing (0, ∞)
• decreasing (-∞,0)

• absolute/relative min is 0
• no absolute max (graph &rarr ∞ )

x-intercept:
intersects x-axis at (0, 0)
unless domain is altered

y-intercept:
intersects y-axis at (0, 0)
unless domain is altered

Vertex:
the point (0,0)
unless domain is altered

Average rate of change:
is constant on each straight line section (ray) of the graph.

A step function (or staircase function ) is a piecewise function containing all constant "pieces" . The constant pieces are observed across the adjacent intervals of the function, as they change value from one interval to the next. A step function is discontinuous (not continuous). You cannot draw a step function without removing your pencil from your paper.

• notice the resemblance to a set of steps

One of the most famous step functions is the Greatest Integer Function.
The greatest integer function returns the largest integer less than or equal to x, for all real numbers x. In essence, the greatest integer function rounds down a real number to the nearest integer. For example: [2] = 2 [1.5] = 1 [-3.1] = -4 [-6.9] = -7

• you may see some texts using the notation y = [[x]] (double brackets).

## Piecewise Functions Examples

Evaluating a piecewise function adds an extra step to the whole proceedings. We have to decide which piece of the function to plug-and-chug into. Since -3 is less than 2, we use the first function to evaluate x = -3.

The number 2 is our boundary between life, death, and the two pieces of our function. Tie-breakers go to the second function, though.

The second function continues to be used, from 2 onward to infinity—and beyond, according to some space-faring toys.

Now, to graph the function.

To the left of x = 2, f(x) = x + 1. The graph will go right up to, but not touch, f(2) = 2 + 1 = 3. Then f(x) = -2x + 7 to the right of and including x = 2. We can also use the points we evaluated as guides.

### Example 2

Careful, Shmooper. Every other time that we've done a piecewise function, the "if" conditions have started with the negative x-values and then become more positive as we go. That doesn't have to be the case, though. Always read the problem carefully, or you'll commit a terrible math blunder.

When x is less than -2, the function is a straight line at y = 2. At the end of the line, it's an inequality the function doesn't equal 2 at x = -2. Instead, it equals:

The function equals 4x – 4 forever onward to the right after that.

### Example 3

Graph the piecewise function:

We'll just go one piece at a time, graphing each section in turn.

First, we have f(x) = x + 1, right up to, but not including, x = 3.

Then, at x = 3, the function just equals 3. Add a dot to the graph at (3, 3).

Finally, we add in f(x) = x + 2 for all points after x = 3, giving us the full graph.

This is still a function, because every value of x is still associated with one value of y. We just have to do some hunting at x = 3, seeing how it jumps around so much.

Just because a graph looks like it’s a piecewise continuous function, it doesn’t mean that it is. For example, the square wave function is piecewise, and it certainly looks like a piecewise continuous function. However, the function is not continuous at the integers, so it isn’t an example of this type of function.

## How to Classify Discontinuities

Using the graph shown below, identify and classify each point of discontinuity.

Step 1

The table below lists the location ($x$-value) of each discontinuity, and the type of discontinuity.

Note that the discontinuity at $x=-7$ is both removable (the function value is different from the one-sided limit value) and an endpoint (since the graph is not defined to the left of $x=-7$ ).

##### Example 2

Using the tables below, what type of discontinuity seems to exist at $x = 5$ ?

$egin & hline 4.9 & 8.15 4.99 & 8.015 4.999 & 8.0015 4.9999 & 8.00015 4.99999 & 8.000015 end$

$egin & hline 5.1 & 2.4 5.01 & 2.43 5.001 & 2.403 5.0001& 2.4003 5.00001 & 2.40003 end$

The table on the left tells us $limlimits_f(x) approx 8$

The table on the right tells us $limlimits_f(x) approx 2.4$

The tables lead us to believe the one-sided limits are different, so we conclude the function likely has a jump discontinuity at $x = 5$ .

##### Example 3

Is the function below continuous at its transition point? If not, identify the type of discontinuity occurring there.

Identify the transition point(s).

The transition point is at $x = 1$ since this is where the function transitions from one formula to the next.

Determine the left-hand limit at the transition point.

$displaystylelim_ f(x) = displaystylelim_ x^2 = 1^2 = 1$

Determine the right-hand limit at the transition point.

$displaystylelim_ f(x) = displaystylelim_ (x+ 3) = 1 + 3 = 4$

Since the one-sided limits are different, the function has a jump discontinuity at $x = 1$ .

##### Example 4

Is the function below continuous at x = 4 ? If not, identify the type of discontinuity occurring there.

Examine the left-hand limit.

$displaystylelim_ f(x) = displaystylelim_ sqrt x = sqrt <4>= 2$

Examine the right-hand limit.

$displaystylelim_ f(x) = displaystylelim_ (6-x) = 6 -4 = 2$

The limit exists, and the function exists, but they have different values. The function has a removable discontinuity at $x = 4$ .

##### Example 5

Without graphing, determine the type of discontinuity the function below has at $x = 3$ .

The function is undefined at $x = 3$, so there is a discontinuity at this point. To determine the type, we will need to evaluate the limit as $x$ approaches 3.

Since the function has a $frac 0 0$ form at $x = 3$ , we need to find and divide out the common factors in the numerator and denominator.

Evaluate the limit of the simpler function as $x$ approaches 3.

Since the limit exists, but the function value does not, we know the function has is a removable discontinuity at $x = 3$ .

##### Example 6

Without graphing, determine the type of discontinuity the function below has at $x = -1$ .

Since we have division by zero, the function doesn't exist at $x = -1$ . But, the $frac n 0$ form tells us the function is becoming infinitely large as $x$ approaches -1.

Note: In order to determine if the limit is infinite, we would need to know which direction the function is going as $x$ approached -1. But for the purposes of classifying the discontinuity, it's enough to know the function becomes infinitely large.