Piecewise functions are often used in algebra and calculus to describe behavior that does not follow a single function for an entire interval. They are sometimes called “hybrid functions”, which gives us a hint about their nature.

So, what is a piecewise function? **A piecewise function is defined by multiple functions, one for each part of a domain. A piecewise function may or may not be continuous or differentiable. A piecewise function may have an inverse if it is one-to-one. It may also have extrema (maximum or minimum values), including at its endpoints.**

Of course, a piecewise function can have two, three, or more different parts – the key is that each part is defined on a different interval (there is no overlap).

In this article, we’ll talk about piecewise functions and answer some common questions about them. We’ll also take a look at some examples to make the concepts clear.

Let’s get started.

## What Is A Piecewise Function?

A piecewise function has two or more different parts, each of which is defined by a separate function on an interval in the domain.

### Example 1: A Piecewise Function With Two Parts

Consider the piecewise function defined by:

**f(x) = 2x for x >= 0****f(x) = x**^{2}for x < 0

You can see the graph of this function below.

The domain of this piecewise function is the entire set of real numbers.

This function is linear on the interval x >= 0 (defined by f(x) = 2x) and quadratic on the interval x < 0 (defined by f(x) = x^{2}).

### Example 2: A Piecewise Function With Three Parts

Consider the piecewise function defined by:

**f(x) = x**^{3}for -3 <= x <= 0**f(x) = x for 0 < x <= 2****f(x) = 2 for x > 2**

You can see the graph of this function below.

The domain of this piecewise function is the entire set of real numbers.

This function is cubic on the interval [-3, 0] (defined by f(x) = x^{3}), linear on the interval (0, 2] (defined by f(x) = x), and constant on the interval x > 2 (defined by f(x) = 2).

### Is Absolute Value A Piecewise Function?

We can define absolute value as a piecewise function. Instead of f(x) = |x| for all x in the real numbers, we can use the equivalent piecewise function:

**f(x) = -x for x <= 0****f(x) = x for x > 0**

You can see the graph of this function below.

The domain of this piecewise function is the entire set of real numbers.

This function is linear on the interval x <= 0 (defined by f(x) = -x) and linear on the interval x > 0 (defined by f(x) = x).

### How To Graph A Piecewise Function

To graph a piecewise function, look at each function individually and graph it from the left endpoint (if applicable) to the right endpoint (if applicable).

Be sure to pay attention to the inequality symbols to determine the interval. For a strict inequality (< or >), we use an open circle at the endpoint, and for an inclusive inequality (<= or >=), we use a closed circle at the endpoint.

#### Example: Graphing A Piecewise Function

Consider the piecewise function defined by:

**f(x) = x + 3 for -2 <= x <= 1****f(x) = -2x – 4 for 1 < x <= 5**

First, we look at the function f(x) = x + 3. This is a linear function, and the endpoints are x = -2 (left) and x = 1 (right).

The inequality symbols are inclusive, so we have an open circle for both.

Next, we look at the function f(x) = -2x – 4. This is a linear function, and the endpoints are x = 1 (left) and x = 5 (right).

The inequality symbol at the left is strict, so we use an open circle at x = 1. The inequality symbol at the right is inclusive, so we use a closed circle at x = 5.

[graph]

Note that this function is not continuous at x = 1, where the left and right intervals meet.

### Can Piecewise Functions Intersect?

The parts of a single piecewise function do not intersect or overlap. The reason is that each part of the piecewise function should have its own interval in the domain, which should not overlap with the interval of other parts.

One good reason for this is that derivatives might not be well defined if there is an overlap. Another good reason is that we may end up with a piecewise relation that is not a function!

#### Example: A Piecewise Relation That Is Not A Function

Consider the piecewise relation defined by:

**f(x) = x for -2 <= x <= 2****f(x) = 3x for 0 < x <= 4**

You can see the graph of this relation below.

Note that there is an overlap between the two intervals: (0, 2] is contained in both. Also note that the function can have two y-values for a single x-value within this interval.

For example, at x = 1, we get f(1) = 1 for the first part of the function, and f(1) = 3(1) = 3 for the second part of the function.

Since we don’t know which part of the function to use, there is ambiguity in the output for the input x = 1. A function can have only one output for a given input, so this relation is not a function.

### Can Piecewise Functions Be One-To-One?

Piecewise functions can be one to one, but not all of them are. To find out if a piecewise function is one to one, we would apply the horizontal line test to its graph.

#### Example 1: A Piecewise Function That Is One-To-One

Consider the piecewise function defined by:

**f(x) = 2x for x >= 0****f(x) = -x**^{2}for x < 0

You can see the graph of this function below.

Note that the function is nonnegative for x >= 0 and negative for x < 0. There is also no horizontal line that intersects the graph more than once.

So, this piecewise function is one-to-one.

#### Example 2: A Piecewise Function That Is Not One-To-One

The absolute value function is a piecewise function that is not one to one. Recall the definition:

**f(x) = -x for x <= 0****f(x) = x for x > 0**

You can see the graph of this function below.

Any horizontal line y = b, where b > 0, will intersect the graph at two places: the points (b, b) and (-b, b). Since there is a horizontal line that intersects the graph at more than one point, it is not a one-to-one function.

### Can A Piecewise Function Have An Inverse?

A piecewise function can have an inverse if it is one-to-one. Remember that you would need to find the inverse of each part of the piecewise function to find the inverse piecewise function.

#### Example: A Piecewise Function With An Inverse

Consider the piecewise function defined by:

**f(x) = x**^{3}for x >= -1**f(x) = 2x + 1 for x < -1**

You can see the graph of this function below.

You can see that the graph passes the horizontal line test, so the function is one-to-one. To find its inverse, we take the inverse of each part of the function.

