Unit 1, lesson 9

Piecewise-Defined Functions

How one function can use different formulas on different parts of its domain, how to pick the right formula for an input, and how to read the open dots, closed dots and jumps where the formulas change.

  • Theory part 17
  • Practice part 18
  • Special Kinds of Functions

An electricity bill often charges one rate for the first 100 kilowatt hours of a month and a higher rate for every kilowatt hour after that. No single formula gives the bill, but two simple formulas do, each in charge of its own range of usage. Functions built like this show up in tax brackets, shipping prices and phone plans, and calculus uses them as its standard examples for studying what happens where one formula hands over to the next.

Key terms

Piecewise definition

Definition A piecewise-defined function ff is given by formulas f1,f2,…,fnf_1, f_2, \ldots, f_n, called branches, together with sets of real numbers D1,D2,…,DnD_1, D_2, \ldots, D_n, no two of which share a point, such that each formula fkf_k is defined at every number of DkD_k. The sets are usually described by inequalities, called the conditions. The domain of ff is the union D1∪D2∪⋯∪DnD_1 \cup D_2 \cup \cdots \cup D_n, and for each xx in it

f(x)=fk(x)for the one k with x∈Dk.\begin{gathered} f(x) = f_k(x) \\[0.4em] \text{for the one } k \text{ with } x \in D_k. \end{gathered}

It is written with a brace, one line per branch,

