Making a piecewise function continuous
A function is built from different rules on different intervals, and some of the rules hold an unknown constant. How do you choose the constants so each rule meets the next one where it hands over, and when is that impossible?
Where you are 5 in Continuity
When you reach for it
A piecewise function uses one rule on one interval and another rule on the next: a tax bracket, a shipping charge, a water rate. Each rule is usually continuous on its own interval, so the function can break only at the boundaries, where one rule hands over to the next. When a rule holds an unknown constant, asking for continuity at the boundaries gives equations for it.
The simplest case is in Continuous graphs, jumps and holes: joining 4 - x^2 to kx + 6 at x = 2 gave one linear equation and k = -3. This lesson takes harder counts: two constants at two boundaries, a constant inside a square, an exponential or a sine, a piece that reads \displaystyle \frac{0}{0} at its own boundary, and pieces no constant can join. Elnur, Gunay and Aygun work on a city’s tiered water rate, where a new rule must join the old ones at the tier boundaries.
The procedure
Let f use the rule p just left of a boundary c and the rule q just right of it, with f(c) given by whichever rule includes c, or by a line of its own.
Inside a piece there is nothing to solve. On an open interval where one rule holds, f agrees with that rule at every nearby input, and continuity at a point looks only at nearby inputs. So f is continuous there exactly where the rule is (Continuity on an interval). The constants found must not break a piece from the inside.
At a boundary the three conditions become equations. By Continuity at a point, f is continuous at c when f(c) is defined, \lim_{x \to c} f(x) exists, and the two are equal; by One sided limits and when a limit exists, the limit exists when the one-sided limits agree. Each one-sided limit sees only the rule on its side, so continuity at c says
If a rule is continuous at c itself, its one-sided limit is its value there. If it reads \displaystyle \frac{0}{0} at c, the limit must be computed (Limits by algebra: factoring and rationalizing). If a side runs off to infinity, nothing on the other side helps. A value given by one of the two rules makes one equation per boundary; a value on its own line makes two.
The number of answers depends on the kind of equation. Two linear equations in two unknowns usually have one solution, but they can contradict each other (Exercise 4). A constant entering as k^2 gives a quadratic: two, one or no real solutions (The discriminant). A constant inside e^{kx} gives at most one, since e^t takes each positive value once and no other value. A constant inside \sin kx gives none when the target is outside the sine’s range and infinitely many when it is inside, since the sine repeats.
Substituting back is the check: both sides arrive at the same height at every boundary.
Worked examples
Elnur’s three water tiers
Elnur’s city bills a household by its use w, in thousands of gallons per month. The bill in dollars is
Elnur must choose a and b so the bill never jumps: a household using slightly more water than its neighbor should never pay a sudden extra amount. Find a and b, and say what a means.
SolutionEach rule is linear, so only the boundaries 5 and 12 need equations.
At 5. The first rule includes 5, so B(5) = 15 + 2(5) = 25, which is also the left limit. The right limit comes from the middle line: 5a + b. So 5a + b = 25.
At 12. The middle rule includes 12, so B(12) = 12a + b, also the left limit. The right limit is 7(12) - 31 = 53. So 12a + b = 53.
Subtracting the first equation from the second removes b:
The middle rule is 4w + 5. Check: 4(5) + 5 = 25 and 4(12) + 5 = 53. At w = 0, the end of the domain, B is continuous from the right, so B is continuous on [0, \infty).
The constant a is the price of each extra thousand gallons in the middle tier: 4 dollars, between the first tier’s 2 and the third tier’s 7. The two equations say the middle line passes through (5, 25) and (12, 53), and only one line does, of slope \displaystyle \frac{53 - 25}{12 - 5} = 4 (Figure 1).
Gunay’s constant that appears squared
Gunay studies
Find every k that makes g continuous. Then replace -14 by -16 and show that no k works.
SolutionFor each k both rules are lines, so only x = 2 matters. The second rule gives g(2) = 10k - 14, also the right limit; the left limit is 2k^2 - 2. Continuity says
so k = 2 or k = 3. With k = 2 the rules are 4x - 2 and 10x - 14, both 6 at 2; with k = 3 they are 9x - 2 and 15x - 14, both 16 at 2. Two different continuous functions (Figure 2).
With -16 the equation becomes k^2 - 5k + 7 = 0, with discriminant 25 - 28 = -3 < 0: no real k. Completing the square shows how far apart the sides stay. The right value minus the left limit is
which is at most \displaystyle -\frac{3}{2}. The smallest jump, \displaystyle \frac{3}{2}, comes at \displaystyle k = \frac{5}{2}.
Aygun’s exponential piece
Aygun studies
(a) Find every k that makes u continuous. (b) Show that no k works if the second rule is 1 - x^2. (c) Show the same for x^2 - 4, although there the jump can be made as small as you like.
SolutionFor every k, e^{kx} is the exponential of a line, continuous everywhere. Only x = 2 matters.
(a) The left limit is e^{2k} and u(2) = 5. So e^{2k} = 5, 2k = \ln 5, and \displaystyle k = \frac{\ln 5}{2} \approx 0.8047, the only answer because e^t takes the value 5 once.
(b) Now u(2) = 1 - 4 = -3, but e^{2k} > 0. No k works.
(c) Now u(2) = 0, which e^{2k} never equals. Yet the jump e^{2k} tends to 0 as k \to -\infty; with k = -3 it is e^{-6} \approx 0.00248. Every jump can be beaten by a more negative k, so there is no smallest jump.
A sine piece with infinitely many answers
Let
with k > 0. Find every such k that makes s continuous. What changes if the second rule is x + 4?
SolutionOnly x = 1 matters. The left limit is 4\sin k and s(1) = 2, so continuity asks \displaystyle \sin k = \frac{1}{2}. In 0 < k < 2\pi that happens at \displaystyle \frac{\pi}{6} and \displaystyle \frac{5\pi}{6}, and the sine repeats every 2\pi (Solving basic trig equations):
Infinitely many continuous functions. Check \displaystyle k = \frac{5\pi}{6}: \displaystyle 4\sin\frac{5\pi}{6} = 4 \cdot \frac{1}{2} = 2.
With x + 4, continuity would need \displaystyle \sin k = \frac{5}{4}, impossible. The left side arrives at most at height 4, so the jump is at least 1.
A boundary where both formulas read 0/0
Find a and c so that
is continuous at -1.
SolutionAt -1 both bottoms are 0 and both tops are too (3 - 2 - 1 = 0 and a(2 - 2) = 0), so each one-sided limit must be computed.
Left. The top factors as (3x - 1)(x + 1); for x \ne -1 the factor x + 1 cancels, leaving 3x - 1, which tends to 3(-1) - 1 = -4.
Right. Multiplying top and bottom by the conjugate \displaystyle \sqrt{x + 5} + 2, for x > -1,
which tends to \displaystyle \frac{a}{2 + 2} = \frac{a}{4}.
Both one-sided limits must equal the value:
Inside the pieces nothing breaks: on the right the root’s input is positive and the bottom \displaystyle \sqrt{x + 5} + 2 is never 0. Numerically, the left rule gives -4.003 at x = -1.001 and the right rule gives \displaystyle \frac{-16}{\sqrt{4.001} + 2} \approx -3.99975 at x = -0.999 (Figure 3). The value c fills a hole as in Discontinuities and how to remove them, but two formulas must head for the same hole.
When no constant can join the pieces
Show that no k makes either function continuous at 1:
For p. The left limit is k + 1 and p(1) = k + 3. Continuity would need k + 1 = k + 3, that is 1 = 3. At x = 1 the constant enters both sides the same way and cancels, leaving a jump of 2 for every k. A constant joins two pieces only if changing it moves one side relative to the other.
For r. As x \to 1^- the top tends to 3 and the bottom to 0 through negative numbers, so the left limit is -\infty (Infinite limits and vertical asymptotes). Then \lim_{x \to 1} r(x) cannot exist, whatever k is: k moves only the right side, and the left side never arrives.
Boundaries
- Each piece must be continuous on its own open interval. A constant can break a piece from the inside: in \displaystyle \frac{1}{x - k} for x < 0, any k < 0 puts an asymptote inside that piece.
- The one-sided limits at a boundary must be numbers. If a side runs off to infinity or never settles, no constant makes the function continuous there (Example 6).
- Counting equations and unknowns does not settle the answer. Equal counts can give no solution (Exercise 4) or infinitely many; a nonlinear constant can give two, one, none, or infinitely many.
- Continuity matches heights, not directions. Elnur’s bill turns a corner at 5 and 12. Matching slopes too is a separate condition, taken up in Differentiability: corners, cusps and piecewise functions.
- At an end of the domain only one side counts, as at w = 0 for the bill.
Where this goes next
A function joined this way is continuous on a whole interval, so theorems that need an unbroken graph, such as the The extreme value theorem, apply to it. Differential calculus asks more of a join: the rules must also leave the boundary in the same direction, a second equation at each boundary.
Exercises
Two boundaries, two constants
- Let f(x) = x^2 - 3 for x < -1, f(x) = ax + b for -1 \le x \le 3, and f(x) = 15 - x^2 for x > 3. Find a and b so that f is continuous.
- Let g(x) = a\cos x for x \le 0, g(x) = x^2 + b for 0 < x < 2, and g(x) = bx - 1 for x \ge 2. Find a and b so that g is continuous.
- Aygun’s town bills 10 + 3w dollars for 0 \le w \le 4 thousand gallons, cw + d for 4 < w \le 10, and 9w - 38 for w > 10. Find c and d so the bill never jumps, and the bill for 7 thousand gallons.
- Let n(x) = x + 4 for x < -1, n(x) = ax^2 + b for -1 \le x \le 1, and n(x) = 5 - x for x > 1. (a) Show that no a and b make n continuous. (b) Find every pair that works when the last rule is 4 - x.
Constants inside squares, exponentials, logarithms and sines
- Find every k that makes x + k^2 for x < 3 and k(x + 1) + 5 for x \ge 3 one continuous function.
- Let q(x) = x^2 + k^2 for x < 2 and q(x) = kx for x \ge 2. Show that no k makes q continuous, and find the k with the smallest jump.
- Find k so that 2^{kx} for x < 3 and x^2 + 7 for x \ge 3 form a continuous function.
- Let y(x) = \ln(kx) for 0 < x \le 2 and y(x) = x - 1 for x > 2, with k > 0. Find k so that y is continuous.
- Find every k for which \cos(kx) for x < \pi and \sin x for x \ge \pi form a continuous function.
- Show that no k makes 3\sin(kx) for x < 2 and x^2 for x \ge 2 continuous.
Pieces that read 0/0 at the boundary
- Let f(x) = \dfrac{2x^2 - 5x - 3}{x - 3} for x < 3, f(3) = c, and f(x) = kx - 2 for x > 3. Find c and k so that f is continuous at 3.
- Let g(x) = \dfrac{\sin 3x}{x} for x < 0, g(0) = a, and g(x) = b + \cos x for x > 0. Find a and b so that g is continuous at 0.
- Let m(x) = \dfrac{a(x^2 - 1)}{x - 1} for x < 1, m(1) = 6, and m(x) = \dfrac{x^3 - 1}{b(x - 1)} for x > 1. Find a and b so that m is continuous at 1.
When nothing works
- Let r(x) = \dfrac{k}{x - 2} for x < 2 and r(x) = x for x \ge 2. Show that no k makes r continuous at 2. Treat k = 0 separately.
- In Aygun’s town (Exercise 3), Gunay proposes a middle tier of cw dollars with no fixed part. Show that no c keeps the bill free of jumps.
Reasoning
- Let f(x) = p(x) for x < c and f(x) = q(x) for x \ge c, with p and q polynomials. Prove that f is continuous everywhere exactly when p(c) = q(c).
- A middle rule ax + b on [c_1, c_2], with c_1 < c_2, must arrive at L_1 at c_1 and L_2 at c_2. Prove that exactly one pair a, b does this, and explain why Exercise 4 does not contradict it.
- Explain why a constant inside e^{kx}, at a boundary c \ne 0, gives at most one k, while one inside \sin(kx) can give infinitely many. What happens with e^{kx} at c = 0?
- Let f be continuous on [a, c] and g on [c, b], with f(c) = g(c). Prove that h(x) = f(x) for a \le x \le c and h(x) = g(x) for c < x \le b is continuous on [a, b].
- Elnur says: “Once the pieces join, the graph is smooth.” Use Example 1 to show he is wrong.
Answers
- a = 2, b = 0. At -1: -a + b = 1 - 3 = -2. At 3: 3a + b = 15 - 9 = 6.
- a = 5, b = 5. At 0: a\cos 0 = b. At 2: 4 + b = 2b - 1.
- c = 5, d = 2, and 37 dollars. At 4: 4c + d = 22. At 10: 10c + d = 90 - 38 = 52. Then 5(7) + 2 = 37.
- (a) The conditions are a + b = 3 and a + b = 4: the middle rule has the same value at -1 and 1, but the outer rules arrive at different heights. (b) Now the right limit is 3, so every pair with a + b = 3 works, such as a = 1, b = 2.
- \displaystyle k = 2 \pm \sqrt{6}. From 3 + k^2 = 4k + 5, k^2 - 4k - 2 = 0.
- No k; the smallest jump, 3, comes at k = 1. Continuity would need k^2 - 2k + 4 = 0, discriminant -12. The jump is (k - 1)^2 + 3.
- \displaystyle k = \frac{4}{3}. From 2^{3k} = 16 = 2^4.
- \displaystyle k = \frac{e}{2}. The value at 2 is \ln 2k, and the right limit is 1.
- \displaystyle k = n + \frac{1}{2} for every integer n. Continuity needs \cos(k\pi) = \sin\pi = 0, so \displaystyle k\pi = \frac{\pi}{2} + n\pi.
- It would need 3\sin 2k = 4, that is \displaystyle \sin 2k = \frac{4}{3} > 1.
- c = 7, k = 3. For x \ne 3 the rule is \displaystyle \frac{(2x + 1)(x - 3)}{x - 3} = 2x + 1 \to 7, and 3k - 2 = 7.
- a = 3, b = 2. The left limit is \displaystyle 3 \lim \frac{\sin 3x}{3x} = 3 (The squeeze theorem and the limit of sine x over x); the right limit is b + 1.
- a = 3, \displaystyle b = \frac{1}{2}. Left: a(x + 1) \to 2a = 6. Right: \displaystyle \frac{x^2 + x + 1}{b} \to \frac{3}{b} = 6.
- The value at 2 is 2. If k \ne 0, the left limit is -\infty for k > 0 and \infty for k < 0, not a number. If k = 0, the left limit is 0, a jump of size 2.
- At 4 continuity needs 4c = 22, so c = 5.5; at 10 it needs 10c = 52, so c = 5.2. With c = 5.5 the bill jumps at 10, from 55 down to 52 dollars; with c = 5.2 it jumps at 4, from 22 down to 20.8 dollars.
- Away from c, f agrees with p or q on an open interval, so it is continuous. At c the left limit is p(c) and the right limit and value are q(c), since polynomials are continuous; they match exactly when p(c) = q(c).
- The conditions ac_1 + b = L_1 and ac_2 + b = L_2 give a(c_2 - c_1) = L_2 - L_1 with c_2 - c_1 \ne 0, so \displaystyle a = \frac{L_2 - L_1}{c_2 - c_1} and b = L_1 - ac_1: the one line through two points. In Exercise 4 the middle rule ax^2 + b takes equal values at \pm 1, so both equations have the same left side.
- At c \ne 0, e^{kc} = L gives \displaystyle k = \frac{\ln L}{c} when L > 0 and nothing otherwise, since e^t takes each positive value once. \sin(kc) = L with \lvert L \rvert \le 1 has a solution in every period. At c = 0, e^{0} = 1 for every k: all k work if the other side arrives at 1, none otherwise.
- Inside (a, c) or (c, b), h agrees with f or g on an open interval. At a and b, h inherits one-sided continuity from f and g. At c, the left limit is f(c), the right limit is g(c) = f(c), and h(c) = f(c).
- The bill is continuous, but at 5 its slope changes from 2 to 4, a corner (Figure 1), and at 12 from 4 to 7.