For f(x) = x^{3}, the inverse function is f^{-1}(x) = x^{1/3} (defined for x >= -1)

For f(x) = 2x + 1, the inverse function is f^{-1}(x) = (x – 1)/2 (defined for x < -1).

So, the inverse of the original piecewise function is:

**f(x) = x**^{1/3}for x >= -1**f(x) = (x – 1)/2 for x < -1**

You can see the graph of this inverse function below.

### Can A Piecewise Function Be Even Or Odd?

A piecewise function can be even, odd, or neither.

#### Example 1: A Piecewise Function That Is Even

For example, the absolute value function that we saw earlier is piecewise and even, since f(-x) = |-x| = |x| = f(x) for all real numbers x (you can see the graph below).

#### Example 2: A Piecewise Function That Is Odd

On the other hand, the following piecewise function is odd:

**f(x) = x**^{2}, x <= 0**f(x) = -x**^{2}, x > 0

You can see the graph of this function below.

**For x < 0, we have f(-x) = -(-x)**^{2}= -x^{2}= -f(x).**For x > 0, we have f(-x) = (-x)**^{2}= x^{2}= -(-x^{2}) = -f(x)**For x = 0, we have f(-0) = f(0) = 0**^{2}= 0 = -0 = -f(0)

This means that f(x) is odd.

#### Example 3: A Piecewise Function That Is Neither Even Nor Odd

Consider the piecewise function defined by:

**f(x) = 2x for x >= 0****f(x) = x**^{2}for x < 0

You can see the graph of this function below.

Note that f(-1) = (-1)^{2} = 1, while f(1) = 2(1) = 2 and –f(1) = -2. This means that the function f(x) is neither even nor odd.

### Do Piecewise Functions Have Asymptotes?

Piecewise functions can still have asymptotes: both vertical and horizontal.

#### Example 1: Piecewise Function With A Vertical Asymptote

Consider the piecewise function defined by:

**f(x) = 1/x for x >= 0****f(x) = 1/x**^{2}for x < 0

You can see the graph of this function below.

The graph has a vertical asymptote at x = 0 (both sides of the graph approach positive infinity as x approaches zero).

#### Example 2: Piecewise Function With A Horizontal Asymptote

Consider the piecewise function defined by:

**f(x) = 1 for x >= 0****f(x) = x / (2x – 1) for x < 0**

You can see the graph of this function below.

The graph has a horizontal asymptote at y = ½ (as x approaches negative infinity, f(x) approaches 1/2).

### Do Piecewise Functions Have Extrema?

Piecewise functions can have extrema – both maximums and minimums, local and global.

#### Example: Piecewise Function With Extrema

Consider the piecewise function defined by:

**f(x) = -x**^{2}for x >= -2**f(x) = (x + 4)**^{2}for x < -2

You can see the graph of this function below.

The function has a local maximum at x = 0 (the right part of the function) and a local minimum at x = -4 (left part of the function). Each of these points is the vertex of a parabola.

### Can Piecewise Functions Be Continuous?

A piecewise function can be continuous if:

**Each function that makes up the piecewise function is continuous****The limits and function values agree at the endpoints of intervals**

#### Example 1: A Piecewise Function That Is Continuous

Consider the piecewise function defined by:

**f(x) = 2x for x >= 0****f(x) = x**^{2}for x < 0

You can see the graph of this function below.

At the endpoint x = 0, we get:

**A left-hand limit of 0**^{2}= 0**A right-hand limit of 2(0) = 0****A function value of f(0) = 2(0) = 0**

Since the left hand limit agrees with the right hand limit, the limit exists at x = 0. Since the limit at x = 0 is equal to the function value at x = 0, f(x) is continuous at x = 0.

#### Example 2: A Piecewise Function That Is Not Continuous

Consider the piecewise function defined by:

**f(x) = x + 3 for -2 <= x <= 1****f(x) = -2x – 4 for 1 < x <= 5**

You can see the graph of this function below.

At the endpoint x = 1, we get:

**A left-hand limit of 1 + 3 = 4****A right-hand limit of -2(1) – 4 = -6****A function value of f(1) = 1 + 3 = 4**

Since the left hand limit does not agree with the right hand limit, the limit does not exist at x = 1. Since the limit at x = 1 does not exist, the function is not continuous at x = 1.

### Can Piecewise Functions Be Differentiable?

Piecewise functions can be differentiable in some cases. A piecewise function that is differentiable is also continuous.

#### Example 1: A Piecewise Function That Is Differentiable

Consider the following piecewise function from earlier:

**f(x) = x**^{2}, x <= 0**f(x) = -x**^{2}, x > 0

You can see the graph of this function below.

Both of the functions are differentiable, but we must still check the behavior at the endpoint x = 0.

The piecewise derivative function would be:

**f’(x) = 2x, x <= 0****f’(x) = -2x, x > 0**

Both of these functions are continuous, and at the endpoint x = 0, the limit is zero, as is the function value.

So, this piecewise function is differentiable.

#### Example 2: A Piecewise Function That Is Not Differentiable

Recall the absolute value function f(x) = |x| from earlier. Its piecewise definition is:

**f(x) = -x for x <= 0****f(x) = x for x > 0**

You can see the graph of this function below.

The derivatives on the left and right sides do not agree at x = 0, since:

**f’(x) = -1 for x <= 0****f’(x) = 1 for x > 0**

So, this function is not differentiable at x = 0.

## Conclusion

Now you know what piecewise functions are. You have also seen some examples and learned the answers to some common questions.

You can learn about cases when a limit is zero, negative, or infinite in my article here.

I hope you found this article helpful. If so, please share it with someone who can use the information.

Don’t forget to subscribe to my YouTube channel & get updates on new math videos!

~Jonathon