Piecewise Functions

Bookmark added to your notes.
View Notes

Piecewise Function Definition

A piecewise-defined function is one that is described not by a one (single) equation, but by two or more. Take into account the following function definition:

\[F(x) = \left\{\begin{matrix}-2x, -1 \leq x < 0\\X^{2}, 0 \leq x < 1 \end{matrix}\right.\]

Above mentioned piecewise equation is an example of an equation for piecewise function defined, which states that the function definition is different on different parts of its domain. For the piecewise-defined function above, the domain is [−1, 1][−1, 1], but the function definition on [−1, 0][−1, 0] is distinct from that of function definition on [0, 1][0, 1].

How to Find the Domain of a Piecewise Function

Let’s learn to find the domain and range of the piecewise function 

Consider the function: y = x² if x < 0, y = x + 2 if 0 ≤  x ≤ 3, y = 4 if x > 3?

Domain: (−∞, ∞)

Range: (0, ∞) 


It is ideal to begin graphing piecewise functions by first thoroughly reading the "if" statements and you will then possibly shorten the chance of making an error by doing so.

Having said that, we have:

\[\left\{\begin{matrix} y = x^{2} \text{ if x < 0} \\ y = x + 2 \text{ if 0 }\leq x \leq 3 \\ y = 4 \text{ if x }> 3\end{matrix}\right.\]

It is quite crucial to consider the greater/less than or equal to signs because two points on the same domain will make it such that the graph is not a function. Nonetheless:

  • When No Restrictions in the ‘if’ Statements

y = x² is a simple parabola, and you probably know that it begins at the origin, (0, 0), and stretches out indefinitely in both directions. But, our limitation is all x-values less than (<) 0, thus we will only draw the left half of the graph, and leave an open circle at the point (0, 0), as the limitation is less than 0, and does not include 0.

Our next graph is a normal linear function moved upwards by two but only appears from 0 to 3 and includes both, so we will draw the graph from 0 to 3, with shaded circles on both 0 and 3.

The ultimate function is the simplest function, a constant function of y = 4, where there is only a horizontal line at the value of 4 on the y-axis, but only after 3 on the x-axis, because of our limitation.

Let's see how it would appear without the limitation:

(Image will be uploaded soon)

  • When Adding Restrictions in the ‘if’ Statements

Now, let’s find the domain and range of a piecewise function adding the restrictions in the ‘if’ statements:

Like we said earlier, the quadratic just looks like less than zero (<0), the linear only looks like from 0 to 3, and the constant only appears followed by 3, thus:

Domain: (−∞, ∞)

Range: (0, ∞)

Our domain is all real numbers because of our x-values being continuous along the x-axis, seeing that we have one shaded circle on the linear function at x = 0, and one shaded circle on the linear function at x = 3. The constant function continues endlessly to the right thus, despite the functions visually stopping, the graph still continues, therefore, all real numbers.

Our range begins at 0, but doesn't include it, and goes until infinity because of the graph not going below y = 0, and the lowest point being the quadratic not touching the x-axis at the origin, (0, 0), and stretches out endlessly upwards.

(Image will be uploaded soon)

Solved Examples

Solving piecewise functions requires plotting graphs. Let’s understand how to deal with a piecewise-defined function


Consider the function described as follows.

\[\left\{\begin{matrix} y = x + 2 \text{ if }x < 0 \\ 2 \text{ for }0 \leq x \leq 1 \\ -x + 3 \text{ for }x > 1\end{matrix}\right.\]


In this example, the function is piecewise-linear, since each of the three parts of the graph is a line.

Piecewise-defined functions can also contain discontinuities ("jumps"). The function in the example below consist of discontinuities at x = −2x = −2 and x = 2.


Graph the function described as given below:

\[\left\{\begin{matrix} y = 1/2x^{2} \text{ if }x < -2 \\ 0 \text{ for }-2 \leq x < 2 \\ 1/2x^{2} \text{ for }x \leq 2\end{matrix}\right.\]

Note that we take the help of small white circles in the graph in order to indicate that the endpoint of a curve is not included in the graph, and solid dots to show endpoints that are included.


Graph the function defined below.

y = logx for  0<x<1

1/(x−2)     for  x≥1


Negative values of x and 0 are excluded in the domain since the 1st function, logx, is not defined for those values. The value x=2 is not included in the domain seeing that the 2nd function is undefined for that value (it contains a vertical asymptote there). Thus, the domain of this function is {x | 0<x<2}∪{x | x>2}. This can be illustrated using interval notation as (0,2)∪(2,∞).

FAQ (Frequently Asked Questions)

Q1. What is Piecewise?

Answer: In terms of a number of discrete intervals, sets, or pieces, these are piecewise continuous functions. The function of the piecewise equation is described on a sequence of intervals. A common example of the piecewise function is the absolute value.

X = { -x  for x < 0}

{0   for x = 0}

{x   for x > 0}

Piecewise functions are executed in the Wolfram language (multi-paradigm computational language) as Piecewise [{val1, cond1} {val2, cond2} {val3, cond3}, {val4, cond4,…}]

Additional piecewise functions include the triangle function, rectangle function, and Heaviside step function.

Commas and Semicolons are sometimes used at the end of either the right or the left column, with specific usage. The terms "if" and "for" are often used in the right column, as is "otherwise" for the final case.

Q2. What is a Constant Function?

Answer: A constant function is a linear function whose range has only one element no matter the number of elements of the domain.

Consider the given function f(x) = 3

There is no variable (on the right side).

This implies that it will always produce an output equivalent to 3, irrespective of what input value we give to it.

Thus, this specific function is a constant function and is of the form:

f(x) = k, where k = constant.