math.wiki
Calculus › Limits › The intermediate value theorem
Open on the map
Calculus 1

The intermediate value theorem

A continuous function is negative at one end of an interval and positive at the other. Must it be zero somewhere in between, and if it must, how do you find where?

Where you are 11 in Limits

When you reach for it

Most equations cannot be solved by rearranging. No algebra isolates x in x\,2^x = 5 or in \ln x = 3 - x. Two questions remain: is there a solution at all, and where is it? The first is answered by a theorem about continuous functions; the second by using that theorem again and again.

The intermediate value theorem. Let f be continuous on the closed interval [a, b], and let N be any number between f(a) and f(b). Then there is at least one number c in [a, b] with f(c) = N.

In pictures: the graph of f runs without a break from (a, f(a)) to (b, f(b)), and a horizontal line y = N between those heights is below one end and above the other, so the graph must meet it. The theorem is stated here without proof. Its proof rests on the completeness of the real numbers, the fact that the number line has no gaps (every set of reals with an upper bound has a least upper bound), and belongs to a course in analysis.

The most used case takes N = 0. If f is continuous on [a, b] and f(a) and f(b) have opposite signs, then f has a zero strictly between a and b: the theorem gives a zero in [a, b], and neither end is a zero because f is not zero there. This is how one shows that an equation has a solution, a root, without finding it.

Notice what the theorem does not say. It promises at least one c, not exactly one, and it says nothing about where in [a, b] the number c lies.

The procedure

Showing that a value is reached. An equation g(x) = k(x) is first turned into a question about one function: its solutions are the zeros of F(x) = g(x) - k(x). The theorem then needs two things, and both must be said. The first is continuity on the whole closed interval. Polynomials, roots, exponentials, logarithms, sine and cosine are continuous wherever they are defined, and sums, differences, products, compositions and quotients with a nonzero denominator of continuous functions are continuous (Continuity at a point, Continuity on an interval). The second is the two end values, computed, with the target N between them. Without continuity the conclusion can fail, as Example 5 shows.

Trapping a root by halving. Suppose f is continuous on [a, b] with f(a) < 0 < f(b) (the case f(a) > 0 > f(b) is the same with the signs swapped). Look at the midpoint \displaystyle m = \frac{a + b}{2}. If f(m) = 0, the root is found. Otherwise f(m) has the opposite sign to exactly one of f(a) and f(b), and the theorem, applied to that half, says a root lies in it, because f is still continuous on any smaller closed interval. Keep that half and repeat. This is the bisection method.

Each step halves the length of the interval that holds a root. After n steps the length is

\frac{b - a}{2^n},

and the midpoint of the last interval lies within half of that, \dfrac{b - a}{2^{n + 1}}, of a root. The left ends never move left, the right ends never move right, and the gap between them shrinks toward 0, so both ends close in on a single number c (completeness again). Since f is negative at every left end and positive at every right end, continuity forces f(c) \le 0 and f(c) \ge 0, so f(c) = 0.

Worked examples

Example 1

A height other than zero

Show that the equation x\,2^x = 5 has a solution between 1 and 2.

Solution

Let h(x) = x\,2^x. It is the product of the polynomial x and the exponential 2^x, both continuous everywhere, so h is continuous on [1, 2]. The ends give

\begin{aligned} h(1) &= 1 \cdot 2 = 2, \\ h(2) &= 2 \cdot 4 = 8. \end{aligned}

The target N = 5 lies between 2 and 8, so by the intermediate value theorem there is a number c in [1, 2] with h(c) = 5. It is not an end, since h(1) and h(2) are not 5, so 1 < c < 2.

1 2 2 5 8 x y
y = 5
c
(1, 2)
(2, 8)
Figure 1The graph of h(x) = x\,2^x is unbroken from height 2 to height 8, so it must cross the line y = 5.

One midpoint narrows it: h(1.5) = 1.5 \cdot 2^{1.5} \approx 4.243 < 5, so the theorem on [1.5, 2] places c there. In fact c \approx 1.623, and it is the only solution in [1, 2], since both factors of h are positive and increasing there.

