A piecewise function is a function that is defined using different formulas or rules for different intervals or conditions of the input value.
Instead of one single equation working for all values of x, the function changes its rule depending on the value of x.
The piecewise function can be written as:
f(x) =\begin{cases} f_1(x),& \text{if } x < a \\ f_2(x),& \text{if } a \leq x < b \\ f_3(x),& \text{if } b \leq x \end{cases}
where,
f1(x), f2(x), and f3(x) are three different functions, and
a, b, and c are some real numbers.
The above expression for piecewise function means that for x less than a, the function takes on the value of f1(x), for x between a and b, it takes on the value of f2(x), and for x greater than or equal to b, it takes on the value of f3(x).
Domain and Range
Domain and Range of a piecewise function can be calculated using the domain and range of the individual pieces and taking the union of that range and domains.
Example: Find the Range and Domain of function f(x) which is defined as follows: f(x) = \begin{cases} x, & x<1 \\ 2, & 1 \leq x \leq 5\\ x^2, & x>5 \end{cases}
As the function is defined for all the real numbers, so its domain is R if is defined for some portion of R then that portion becomes its domain.
Range of function, for x<2, f(x) = x, thus range for this part is x<2
For 2 ≤ x ≤ 5, f(x) = 2, thus its range is 2 as it is a constant function for this interval.
For x > 5, f(x) = x2, f(5) = 25 and x2 is continuous and increasing function for x > 0, thus range is x>25.
Now, the union of all the ranges is {x<2} U {2} U {x>25} = (-∞, 2] U (25, ∞)
Piecewise Function Graph
To graph the Piecewise Function, we just need to graph the function individually for all the different intervals it is defined.
Example: Plot the graph of the function defined as follows:
As the domain of the function is the complete set of real numbers.
Now, for the first piece of graph for x < -1, is given as f(x) = x .So the graph of a function for x < -1 is a straight line with a slope of 1 that passes through the origin.
For the second piece of the graph for -1 ≤ x ≤ 2, the given function is a constant function as f(x) = 2. So the graph of a function for -1 ≤ x ≤ 2 is again a straight horizontal line which is at a 2 unit distance from the x-axis.
For the third piece of the graph for x > 2, the given function is a parabolic curve that opens upwards and x2 is a increasing and continuous function, so the graph starts at the point (2, 4) goes in the upward direction as parabolic curve.
Common Types of Piecewise Functions
There are some famous examples of piecewise functions:
1. Modulus Function: The modulus functionf(x) = ∣x∣ , also known as the absolute value function, is defined as:
The graph of absolute value function is as follows:
2. Floor Function: The floor function also called the greatest integer function, gives the largest integer less than or equal to x. The domain for this function is all the real numbers R while the range of this function is all the integers Z.
Example: ⌊4.7⌋ = 4 , ⌊−2.3⌋ = −3
The graph of the floor function appears as a step function, with flat segments at each integer and jumps at every whole number:
3. Ceiling Function: This function returns the smallest successive integer. The ceiling function of a real number x is the least integer that is greater than or equal to the given number x. The domain for this function is R and range Z.
Example: ⌈3.5⌉ = 4
4. Unit Step Function: A step function has different constant values on different intervals. It used a lot in Signals and systems studies. It is defined as,
This function has no value at x = 0. It is called a step function because, at t = 0, it takes a step from 0 to 1. The domain for this function is R - {0} and range {0,1}.
Piecewise Continuous Function
A Piecewise Continuous Function is a function that is continuous across its entire domain i.e., each piece of the function is continuous itself and all the intersection points are the same for each piece so where each piece ends another piece of function starts from there in the graph.
Example:
f(x) = \begin{cases} x^2,& x < 0\\ 2x,& x \geq 0\end{cases}
This function is continuous across the entire domain because the limit of f(x) as x approaches 0 from the left (for x < 0) is equal to the limit of f(x) as x approaches 0 from the right (For x ≥ 0), and both limits are equal to 0. Therefore, f(x) is continuous at x = 0.
Piecewise Continuous Function Graph
The graph of a piecewise continuous function often resembles a series of connected segments, each representing the function's behavior within a specific interval. At the points where intervals meet, the function may experience jumps, breaks, or other types of discontinuities.
at x = -2, x < 0 so the f(-2) = -2. at x = 10, x > 0, so f(10) = 102 = 100.
Example 2: An arcade game charges the following prices depending on the length of time:
Up to 6 minutes costs Rs.10
Over 6 and up to 15 minutes costs Rs.15
Over 15 minutes costs Rs.15 plus Rs.1 per minute above 15 minutes
Represent this as a piecewise function and tell the price charged if Anil played the game for 13 minutes and Raju played for 20 minutes.
These kind of prices charges can be represented as,
f(t)= \begin{cases} 10, & \text{if } t\leq 6\\ 15 & \text{if } t \leq 15 \text{ and } t \gt 6 \\ 15 + 1(t - 15), & \text{otherwise} \end{cases}
at x = 13, f(13) = Rs.15 and x = 20, f(20 ) = 15 + 1( 20 – 15) = 20.
Practice Problem
Question 1: Given the piecewise function f(x) = \begin{cases} x^2, & \text{if } x \leq 2 \\ 3x - 1, & \text{if } x > 2 \end{cases}. Find f(0)
Question 2: Evaluate the piecewise function g(x) = \begin{cases} 2x + 1, & \text{if } x < 0 \\ x^2, & \text{if } x \geq 0 \end{cases} at x = 3.
Question 3: Determine the domain of the piecewise function h(x) = \begin{cases} \sqrt{x}, & \text{if } x \geq 0 \\ \frac{1}{x}, & \text{if } x < 0 \end{cases}
Question 4: Find the value of k(2) for the piecewise functionk(x) = \begin{cases} x^3, & \text{if } x \leq 1 \\ x^2, & \text{if } x > 1 \end{cases}
Question 5: Determine the range of the piecewise function n(x) = \begin{cases} x^2, & \text{if } x \leq 2 \\ 3, & \text{if } x > 2 \end{cases}