f(x)={f1(x),x∈D1,⋮fn(x),x∈Dn.f(x) = \begin{cases} f_1(x), & x \in D_1, \\ \quad \vdots & \\ f_n(x), & x \in D_n. \end{cases}

A piecewise-defined function is still a single function, with exactly one output for each input in its domain.

In plain words One function, several formulas. Each formula is in charge of its own part of the domain, and the condition next to it tells you which part that is.

Example Suppose electricity costs 0.20 dollars per kilowatt hour for the first 100 kilowatt hours of a month and 0.30 dollars for each kilowatt hour after that. For a usage of xx kilowatt hours with 0≤x≤1000 \le x \le 100, the bill is 0.2x0.2x dollars. For x>100x > 100, the first 100 kilowatt hours cost 2020 dollars and the remaining x−100x - 100 cost 0.30.3 dollars each. So the bill in dollars is

B(x)={0.2x,0≤x≤100,20+0.3(x−100),x>100.B(x) = \begin{cases} 0.2x, \\ \quad 0 \le x \le 100, \\[0.4em] 20 + 0.3(x - 100), \\ \quad x > 100. \end{cases}

A usage of 250 kilowatt hours costs B(250)=20+0.3⋅150=65B(250) = 20 + 0.3 \cdot 150 = 65 dollars. It does not cost 0.3⋅250=750.3 \cdot 250 = 75 dollars, because only the usage above 100 is charged at the higher rate.

Branch domain

Definition The branch domain of a branch is the set DkD_k of inputs for which that branch is used. It consists of the numbers that satisfy the branch’s condition and at which its formula is defined. The formula of a branch gives the value of ff only on its branch domain, even if the formula itself makes sense for other numbers too. The domain of ff is the union of the branch domains, so a number that satisfies a condition but makes that branch’s formula undefined, such as 00 for the formula 1/x1/x with the condition x≤0x \le 0, is not in the domain of ff.

In plain words Each formula works only inside its own territory. Outside it the formula is switched off, whatever it would give.

Example Take

g(x)={1x,x≤−1,x,0≤x≤4.g(x) = \begin{cases} \dfrac{1}{x}, & x \le -1, \\ \sqrt{x}, & 0 \le x \le 4. \end{cases}

The branch domains are (−∞,−1](-\infty, -1] and [0,4][0, 4], so the domain of gg is (−∞,−1]∪[0,4](-\infty, -1] \cup [0, 4]. The number −12-\frac{1}{2} is not in the domain, even though 1/(−12)=−21/(-\frac{1}{2}) = -2 makes sense, and 99 is not in the domain, even though 9=3\sqrt{9} = 3 does. Inside the domain, g(−2)=−12g(-2) = -\frac{1}{2} and g(4)=2g(4) = 2.

Evaluation

Definition To evaluate a piecewise-defined function ff at a number aa, find the branch whose condition aa satisfies, so that a∈Dka \in D_k, and compute f(a)=fk(a)f(a) = f_k(a) with that formula only. If aa satisfies none of the conditions, then aa is not in the domain and f(a)f(a) is undefined.

In plain words First decide which branch you are in by checking the conditions, then compute. Never mix formulas.

Example Let

h(x)={x+3,x<−1,x2,−1≤x≤2,6−x,x>2.h(x) = \begin{cases} x + 3, & x < -1, \\ x^2, & -1 \le x \le 2, \\ 6 - x, & x > 2. \end{cases}

Each input below satisfies exactly one condition.

InputCondition it satisfiesValue
−3-3x<−1x < -1h(−3)=−3+3=0h(-3) = -3 + 3 = 0
−1-1−1≤x≤2-1 \le x \le 2h(−1)=(−1)2=1h(-1) = (-1)^2 = 1
0.50.5−1≤x≤2-1 \le x \le 2h(0.5)=0.52=0.25h(0.5) = 0.5^2 = 0.25
22−1≤x≤2-1 \le x \le 2h(2)=22=4h(2) = 2^2 = 4
55x>2x > 2h(5)=6−5=1h(5) = 6 - 5 = 1

Endpoints

Definition The endpoints of a branch domain that is an interval are the finite numbers at its ends, such as aa and bb for the condition a≤x<ba \le x < b, whether or not the condition includes them. An endpoint where one branch domain ends and the next one begins is called a break point, because the formula in use changes there. At an endpoint cc, a condition either includes cc, written with ≤\le or ≥\ge or a square bracket, or excludes it, written with << or >> or a parenthesis. Since the conditions do not overlap, a break point that lies in the domain of ff is included by exactly one condition, and f(c)f(c) comes from that branch.

In plain words The boundary point between two branches belongs to one side at most. The inequality signs tell you which side, if any, so read them carefully right at the boundary.

Example The function gg defined earlier has endpoints −1-1, 00 and 44 but no break points, since no formula hands over to another at those numbers. The function hh above has break points −1-1 and 22. At −1-1 the condition x<−1x < -1 fails and −1≤x≤2-1 \le x \le 2 holds, so h(−1)=(−1)2=1h(-1) = (-1)^2 = 1. Using the first formula would give −1+3=2-1 + 3 = 2, which is wrong for this hh. Had the conditions been written x≤−1x \le -1 and −1<x≤2-1 < x \le 2, the value would be 22, so moving the equal sign changes the function. At 22 the middle condition includes 22 and x>2x > 2 does not, so h(2)=4h(2) = 4.

Open and closed graph points

Definition To graph a piecewise-defined function, graph each branch formula over its own branch domain only. At an endpoint cc of a branch domain where the formula fkf_k is defined, the point (c,fk(c))(c, f_k(c)) is drawn as a closed (filled) dot if cc belongs to that branch domain, and as an open (hollow) dot if it does not. A closed dot is a point of the graph. An open dot marks a point that the piece comes arbitrarily close to but that this branch does not include. If another branch has a closed dot at the same spot, the point is on the graph after all and is drawn filled.

In plain words A filled dot means the point is on the graph. A hollow dot means the piece runs right up to that point but stops just short of it.

Example For hh from above, here are the ends of each piece.

BranchBranch domainDots
y=x+3y = x + 3(−∞,−1)(-\infty, -1)open dot at (−1,2)(-1, 2)
y=x2y = x^2[−1,2][-1, 2]closed dots at (−1,1)(-1, 1) and (2,4)(2, 4)
y=6−xy = 6 - x(2,∞)(2, \infty)open dot at (2,4)(2, 4)

At x=−1x = -1 the graph has a hollow dot at height 22 and a filled dot at height 11. At x=2x = 2 the hollow dot of the last piece sits exactly on the filled dot of the parabola, so the graph runs through (2,4)(2, 4) without a break.

Jumps

Definition Let cc be a break point of ff such that one formula fLf_L is used on an interval (b,c)(b, c) just to the left of cc and another formula fRf_R is used on an interval (c,d)(c, d) just to the right. Suppose both formulas are defined at cc and their graphs have no breaks near cc, as with polynomials. The graph of ff has a jump at cc if fL(c)≠fR(c)f_L(c) \ne f_R(c), and the size of the jump is

fR(c)−fL(c),f_R(c) - f_L(c),

positive for a step up and negative for a step down. If fL(c)=fR(c)f_L(c) = f_R(c), the two pieces meet and there is no jump. The value f(c)f(c) itself, which comes from whichever condition includes cc, does not decide whether there is a jump.

In plain words Follow the graph from the left up to cc, then from the right up to cc. If you arrive at two different heights, the graph jumps there, and you have to lift your pencil to draw it.

Example At the break point −1-1 of hh, the left formula gives −1+3=2-1 + 3 = 2 and the right formula gives (−1)2=1(-1)^2 = 1. These differ, so hh jumps at −1-1, with size 1−2=−11 - 2 = -1, a step down by 11. At 22 the left formula gives 22=42^2 = 4 and the right formula gives 6−2=46 - 2 = 4, so there is no jump. The electricity bill BB has no jump at 100100 either, since both of its formulas give 2020 there. Calculus describes the two heights at a break point with one-sided limits.

Overlapping and missing branch conditions

Definition The conditions of a piecewise definition should cover every intended input exactly once. If two conditions overlap at an input aa and their formulas give different values there, the rule assigns two outputs to aa and does not define a function. If the formulas agree at every shared input, the rule still defines a function, and removing the shared inputs from one of the conditions brings it to the standard form above, with branch domains that do not overlap. An input that satisfies no condition is not in the domain, even when it lies between two branch domains.

In plain words Two conditions that both claim a point must agree there, or the rule is broken. A point that no condition claims is simply missing from the domain.

Example The rule

k(x)={x+1,x≤2,x2,x≥2k(x) = \begin{cases} x + 1, & x \le 2, \\ x^2, & x \ge 2 \end{cases}

claims x=2x = 2 twice, with outputs 33 and 44, so it is not a function. Changing the second condition to x>2x > 2 repairs it, and then k(2)=3k(2) = 3. The opposite slip is a gap. A rule with the conditions x<0x < 0 and x>0x > 0 says nothing about 00, so 00 is not in its domain. If 00 should be included, one of the two conditions must become x≤0x \le 0 or x≥0x \ge 0.

Check yourself

  1. A courier charges 6 dollars for a parcel of up to 2 kilograms, 10 dollars for more than 2 and up to 5 kilograms, and 15 dollars for more than 5 and up to 20 kilograms. Write the price as a piecewise function S(w)S(w) of the weight ww, find S(2)S(2), S(2.5)S(2.5) and S(5)S(5), and describe the jumps.
Show the answer

The price in dollars is

S(w)={6,0<w≤2,10,2<w≤5,15,5<w≤20.S(w) = \begin{cases} 6, & 0 < w \le 2, \\ 10, & 2 < w \le 5, \\ 15, & 5 < w \le 20. \end{cases}

So S(2)=6S(2) = 6, because 22 satisfies 0<w≤20 < w \le 2, while S(2.5)=10S(2.5) = 10 and S(5)=10S(5) = 10. The graph jumps up by 44 at w=2w = 2, from a closed dot at (2,6)(2, 6) to an open dot at (2,10)(2, 10), and up by 55 at w=5w = 5, from a closed dot at (5,10)(5, 10) to an open dot at (5,15)(5, 15).

  1. Let f(x)=x2f(x) = x^2 for x<1x < 1 and f(x)=5−xf(x) = 5 - x for 1<x≤41 < x \le 4. Find the domain of ff and evaluate f(1)f(1), f(4)f(4) and f(5)f(5) where they are defined.
Show the answer

The branch domains are (−∞,1)(-\infty, 1) and (1,4](1, 4], so the domain is (−∞,1)∪(1,4](-\infty, 1) \cup (1, 4]. The input 11 satisfies neither condition, so f(1)f(1) is undefined, and the graph has open dots at (1,1)(1, 1) and (1,4)(1, 4). The input 44 satisfies 1<x≤41 < x \le 4, so f(4)=5−4=1f(4) = 5 - 4 = 1. The input 55 satisfies no condition, so f(5)f(5) is undefined.

  1. One rule sets p(x)=x2p(x) = x^2 for x≤1x \le 1 and p(x)=2xp(x) = 2x for x≥1x \ge 1. Another sets q(x)=x2q(x) = x^2 for x≤1x \le 1 and q(x)=2x−1q(x) = 2x - 1 for x≥1x \ge 1. Which of them defines a function?
Show the answer

Both rules claim x=1x = 1 twice. For pp the two formulas give 12=11^2 = 1 and 2⋅1=22 \cdot 1 = 2, two different outputs, so pp is not a function. For qq they give 11 and 2⋅1−1=12 \cdot 1 - 1 = 1, the same output, so qq is a function with q(1)=1q(1) = 1, and its graph has no jump at 11.

How this lesson connects