Example 2

A root of a cubic, and only one

Show that x^3 + x - 3 = 0 has exactly one real solution, and that it lies between 1 and 2.

Solution

Let f(x) = x^3 + x - 3. A polynomial is continuous everywhere. At the ends,

\begin{aligned} f(1) &= 1 + 1 - 3 = -1 < 0, \\ f(2) &= 8 + 2 - 3 = 7 > 0. \end{aligned}

The signs are opposite, so the theorem with N = 0 gives a root c with 1 < c < 2.

The theorem gives at least one root; “exactly one” needs a separate argument. If u < v, then u^3 < v^3 (cubing keeps order) and u < v, so adding, u^3 + u < v^3 + v and f(u) < f(v). An increasing function takes the value 0 at most once, so this root is the only real one.

Example 3

Trapping the root by halving

Use bisection on [1, 2] to place the root of f(x) = x^3 + x - 3 in an interval of length less than 0.01.

Solution

After n halvings of an interval of length 1 the length is \displaystyle \frac{1}{2^n}. Since 2^6 = 64 and 2^7 = 128, the first length below 0.01 comes at n = 7. In the table, f(a) < 0 and f(b) > 0 on every row; the sign of f(m) decides which end moves to m.

abmf(m)
121.51.875
11.51.250.2031
11.251.125-0.4512
1.1251.251.1875-0.1379
1.18751.251.218750.0290
1.18751.218751.203125-0.0553
1.2031251.218751.2109375-0.0134
1.5 2 x y
(1, -1)
(2, 7)
[1, 2]
[1, 1.5]
[1, 1.25]
[1.125, 1.25]
Figure 2Each halving keeps the half on which f(x) = x^3 + x - 3 changes sign, so the root stays trapped.

In the first row f(1.5) > 0, so b moves to 1.5; in the third, f(1.125) < 0, so a moves instead. After the seventh the root lies in

[1.2109375,\ 1.21875],

an interval of length \displaystyle \frac{1}{128} \approx 0.0078. Its midpoint 1.21484375 is within \displaystyle \frac{1}{256} \approx 0.0039 of the root. More steps give c \approx 1.21341.

Example 4

Where two graphs cross

Sonam wants the point where the graphs of y = \ln x and y = 3 - x cross. Show that they cross for some x in [2, 3], take three bisection steps, and find how many steps from [2, 3] would guarantee a midpoint within 0.001 of the crossing.

Solution

The graphs cross where \ln x = 3 - x, that is, at a zero of F(x) = \ln x + x - 3. The logarithm is continuous for x > 0, so F is continuous on [2, 3], and

\begin{aligned} F(2) &= \ln 2 - 1 \approx -0.3069 < 0, \\ F(3) &= \ln 3 \approx 1.0986 > 0. \end{aligned}

So a crossing lies strictly between 2 and 3. Now halve. F(2.5) \approx 0.4163 > 0, so keep [2, 2.5]. F(2.25) \approx 0.0609 > 0, so keep [2, 2.25]. F(2.125) \approx -0.1212 < 0, so keep [2.125, 2.25]. The crossing is at an x in [2.125, 2.25], and the midpoint 2.1875 is within 0.0625 of it.

For the guarantee, the midpoint after n steps is within \displaystyle \frac{1}{2^{n + 1}} of the crossing, so we need 2^{n + 1} \ge 1000. Since 2^9 = 512 is too small and 2^{10} = 1024 is enough, n + 1 = 10 and n = 9 steps suffice. (The crossing is at x \approx 2.2079.)

Example 5

A sign change with no root

Let

s(x) = \begin{cases} x - 2, & x < 1 \\ x + 1, & x \ge 1 \end{cases}

on [0, 2]. Show that s(0) and s(2) have opposite signs but s has no zero, and explain why this does not contradict the intermediate value theorem.

Solution

