- Foundation
- About 13 min
- 5 practice questions
Piecewise functions and equal functions
Read, evaluate and find the range of a function defined by more than one formula, write |x − a| as a piecewise function, and decide when two formulas define the same function.
If something looks wrong, please tell us.
Some functions cannot be written as one single formula. A taxi fare, for example, may be one price for a short trip and a different rule for a longer trip. In mathematics such a rule is a piecewise function: the domain is split into parts, and each part has its own formula. You have already met two such functions, the modulus and the signum. This lesson shows how to read and evaluate them, and how to decide when two different-looking formulas describe the same function.
Reading a piecewise function
A piecewise function looks like f(x) = x + 1 for x < 2, and f(x) = x² for x ≥ 2. To find f(a), first decide which condition a satisfies, then use that formula only. Each x in the domain meets exactly one condition, so the rule still gives one output for each input. That is what makes it a function.
Worked example 1: evaluating
Take f(x) = x + 1 for x < 2 and f(x) = x² for x ≥ 2. Then f(0) = 0 + 1 = 1, because 0 < 2. And f(3) = 9, because 3 ≥ 2. At the joining point, f(2) = 2² = 4, because the condition x ≥ 2 includes 2; the formula x + 1 would have given 3, but it applies only to x < 2. So f(2) + f(0) = 4 + 1 = 5. Always look at the inequality sign at the joining point.
Domain and range of a piecewise function
The domain is the union of the parts. The range is the union of the ranges of the pieces, each taken over its own part. For f(x) = x + 1 when x < 0 and f(x) = x² when x ≥ 0, the first piece gives all values less than 1 (since x + 1 < 1 when x < 0), and the second gives all values in [0, ∞). Together these overlap and cover every real number, so the range is R.
The modulus as a piecewise function
|x − 2| is x − 2 when x ≥ 2 and −(x − 2) = 2 − x when x < 2. For x ≥ 2 the values are in [0, ∞) and for x < 2 the values 2 − x are in (0, ∞), so the range is [0, ∞). Here is the table of a few values.
| x | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| |x − 2| | 2 | 1 | 0 | 1 | 2 |
For a piecewise function, find which condition the input satisfies and use only that formula. The range is the union of the ranges of the pieces. The two pieces are checked at the joining point separately.
Worked example 2: a rule made of two parts
Suppose, purely as an illustration, a taxi charges ₹40 for the first 2 km and ₹12 for every extra km. Then the fare for a trip of d km (d > 0, treating the extra distance as continuous) is C(d) = 40 for 0 < d ≤ 2, and C(d) = 40 + 12(d − 2) for d > 2. For a 5 km trip, d > 2, so C(5) = 40 + 12 × 3 = ₹76. For a 1.5 km trip, C = ₹40. The range of C is [40, ∞), because the smallest fare is 40 and the fare grows without limit as d increases.
When are two functions equal?
Two functions are equal if they have the same domain and give the same output for every input. A formula alone is not enough; the domain matters. Take f(x) = x²/x and g(x) = x. For x ≠ 0, x²/x simplifies to x. But f is not defined at 0 (the denominator is zero), while g(0) = 0. So the domains differ, R − {0} for f and R for g, and the functions are not equal.
Worked example 3: a root of a square
Is √(x²) the same as x? Not for negative x: if x = −3, then √9 = 3, not −3. In fact √(x²) = |x| for every real x. The functions √(x²) and x agree only for x ≥ 0. They have the same formula there but the domain of x is all of R, and the outputs differ for negative numbers.
Key takeaways: a piecewise function uses a different formula on each part of its domain; check which condition the input meets, especially at the joining point. The range is the union of the ranges of the pieces. Two functions are equal only when their domains match and their values match at every input, so simplifying a formula can change its domain.
Check your understanding
-
1. Let f(x) = x + 1 for x < 2 and f(x) = x² for x ≥ 2. What is f(2) + f(0)?
- 4
- 5
- 3
- 6
Show answer
Answer: B. Since 2 ≥ 2, f(2) = 4 (not 2 + 1). Since 0 < 2, f(0) = 1. The sum is 4 + 1 = 5.
-
2. What is the range of f(x) = |x − 2|?
- R
- [2, ∞)
- (0, ∞)
- [0, ∞)
Show answer
Answer: D. |x − 2| is never negative and equals 0 at x = 2, and it takes every larger value. So the range is [0, ∞).
-
3. Suppose, as an illustration, a taxi charges ₹40 for the first 2 km and ₹12 for every extra km. What is the fare for 5 km?
- ₹76
- ₹100
- ₹60
- ₹52
Show answer
Answer: A. The first 2 km cost ₹40 and the remaining 3 km cost 3 × 12 = ₹36. The total is ₹76.
-
4. Are f(x) = x²/x and g(x) = x the same function?
- Yes: x²/x simplifies to x for every real x
- Yes: they agree at every point where both are defined
- No: their domains differ, since f is undefined at 0
- No: f(1) and g(1) have different values
Show answer
Answer: C. f(x) = x²/x is not defined at x = 0, so its domain is R − {0}, while g is defined on all of R. Functions with different domains are not equal, even though f(1) = g(1) = 1.
-
5. For every real x, √(x²) is equal to which expression?
- x
- −x
- x²
- |x|
Show answer
Answer: D. The square root is never negative, so √(x²) = |x|. For x = −3, √9 = 3 = |−3|, while x would give −3.
Sign in to keep track of the lessons you finish.