s(0) = -2 < 0 and s(2) = 3 > 0. A zero would need x - 2 = 0 with x < 1, but that gives x = 2; or x + 1 = 0 with x \ge 1, but that gives x = -1. Neither is allowed, so s has no zero. More is skipped than zero: on [0, 1) the outputs fill [-2, -1), and on [1, 2] they fill [2, 3], so every N with -1 \le N < 2 is missed.

1 2 x y
(0, -2)
(1, -1)
(1, 2)
(2, 3)
Figure 3The function s of Example 5 changes sign on [0, 2] but jumps over zero instead of crossing it.

There is no contradiction, because the hypothesis fails: \lim_{x \to 1^-} s(x) = -1 while s(1) = 2, so s is not continuous at 1. Bisection run anyway keeps [0, 1] (since s(1) = 2 > 0), then [0.5, 1] (since s(0.5) = -1.5 < 0), and every later interval ends at 1. It closes in on the jump, not on a root.

Example 6

A point that stays put

Let g be continuous on [0, 1] with every value g(x) in [0, 1]. Show that g(c) = c for some c in [0, 1].

Solution

The equation g(x) = x asks for a zero of F(x) = g(x) - x, a difference of continuous functions and so continuous on [0, 1]. Since g(0) \ge 0, F(0) = g(0) \ge 0; since g(1) \le 1, F(1) = g(1) - 1 \le 0. If either is 0, that end is the c we want. Otherwise F(0) > 0 > F(1), and the theorem gives c in (0, 1) with F(c) = 0, that is, g(c) = c. In pictures: an unbroken graph from the left side of the unit square to its right side must meet the diagonal y = x.

Boundaries

  • Continuity on the whole closed interval, ends included. Example 5 breaks it with a jump; \displaystyle y = \frac{1}{x} on [-1, 1] breaks it with an infinite break, changes sign and has no zero. Continuity inside is not enough either: let f(0) = -1 and f(x) = x for 0 < x \le 1. Then f(0) < 0 < f(1), f is continuous on (0, 1], and f has no zero.
  • At least one, not exactly one, and no location. Uniqueness needs a separate argument, such as the function being increasing (Example 2).
  • The converse is false. A zero without a sign change is invisible to the theorem: (x - 1)^2 is zero at x = 1 yet never negative, so bisection cannot start on it. When f(a) and f(b) have the same sign, the theorem says nothing either way.
  • The real numbers are needed. On the rational numbers alone, x^2 - 2 is negative at 1 and positive at 2 but is never zero, because \displaystyle \sqrt{2} is irrational. The theorem depends on the number line having no gaps.
  • Bisection needs a bracket and is slow. It must start from a sign change, finds only one of several roots, and needs about 3.3 steps per decimal digit.

Where this goes next

Bisection is sure but slow. Newton’s method uses tangent lines to close in far faster when it works, and bisection supplies a safe starting point. The mean value theorem is another theorem about continuous functions on a closed interval. The theorem also explains sign charts: between neighboring zeros a continuous function keeps one sign, so one test value settles the whole stretch.

Exercises

Showing a value is reached

  1. Show that x^3 - 5x + 1 = 0 has a solution in [0, 1].
  2. Show that x^5 + 2x - 1 = 0 has a solution strictly between 0 and 1.
  3. Show that e^x = 3 - x has a solution between 0 and 1.
  4. Show that \displaystyle \sin x = \frac{x}{2} has a solution in \displaystyle \left[\frac{\pi}{2}, \pi\right].
  5. Let g(x) = x^2 - 3x. Show that g(c) = 1 for some c in [3, 4], then find that c exactly.
  6. Find three intervals of length 1 with integer ends, each holding a root of x^3 - 6x + 2 = 0. Explain why there are no other real roots.
  7. A function f is continuous on [1, 5] with f(1) = 4 and f(5) = -2. Must there be a c in [1, 5] with (a) f(c) = 0, (b) f(c) = 3, (c) f(c) = 5, (d) f(c) = -2?

When the theorem does not apply

  1. Let \displaystyle r(x) = \frac{1}{x - 1}. Then r(0) = -1 and r(2) = 1. Does r have a zero in [0, 2]? Does this contradict the intermediate value theorem?
  2. Let k(x) = x^2 for x \le 1 and k(x) = x + 2 for x > 1, on [0, 2]. Find k(0) and k(2), and every N between them that k never reaches.
  3. Let p(x) = x^2 - 2. Compare the signs of p(-2) and p(2). Does p have a zero in [-2, 2]? What does the theorem say on [-2, 2], and what does it say on [0, 2]?

Bisection

  1. Take three bisection steps for x^3 - 5x + 1 on [0, 1]. Give the final interval and its midpoint.
  2. Take four bisection steps for x^5 + 2x - 1 on [0, 1]. Give the final interval and its midpoint.
  3. Tashi approximates \displaystyle \sqrt{5} by bisection on x^2 - 5 over [2, 3]. Take four steps and compare the final interval with \displaystyle \sqrt{5} \approx 2.2361.
  4. Bisection starts on an interval of length 3. How many halvings bring the length below 0.001?
  5. Dechen takes ten bisection steps from an interval of length 2 and reports the midpoint of the last interval. At most how far is it from a root?

Reasoning

  1. Explain why every cubic p(x) = x^3 + bx^2 + cx + d has a real root.
  2. Dechen walks a road from a village up to a monastery, leaving at 7:00 in the morning and arriving at 5:00 in the afternoon. The next day she leaves the monastery at 7:00 in the morning and walks down the same road, arriving at 5:00 in the afternoon. Her pace changes and she stops to rest. Show that there is a point on the road that she passes at the same time of day on both days.
  3. Sonam says: “f is continuous on [0, 4] with f(0) = 2 and f(4) = -2, so f has exactly one zero in [0, 4].” Say what is right and what is wrong, and give a polynomial with three zeros there.
  4. Explain why, at every step of bisection, the kept interval still has ends where f has opposite signs, and why after n steps from [a, b] the midpoint is within \displaystyle \frac{b - a}{2^{n + 1}} of a zero.
  5. A continuous function f has zeros only at x = -1 and x = 3, and f(0) = 5. Explain why f(x) > 0 for every x in (-1, 3).
Answers
  1. f(x) = x^3 - 5x + 1 is a polynomial, so continuous. f(0) = 1 > 0 and f(1) = -3 < 0, so by the theorem with N = 0 there is a root in [0, 1], in fact in (0, 1).
  2. f(0) = -1 < 0, f(1) = 2 > 0, and f is a polynomial, so a root lies in [0, 1]; neither end is a root, so it lies strictly between. (It is about 0.4864.)
  3. Let F(x) = e^x + x - 3, continuous as a sum of an exponential and a polynomial. F(0) = -2 < 0 and F(1) = e - 2 \approx 0.718 > 0, so F has a zero in (0, 1), where e^x = 3 - x. (It is about 0.7921.)
  4. Let \displaystyle F(x) = \sin x - \frac{x}{2}, continuous everywhere. \displaystyle F\left(\frac{\pi}{2}\right) = 1 - \frac{\pi}{4} \approx 0.215 > 0 and \displaystyle F(\pi) = -\frac{\pi}{2} \approx -1.571 < 0, so a zero lies in the interval. (It is about 1.8955.)
  5. g is a polynomial, g(3) = 0 and g(4) = 4, and 1 lies between, so such a c exists. Solving c^2 - 3c - 1 = 0 gives \displaystyle c = \frac{3 \pm \sqrt{13}}{2}; the one in [3, 4] is \displaystyle c = \frac{3 + \sqrt{13}}{2} \approx 3.3028.
  6. With f(x) = x^3 - 6x + 2: f(-3) = -7, f(-2) = 6, f(0) = 2, f(1) = -3, f(2) = -2, f(3) = 11. Sign changes give roots in [-3, -2], [0, 1] and [2, 3]. A polynomial of degree 3 has at most three real roots, so these are all of them.
  7. (a) Yes, 0 lies between 4 and -2. (b) Yes, 3 lies between. (c) Not forced: 5 is outside [-2, 4], and \displaystyle f(x) = 4 - \frac{3}{2}(x - 1) never reaches 5 on [1, 5]. (d) Yes, trivially, with c = 5.
  8. No zero: a fraction with numerator 1 is never 0. No contradiction: r is undefined at x = 1, which lies in [0, 2], so r is not continuous on [0, 2].
  9. k(0) = 0 and k(2) = 4. On [0, 1] the outputs fill [0, 1]; on (1, 2] they fill (3, 4]. So k misses every N with 1 < N \le 3; it jumps from 1 to just above 3 at x = 1.
  10. p(-2) = 2 and p(2) = 2, the same sign, yet p has zeros at \displaystyle \pm\sqrt{2}. On [-2, 2] the theorem only promises the value 2, which says nothing about zeros. On [0, 2], p(0) = -2 < 0 < 2 = p(2), so it gives a zero in (0, 2), namely \displaystyle \sqrt{2}.
  11. f(0) = 1 > 0, f(1) = -3 < 0. f(0.5) = -1.375 < 0: keep [0, 0.5]. f(0.25) = -0.234375 < 0: keep [0, 0.25]. f(0.125) \approx 0.376953 > 0: keep [0.125, 0.25], midpoint 0.1875. (The root is about 0.2016.)
  12. f(0) = -1, f(1) = 2. f(0.5) = 0.03125 > 0: keep [0, 0.5]. f(0.25) \approx -0.499023 < 0: keep [0.25, 0.5]. f(0.375) \approx -0.242584 < 0: keep [0.375, 0.5]. f(0.4375) \approx -0.108972 < 0: keep [0.4375, 0.5], midpoint 0.46875.
  13. f(2.5) = 1.25 > 0: [2, 2.5]. f(2.25) = 0.0625 > 0: [2, 2.25]. f(2.125) = -0.484375 < 0: [2.125, 2.25]. f(2.1875) \approx -0.214844 < 0: [2.1875, 2.25], which contains 2.2361.
  14. 12. We need \displaystyle \frac{3}{2^n} < 0.001, that is 2^n > 3000; 2^{11} = 2048 is too small and 2^{12} = 4096 is enough.
  15. Within \displaystyle \frac{2}{2^{11}} = \frac{1}{1024} \approx 0.000977.
  16. For large |x| the term x^3 outweighs the rest: \displaystyle \frac{p(x)}{x^3} = 1 + \frac{b}{x} + \frac{c}{x^2} + \frac{d}{x^3} \to 1 as x \to \infty or x \to -\infty. So p(x) has the sign of x^3 far out: some a < 0 has p(a) < 0 and some b_0 > 0 has p(b_0) > 0. A polynomial is continuous, so the theorem gives a root in [a, b_0].
  17. Let L be the length of the road, u(t) her distance from the village at time t on the first day and d(t) on the second, for t from 7:00 to 17:00. Positions change continuously, so F(t) = u(t) - d(t) is continuous, with F(7) = 0 - L < 0 and F(17) = L - 0 > 0. The theorem gives a time c with u(c) = d(c): the same place at the same time of day.
  18. Right: a zero exists, by the theorem. Wrong: “exactly one”; the theorem gives at least one. \displaystyle f(x) = -\frac{1}{3}(x - 1)(x - 2)(x - 3) has f(0) = 2, f(4) = -2 and zeros at 1, 2 and 3.
  19. If f(m) \ne 0, its sign is opposite to exactly one of f(a) and f(b), and that half is kept, so the kept ends always have opposite signs and the theorem puts a zero in each kept interval. Each step halves the length, so after n steps it is \displaystyle \frac{b - a}{2^n}, and the zero inside is no farther than half the length, \displaystyle \frac{b - a}{2^{n + 1}}, from the midpoint.
  20. Suppose some x_0 in (-1, 3) had f(x_0) \le 0. It cannot be 0, since the only zeros are -1 and 3. If f(x_0) < 0, then f(0) = 5 > 0 and the theorem on the interval between 0 and x_0 gives a zero there, inside (-1, 3), which is impossible. So f(x) > 0 throughout.
unattributed · CC-BY-SA-4.0