Ran Wei/ Calculus/Module 3
中文
Calculus · Part I · Functions, limits and continuity

Module 3Continuity and infinity

Learn what it means for a function to be continuous, and what continuity guarantees: solutions of equations, which the bisection method finds to any accuracy you ask for, and largest and smallest values. Then follow functions out to infinity, through asymptotes and limits at infinity, to the orders of growth behind big-O notation.

⏱ 270 minYou need: Modules 1 and 2

In this module you will

  • Decide whether a function is continuous at a point, and classify its discontinuities
  • Explain why the standard functions are continuous on their domains, and use continuity to find limits
  • Use the Intermediate Value Theorem to show that an equation has a solution, and find it by bisection to a guaranteed accuracy
  • State the Extreme Value Theorem, and show with examples why each of its hypotheses is needed
  • Find infinite limits and limits at infinity, and the vertical, horizontal and oblique asymptotes of a graph
  • Compare the growth of logarithms, powers, exponentials and factorials, and use big-O notation
1

Continuity at a point

A cup of tea cooling from 80 °C to 60 °C passes through every temperature in between, because temperature changes gradually. A car park’s charge does not. Suppose (hypothetically) that a car park charges £3 for each hour or part of an hour: 59 minutes cost £3, 61 minutes cost £6, and no length of stay costs £4.50. The charge jumps.

Module 2 met three ways for a limit to fail to exist: a jump, a blow-up and an oscillation. This module asks the opposite question: when is the limit at each point equal to the value there? Such a function is continuous, and on an interval its graph can be drawn without lifting the pencil. Continuity guarantees that equations have solutions (Section 3.3), which can be found to any accuracy (Section 3.4), and that largest and smallest values exist (Section 3.5). Sections 3.6 to 3.8 then follow functions to infinity.

Here are two functions that agree to the left of 2 and differ from 2 on:

h(x)={x2if x<2,6−xif x≥2,h(x) = \begin{cases} x^2 & \text{if } x < 2, \\ 6 - x & \text{if } x \ge 2, \end{cases}
k(x)={x2if x<2,5−xif x≥2.k(x) = \begin{cases} x^2 & \text{if } x < 2, \\ 5 - x & \text{if } x \ge 2. \end{cases}
xxh(x)h(x)k(x)k(x)
1.91.93.613.613.613.61
1.991.993.96013.96013.96013.9601
1.9991.9993.9960013.9960013.9960013.996001
224433
2.0012.0013.9993.9992.9992.999
2.012.013.993.992.992.99
2.12.13.93.92.92.9

Near 2, the values of hh crowd around 4 from both sides, and h(2)=4:h(2) = 4\mathclose{\text{:}} the value fits its neighbours. The values of kk crowd around 4 from the left and around 3 from the right: they disagree, and no single value at 2 could fit both.

For a polynomial p,p\mathclose{\text{,}} Module 2 found that lim⁡x→ap(x)=p(a):\lim_{x\to a} p(x) = p(a)\mathclose{\text{:}} the limit is the value. Functions with this property at a point are called continuous there.

Definition 3.1Continuity at a point

Let ff be defined on an open interval that contains a,a\mathclose{\text{,}} except perhaps at aa itself. Then ff is continuous at aa if

lim⁡x→af(x)=f(a).\lim_{x\to a} f(x) = f(a).

This asks for three things:

  1. f(a)f(a) is defined;
  2. lim⁡x→af(x)\lim_{x\to a} f(x) exists;
  3. the limit equals the value.

If ff is not continuous at a,a\mathclose{\text{,}} then ff is discontinuous at a,a\mathclose{\text{,}} and aa is a discontinuity of f.f\mathclose{\text{.}}

In words: inputs close to aa give outputs close to f(a),f(a)\mathclose{\text{,}} and the graph does not break at (a,f(a)).(a, f(a))\mathclose{\text{.}} In the ε–δ language of Module 2: for every ε>0\varepsilon > 0 there is a δ>0\delta > 0 such that

∣f(x)−f(a)∣<εwhenever∣x−a∣<δ.\abs{f(x) - f(a)} < \varepsilon \quad\text{whenever}\quad \abs{x - a} < \delta.

(The limit only looks at x≠a,x \ne a\mathclose{\text{,}} but x=ax = a does no harm here, since ∣f(a)−f(a)∣=0.)\abs{f(a) - f(a)} = 0\mathclose{\text{.)}}

Example 3.1Testing the three conditions✓ Checked

Decide whether each function is continuous at 2. If it is not, say which condition fails.

  • (a) f(x)=x2−4x−2f(x) = \dfrac{x^2 - 4}{x - 2}
  • (b) g(x)=x2−4x−2g(x) = \dfrac{x^2 - 4}{x - 2} for x≠2,x \ne 2\mathclose{\text{,}} and g(2)=1g(2) = 1
  • (c) the function hh above
  • (d) the function kk above

(a) Condition 1 fails: f(2)=0/0f(2) = 0/0 is not defined. So ff is discontinuous at 2, although its limit there exists: for x≠2,x \ne 2\mathclose{\text{,}} f(x)=(x−2)(x+2)x−2=x+2,f(x) = \dfrac{(x - 2)(x + 2)}{x - 2} = x + 2\mathclose{\text{,}} so lim⁡x→2f(x)=4.\lim_{x\to 2} f(x) = 4\mathclose{\text{.}}

(b) Now g(2)=1g(2) = 1 is defined, and the limit exists and is 4, as in (a): conditions 1 and 2 hold. Condition 3 fails, since 4≠1.4 \ne 1\mathclose{\text{.}} So gg is discontinuous at 2.

(c) h(2)=6−2=4.h(2) = 6 - 2 = 4\mathclose{\text{.}} The formula changes at 2, so use one-sided limits (Module 2): from the left lim⁡x→2−x2=4,\lim_{x\to 2^-} x^2 = 4\mathclose{\text{,}} and from the right lim⁡x→2+(6−x)=4.\lim_{x\to2^+} (6 - x) = 4\mathclose{\text{.}} They agree, so lim⁡x→2h(x)=4=h(2):\lim_{x\to2} h(x) = 4 = h(2)\mathclose{\text{:}} all three conditions hold, and hh is continuous at 2, although it is given by two formulas.

(d) From the left the limit is 4 again; from the right it is lim⁡x→2+(5−x)=3.\lim_{x\to2^+}(5 - x) = 3\mathclose{\text{.}} The one-sided limits differ, so condition 2 fails: kk is discontinuous at 2, although k(2)=3k(2) = 3 is defined.

Watch out

Two opposite mistakes. Being defined at aa and having a limit at aa is not enough: the limit must equal the value, as (b) shows. And a formula in several pieces is no sign of a discontinuity: hh in (c) is continuous at 2 because its pieces meet there. Check the three conditions; do not judge by the look of the formula.

One-sided continuity

Some functions jump, yet their value at the jump fits one of the two sides, like the floor function. The floor of x,x\mathclose{\text{,}} written ⌊x⌋\lfloor x\rfloor and read “floor xx”, is the largest integer less than or equal to x:x\mathclose{\text{:}} ⌊2.7⌋=2,\lfloor 2.7\rfloor = 2\mathclose{\text{,}} ⌊3⌋=3\lfloor 3\rfloor = 3 and ⌊−2.7⌋=−3.\lfloor -2.7\rfloor = -3\mathclose{\text{.}} In Python it is math.floor, and integer division 7 // 2 gives ⌊7/2⌋=3.\lfloor 7/2\rfloor = 3\mathclose{\text{.}} Its graph is a staircase. At x=3:x = 3\mathclose{\text{:}} for xx slightly less than 3, ⌊x⌋=2,\lfloor x\rfloor = 2\mathclose{\text{,}} and for 3≤x<4,3 \le x < 4\mathclose{\text{,}} ⌊x⌋=3.\lfloor x\rfloor = 3\mathclose{\text{.}} So

lim⁡x→3−⌊x⌋=2,lim⁡x→3+⌊x⌋=3=⌊3⌋.\lim_{x\to3^-}\lfloor x\rfloor = 2, \qquad \lim_{x\to3^+}\lfloor x\rfloor = 3 = \lfloor 3\rfloor.

The limit at 3 does not exist, so the floor function is discontinuous at 3; but its value agrees with the limit from the right.

Definition 3.2One-sided continuity and continuity on an interval

A function ff is continuous from the right at aa if lim⁡x→a+f(x)=f(a),\lim_{x\to a^+} f(x) = f(a)\mathclose{\text{,}} and continuous from the left at aa if lim⁡x→a−f(x)=f(a).\lim_{x\to a^-} f(x) = f(a)\mathclose{\text{.}}

ff is continuous on an interval II if it is continuous at every number of I,I\mathclose{\text{,}} except that at an endpoint that belongs to II it need only be continuous from the side of I:I\mathclose{\text{:}} from the right at a left endpoint, from the left at a right endpoint.

So ⌊x⌋\lfloor x\rfloor is continuous from the right at every integer, and continuous on each interval [n,n+1),[n, n + 1)\mathclose{\text{,}} but not on [n,n+1]:[n, n + 1]\mathclose{\text{:}} at n+1n + 1 it is not continuous from the left. The square root is defined only for x≥0,x \ge 0\mathclose{\text{,}} so at 0 only one side counts: lim⁡x→0+x=0=0,\lim_{x\to0^+}\sqrt x = 0 = \sqrt0\mathclose{\text{,}} and x\sqrt x is continuous on [0,∞)[0, \infty) (Section 3.2). Since a limit exists exactly when both one-sided limits exist and are equal (Module 2), ff is continuous at aa exactly when it is continuous from both sides there.

Staircases are everywhere in computing: a digital thermometer that shows whole degrees, rounding down, displays ⌊T⌋\lfloor T\rfloor for a true temperature T,T\mathclose{\text{,}} and its reading jumps at every whole degree.

Watch out

Read one-sided continuity off the graph. Each step of y=⌊x⌋y = \lfloor x\rfloor has its filled dot at its left end, (n,n),(n, n)\mathclose{\text{,}} and runs to the right from there: so ⌊x⌋\lfloor x\rfloor is continuous from the right. Calling it “continuous from the left” because the dot is on the left is the usual slip.

Kinds of discontinuity

Discontinuities come in a few kinds (Figure 3.1), named after what the graph does near the point.

Four kinds of discontinuity at x = 2. Removable: the graph of g (Example 3.1) heads for (2, 4), but g(2) = 1; moving one point fills the hole. Jump: k arrives at different heights from the two sides. Infinite: 1/(x - 2)^2 grows without bound near the dashed line. Oscillating: sinbig(1/(x - 2)big) swings between -1 and 1 infinitely often near 2.
Figure 3.1

Four kinds of discontinuity at x=2.x = 2\mathclose{\text{.}} Removable: the graph of gg (Example 3.1) heads for (2,4),(2, 4)\mathclose{\text{,}} but g(2)=1;g(2) = 1\mathclose{\text{;}} moving one point fills the hole. Jump: kk arrives at different heights from the two sides. Infinite: 1/(x−2)21/(x - 2)^2 grows without bound near the dashed line. Oscillating: sin⁡(1/(x−2))\sin\big(1/(x - 2)\big) swings between −1-1 and 1 infinitely often near 2.

Definition 3.3Kinds of discontinuity

Let aa be a discontinuity of f.f\mathclose{\text{.}} The discontinuity is

  • removable if lim⁡x→af(x)\lim_{x\to a} f(x) exists;
  • a jump if both one-sided limits exist but are different;
  • infinite if, as xx approaches aa from at least one side, the values f(x)f(x) become, and stay, larger than any number you name, or smaller than any number you name (Section 3.6 writes this lim⁡x→a+f(x)=∞,\lim_{x\to a^+} f(x) = \infty\mathclose{\text{,}} lim⁡x→a−f(x)=−∞,\lim_{x\to a^-} f(x) = -\infty\mathclose{\text{,}} and so on);
  • oscillating in every other case: then at least one one-sided limit fails to exist without becoming infinite, as when ff keeps swinging between values.

A removable discontinuity is removed by defining, or redefining, ff at the single point a:a\mathclose{\text{:}} set f(a)=lim⁡x→af(x).f(a) = \lim_{x\to a} f(x)\mathclose{\text{.}} That repairs gg of Example 3.1: give it the value 4 at 2. No single value repairs the other three kinds, because at them lim⁡x→af(x)\lim_{x\to a} f(x) does not exist.

Example 3.2Classifying discontinuities✓ Checked

Find and classify the discontinuities of

  • (a) r(x)=x2−4x2−x−2,r(x) = \dfrac{x^2 - 4}{x^2 - x - 2}\mathclose{\text{,}} the rational function of Example 1.5;
  • (b) s(x)=∣x∣x;s(x) = \dfrac{\abs{x}}{x}\mathclose{\text{;}}
  • (c) q(x)=sin⁡xx.q(x) = \dfrac{\sin x}{x}\mathclose{\text{.}}

(a) Module 1 factored top and bottom: r(x)=(x−2)(x+2)(x−2)(x+1).r(x) = \dfrac{(x - 2)(x + 2)}{(x - 2)(x + 1)}\mathclose{\text{.}} So rr is not defined at 2 and at −1,-1\mathclose{\text{,}} and r(x)=x+2x+1r(x) = \dfrac{x + 2}{x + 1} for every other x;x\mathclose{\text{;}} Section 3.2 shows that rr is continuous everywhere except at these two numbers. At 2, by direct substitution in the cancelled form,

lim⁡x→2r(x)=lim⁡x→2x+2x+1=43,\lim_{x\to2} r(x) = \lim_{x\to2}\frac{x + 2}{x + 1} = \frac43,

so the discontinuity is removable: it is the hole at (2,43)\big(2, \tfrac43\big) that Module 1 found. At −1,-1\mathclose{\text{,}} the numerator x+2x + 2 approaches 1 and the denominator x+1x + 1 approaches 0, so the values of rr grow without bound: an infinite discontinuity (Section 3.6 finds the one-sided limits).

(b) ss is not defined at 0. It is −1-1 for x<0x < 0 and 11 for x>0,x > 0\mathclose{\text{,}} so, as Module 2 found, lim⁡x→0−s(x)=−1\lim_{x\to0^-} s(x) = -1 and lim⁡x→0+s(x)=1:\lim_{x\to0^+} s(x) = 1\mathclose{\text{:}} 0 is a jump discontinuity.

(c) qq is not defined at 0, and Module 2 proved that lim⁡x→0sin⁡xx=1.\lim_{x\to0}\dfrac{\sin x}{x} = 1\mathclose{\text{.}} So 0 is a removable discontinuity: sin⁡xx,\dfrac{\sin x}{x}\mathclose{\text{,}} given the value 1 at 0, is continuous at 0. This repaired function is the sinc function of signal processing (some books put πx\pi x in place of x).x\mathclose{\text{).}}

Watch out

A zero in the denominator does not always mean an infinite discontinuity: the denominator of rr is 0 at 2, but so is the numerator, the factor x−2x - 2 cancels, and the discontinuity is removable. Factor and cancel first, then decide. And the kind depends on the limits near a,a\mathclose{\text{,}} not on f(a):f(a)\mathclose{\text{:}} ss and qq are both undefined at 0, but differ in kind.

2

Which functions are continuous

Checking three conditions at every point would never end. A few theorems settle continuity at once for every function built from the catalogue of Module 1.

Sums, products and quotients

Theorem 3.1Continuity laws

If ff and gg are continuous at aa and cc is a constant, then the functions

f+g,f−g,cf,fgf + g, \qquad f - g, \qquad cf, \qquad fg

are continuous at a,a\mathclose{\text{,}} and so is f/gf/g if g(a)≠0.g(a) \ne 0\mathclose{\text{.}} The same holds for continuity from one side, and so for continuity on an interval.

Proof

Each statement is a limit law of Module 2 in disguise. For the product: since lim⁡x→af(x)=f(a)\lim_{x\to a} f(x) = f(a) and lim⁡x→ag(x)=g(a),\lim_{x\to a} g(x) = g(a)\mathclose{\text{,}} the product law gives

lim⁡x→af(x) g(x)=lim⁡x→af(x)⋅lim⁡x→ag(x)=f(a) g(a),\begin{aligned} \lim_{x\to a} f(x)\,g(x) &= \lim_{x\to a} f(x) \cdot \lim_{x\to a} g(x) \\ &= f(a)\,g(a), \end{aligned}

which says that fgfg is continuous at a.a\mathclose{\text{.}} Sums, differences and constant multiples work the same way. The quotient law needs the limit of the denominator to be non-zero, and it is: lim⁡x→ag(x)=g(a)≠0.\lim_{x\to a} g(x) = g(a) \ne 0\mathclose{\text{.}} (So g(x)≠0g(x) \ne 0 for xx close to a,a\mathclose{\text{,}} and f/gf/g is defined on an open interval around a.)a\mathclose{\text{.)}} One-sided limits obey the same laws, which gives the one-sided statements.

∎
Theorem 3.2Polynomials and rational functions

Every polynomial is continuous on R.\R\mathclose{\text{.}} Every rational function is continuous at every number of its domain.

Proof

This is the direct substitution theorem of Module 2 in new words. For a polynomial pp and every number a,a\mathclose{\text{,}} lim⁡x→ap(x)=p(a).\lim_{x\to a} p(x) = p(a)\mathclose{\text{.}} For a rational function p/qp/q and a number aa of its domain, q(a)≠0,q(a) \ne 0\mathclose{\text{,}} and lim⁡x→ap(x)/q(x)=p(a)/q(a).\lim_{x\to a} p(x)/q(x) = p(a)/q(a)\mathclose{\text{.}} Each statement says that the limit is the value: continuity at a.a\mathclose{\text{.}}

∎

This completes Example 3.2: rr is continuous at every number except 2 and −1.-1\mathclose{\text{.}}

The catalogue is continuous

Theorem 3.3Continuity of the standard functions

Each of these functions is continuous at every number of its domain (at 0, the endpoint of the domain of an even root, from the right):

  • roots xn,\sqrt[n]{x}\mathclose{\text{,}} for whole numbers n≥2;n \ge 2\mathclose{\text{;}}
  • the trigonometric functions sin⁡x,\sin x\mathclose{\text{,}} cos⁡x,\cos x\mathclose{\text{,}} tan⁡x,\tan x\mathclose{\text{,}} cot⁡x,\cot x\mathclose{\text{,}} sec⁡x\sec x and csc⁡x;\csc x\mathclose{\text{;}}
  • exponential functions ax,a^x\mathclose{\text{,}} for a>0;a > 0\mathclose{\text{;}}
  • logarithms log⁡ax,\log_a x\mathclose{\text{,}} for a>0a > 0 with a≠1;a \ne 1\mathclose{\text{;}} in particular ln⁡x.\ln x\mathclose{\text{.}}

Here is why, family by family: proofs for sine, cosine and roots, and the idea of the proof for exponentials and logarithms. On a first reading you may take the theorem on trust.

Sine and cosine. Module 2 proved that sin⁡h→0=sin⁡0\sin h \to 0 = \sin 0 and cos⁡h→1=cos⁡0\cos h \to 1 = \cos 0 as h→0:h \to 0\mathclose{\text{:}} sine and cosine are continuous at 0. For any other number a,a\mathclose{\text{,}} write x=a+h,x = a + h\mathclose{\text{,}} so that h→0h \to 0 as x→a.x \to a\mathclose{\text{.}} The addition formula of Section 1.4 and those two limits give

sin⁡(a+h)=sin⁡acos⁡h+cos⁡asin⁡h→sin⁡a⋅1+cos⁡a⋅0=sin⁡a.\begin{aligned} \sin(a + h) &= \sin a\cos h + \cos a\sin h \\ &\to \sin a \cdot 1 + \cos a \cdot 0 = \sin a. \end{aligned}

In the same way cos⁡(a+h)=cos⁡acos⁡h−sin⁡asin⁡h→cos⁡a.\cos(a + h) = \cos a\cos h - \sin a\sin h \to \cos a\mathclose{\text{.}} So sine and cosine are continuous on R,\R\mathclose{\text{,}} and the other four, quotients built from these two, are continuous wherever their denominators are not 0 (Theorem 3.1): on their domains.

Roots. By the root law of Module 2, lim⁡x→axn=an\lim_{x\to a}\sqrt[n]{x} = \sqrt[n]{a} for every a>0,a > 0\mathclose{\text{,}} and for every aa when nn is odd. At 0 an even root is continuous from the right: xn<ε\sqrt[n]{x} < \varepsilon whenever 0≤x<εn,0 \le x < \varepsilon^n\mathclose{\text{,}} which is the ε–δ condition with δ=εn.\delta = \varepsilon^n\mathclose{\text{.}}

Exponentials and logarithms. For an irrational xx such as 2,\sqrt2\mathclose{\text{,}} Module 1 defined axa^x as the number that a1.4,a1.41,a1.414,…a^{1.4}, a^{1.41}, a^{1.414}, \dots approach. Making that precise is what shows axa^x to be continuous; it belongs to a course in analysis, and this series takes it as known. The logarithm log⁡a\log_a is the inverse of ax,a^x\mathclose{\text{,}} so its graph is the mirror image of the graph of axa^x in the line y=xy = x (Theorem 1.2), and the mirror image of an unbroken curve is unbroken. That is the idea behind a fact proved in analysis courses: the inverse of a continuous function that is strictly increasing or strictly decreasing on an interval (Exercise 1.10) is continuous.

Key idea

Every function built from the catalogue of Module 1 with +,+\mathclose{\text{,}} −,-\mathclose{\text{,}} ×,\times\mathclose{\text{,}} ÷\div and composition (below) is continuous on every interval that lies in its domain. A discontinuity can only occur where a formula breaks down (a zero denominator, the logarithm of 0) or where a piecewise definition changes formula.

Watch out

“Continuous on its domain” is not “continuous everywhere”. 1/x1/x and tan⁡x\tan x are continuous at every number of their domains, and books call them continuous functions; yet they have infinite discontinuities at 0 and at π/2,\pi/2\mathclose{\text{,}} outside their domains, where their graphs break. Asked where a function is continuous, give the intervals: 1/x1/x is continuous on (−∞,0)(-\infty, 0) and on (0,∞),(0, \infty)\mathclose{\text{,}} but not on [−1,1].[-1, 1]\mathclose{\text{.}}

Composition

Most formulas nest one function inside another: 9−x2,\sqrt{9 - x^2}\mathclose{\text{,}} ln⁡(1+cos⁡x),\ln(1 + \cos x)\mathclose{\text{,}} e(sin⁡x)/x.e^{(\sin x)/x}\mathclose{\text{.}} Limits can be moved inside such a nest, as long as the outer function is continuous.

Theorem 3.4Limits of compositions

If lim⁡x→ag(x)=b\lim_{x\to a} g(x) = b and ff is continuous at b,b\mathclose{\text{,}} then

lim⁡x→af(g(x))=f(b)=f(lim⁡x→ag(x)).\lim_{x\to a} f\big(g(x)\big) = f(b) = f\Big(\lim_{x\to a} g(x)\Big).

The same holds for one-sided limits, and for limits as x→∞x \to \infty or x→−∞x \to -\infty (Section 3.7).

In words: if the inner function heads for bb and the outer function is continuous at b,b\mathclose{\text{,}} the composition heads for f(b).f(b)\mathclose{\text{.}} The proof is in the Going deeper box below. With b=g(a),b = g(a)\mathclose{\text{,}} the theorem gives the composition rule:

Theorem 3.5Continuity of compositions

If gg is continuous at aa and ff is continuous at g(a),g(a)\mathclose{\text{,}} then f∘gf \circ g is continuous at a.a\mathclose{\text{.}}

Proof

Since gg is continuous at a,a\mathclose{\text{,}} lim⁡x→ag(x)=g(a).\lim_{x\to a} g(x) = g(a)\mathclose{\text{.}} Since ff is continuous at g(a),g(a)\mathclose{\text{,}} Theorem 3.4 with b=g(a)b = g(a) gives

lim⁡x→af(g(x))=f(g(a)),\lim_{x\to a} f\big(g(x)\big) = f\big(g(a)\big),

which says that f∘gf \circ g is continuous at a.a\mathclose{\text{.}}

∎

For example, ∣x∣=x2,\abs{x} = \sqrt{x^2}\mathclose{\text{,}} the composition of x2x^2 with the square root, is continuous at every x≠0,x \ne 0\mathclose{\text{,}} where x2>0x^2 > 0 and the square root is continuous. At 0 the theorem does not apply, since the square root is continuous there only from the right; but lim⁡x→0∣x∣=0=∣0∣,\lim_{x\to0}\abs{x} = 0 = \abs{0}\mathclose{\text{,}} as Example 2.9 showed. So ∣x∣\abs{x} is continuous on R.\R\mathclose{\text{.}}

Going deeperWhy limits pass inside continuous functions

Here is the proof of Theorem 3.4, with the ε–δ definition of Module 2. Let ε>0.\varepsilon > 0\mathclose{\text{.}} Because ff is continuous at b,b\mathclose{\text{,}} there is a number η>0\eta > 0 (η\eta is the Greek letter eta) such that

∣u−b∣<η implies ∣f(u)−f(b)∣<ε.\abs{u - b} < \eta \ \text{implies}\ \abs{f(u) - f(b)} < \varepsilon.

Because g(x)→bg(x) \to b as x→a,x \to a\mathclose{\text{,}} the definition of that limit, applied with η\eta in the role of ε,\varepsilon\mathclose{\text{,}} gives a δ>0\delta > 0 such that

0<∣x−a∣<δ implies ∣g(x)−b∣<η.0 < \abs{x - a} < \delta \ \text{implies}\ \abs{g(x) - b} < \eta.

Chain the two: if 0<∣x−a∣<δ,0 < \abs{x - a} < \delta\mathclose{\text{,}} then u=g(x)u = g(x) satisfies ∣u−b∣<η,\abs{u - b} < \eta\mathclose{\text{,}} so ∣f(g(x))−f(b)∣<ε.\abs{f(g(x)) - f(b)} < \varepsilon\mathclose{\text{.}} That is the definition of lim⁡x→af(g(x))=f(b).\lim_{x\to a} f(g(x)) = f(b)\mathclose{\text{.}}

Continuity of ff at b,b\mathclose{\text{,}} not merely a limit of ff at b,b\mathclose{\text{,}} is needed. Let f(u)=0f(u) = 0 for u≠0u \ne 0 and f(0)=1,f(0) = 1\mathclose{\text{,}} and let g(x)=0g(x) = 0 for every x.x\mathclose{\text{.}} Then lim⁡u→0f(u)=0,\lim_{u\to0} f(u) = 0\mathclose{\text{,}} but f(g(x))=f(0)=1f(g(x)) = f(0) = 1 for every x,x\mathclose{\text{,}} so lim⁡x→0f(g(x))=1.\lim_{x\to0} f(g(x)) = 1\mathclose{\text{.}} The proof breaks because u=g(x)u = g(x) can equal b,b\mathclose{\text{,}} and the limit of ff at bb says nothing about f(b)f(b) itself; continuity does.

Example 3.3Where is it continuous?✓ Checked

Find the intervals on which each function is continuous.

  • (a) f(x)=sin⁡xx2+1f(x) = \dfrac{\sin x}{x^2 + 1}
  • (b) g(x)=9−x2g(x) = \sqrt{9 - x^2}
  • (c) h(x)=ln⁡(1+cos⁡x)h(x) = \ln(1 + \cos x)

(a) sin⁡x\sin x and x2+1x^2 + 1 are continuous on R,\R\mathclose{\text{,}} and x2+1≥1x^2 + 1 \ge 1 is never 0, so by the quotient law ff is continuous on R.\R\mathclose{\text{.}}

(b) gg is the square root u\sqrt u composed with u=9−x2,u = 9 - x^2\mathclose{\text{,}} and its domain is where 9−x2≥0:9 - x^2 \ge 0\mathclose{\text{:}} −3≤x≤3.-3 \le x \le 3\mathclose{\text{.}} For −3<x<3,-3 < x < 3\mathclose{\text{,}} uu is positive, and u\sqrt u is continuous at every positive u,u\mathclose{\text{,}} so gg is continuous at xx by Theorem 3.5. At the endpoint 3: as x→3−,x \to 3^-\mathclose{\text{,}} u=9−x2u = 9 - x^2 approaches 0 through positive values, and u→0\sqrt u \to 0 as u→0+,u \to 0^+\mathclose{\text{,}} so g(x)→0=g(3).g(x) \to 0 = g(3)\mathclose{\text{.}} So gg is continuous from the left at 3, in the same way from the right at −3,-3\mathclose{\text{,}} and therefore continuous on [−3,3].[-3, 3]\mathclose{\text{.}} Its graph is the upper half of the circle x2+y2=9x^2 + y^2 = 9 (compare Example 1.2).

(c) ln⁡u\ln u is continuous for u>0u > 0 and 1+cos⁡x1 + \cos x is continuous everywhere, so hh is continuous wherever 1+cos⁡x>0.1 + \cos x > 0\mathclose{\text{.}} Since cos⁡x≥−1,\cos x \ge -1\mathclose{\text{,}} 1+cos⁡x≥0,1 + \cos x \ge 0\mathclose{\text{,}} with equality exactly where cos⁡x=−1:\cos x = -1\mathclose{\text{:}} at the odd multiples of π,\pi\mathclose{\text{,}} x=±π,±3π,….x = \pm\pi, \pm3\pi, \dots\mathclose{\text{.}} So hh is continuous on every interval between consecutive odd multiples of π:\pi\mathclose{\text{:}} on (−π,π),(-\pi, \pi)\mathclose{\text{,}} on (π,3π),(\pi, 3\pi)\mathclose{\text{,}} and so on. At the odd multiples of π,\pi\mathclose{\text{,}} hh is not defined, and its values plunge without bound (Section 3.6).

Example 3.4Limits by continuity✓ Checked

Find (a) lim⁡x→1ln⁡x2−1x−1\displaystyle\lim_{x\to 1} \ln\frac{x^2 - 1}{x - 1} and (b) lim⁡x→0e(sin⁡x)/x.\displaystyle\lim_{x\to0} e^{(\sin x)/x}\mathclose{\text{.}}

(a) The inner function g(x)=x2−1x−1g(x) = \dfrac{x^2 - 1}{x - 1} is not defined at 1, but for x≠1x \ne 1 it equals (x−1)(x+1)x−1=x+1,\dfrac{(x - 1)(x + 1)}{x - 1} = x + 1\mathclose{\text{,}} so lim⁡x→1g(x)=2.\lim_{x\to1} g(x) = 2\mathclose{\text{.}} The logarithm is continuous at 2, so by Theorem 3.4

lim⁡x→1ln⁡x2−1x−1=ln⁡(lim⁡x→1x2−1x−1)=ln⁡2≈0.6931.\begin{aligned} \lim_{x\to 1} \ln\frac{x^2 - 1}{x - 1} &= \ln\Big(\lim_{x\to1}\frac{x^2 - 1}{x - 1}\Big) \\ &= \ln 2 \approx 0.6931. \end{aligned}

The theorem needs the inner limit to exist, not the inner function to be continuous: here it has a removable discontinuity at 1.

(b) As x→0,x \to 0\mathclose{\text{,}} the exponent sin⁡xx\dfrac{\sin x}{x} tends to 1 (Module 2), and eue^u is continuous at 1, so

lim⁡x→0e(sin⁡x)/x=e1=e≈2.718.\lim_{x\to0} e^{(\sin x)/x} = e^1 = e \approx 2.718.
Watch out

A limit moves inside a function only if the function is continuous at the inner limit. The floor function is not continuous at 1: as x→0,x \to 0\mathclose{\text{,}} cos⁡x→1,\cos x \to 1\mathclose{\text{,}} but for 0<∣x∣<π/2,0 < \abs{x} < \pi/2\mathclose{\text{,}} 0<cos⁡x<1,0 < \cos x < 1\mathclose{\text{,}} so ⌊cos⁡x⌋=0.\lfloor\cos x\rfloor = 0\mathclose{\text{.}} Hence lim⁡x→0⌊cos⁡x⌋=0,\lim_{x\to0}\lfloor\cos x\rfloor = 0\mathclose{\text{,}} not ⌊1⌋=1.\lfloor 1\rfloor = 1\mathclose{\text{.}}

3

The Intermediate Value Theorem

Walk up a mountain path from a hut at 1200 m to a summit at 2100 m. However the path twists and dips, at some moment you are at exactly 1500 m: your height changes continuously, so it cannot skip from below 1500 m to above it. In the same way, a horizontal line at any height NN between f(a)f(a) and f(b)f(b) must meet the graph of a continuous function somewhere between aa and bb (Figure 3.2).

The Intermediate Value Theorem. Left: f is continuous on [a, b] and N lies between f(a) and f(b), so the line y = N meets the graph, here at three points c1, c2 and c3. Right: a graph with a jump can skip over the height N, and then no c has f(c) = N.
Figure 3.2

The Intermediate Value Theorem. Left: ff is continuous on [a,b][a, b] and NN lies between f(a)f(a) and f(b),f(b)\mathclose{\text{,}} so the line y=Ny = N meets the graph, here at three points c1,c_1\mathclose{\text{,}} c2c_2 and c3.c_3\mathclose{\text{.}} Right: a graph with a jump can skip over the height N,N\mathclose{\text{,}} and then no cc has f(c)=N.f(c) = N\mathclose{\text{.}}

Theorem 3.6The Intermediate Value Theorem

Suppose that ff is continuous on the closed interval [a,b],[a, b]\mathclose{\text{,}} and let NN be any number strictly between f(a)f(a) and f(b).f(b)\mathclose{\text{.}} Then there is at least one number cc in (a,b)(a, b) with f(c)=N.f(c) = N\mathclose{\text{.}}

The form you will use most is about roots. If ff is continuous on [a,b][a, b] and f(a)f(a) and f(b)f(b) have opposite signs, then 0 lies strictly between them, so the equation f(x)=0f(x) = 0 has a solution in (a,b).(a, b)\mathclose{\text{.}}

The hypothesis is continuity on the whole closed interval, endpoints included, and every part of it is needed:

  • Without continuity. Let f(x)=−1f(x) = -1 for x<0x < 0 and f(x)=1f(x) = 1 for x≥0.x \ge 0\mathclose{\text{.}} On [−1,1],[-1, 1]\mathclose{\text{,}} f(−1)=−1<0<1=f(1),f(-1) = -1 < 0 < 1 = f(1)\mathclose{\text{,}} but ff is never 0: the jump at 0 skips every value strictly between −1-1 and 1.
  • Without continuity at an endpoint. Let g(0)=−1g(0) = -1 and g(x)=xg(x) = x for 0<x≤1.0 < x \le 1\mathclose{\text{.}} Then gg is continuous on (0,1],(0, 1]\mathclose{\text{,}} and g(0)=−1<0<1=g(1),g(0) = -1 < 0 < 1 = g(1)\mathclose{\text{,}} but g(x)=xg(x) = x is positive for every xx in (0,1]:(0, 1]\mathclose{\text{:}} gg has no root. The culprit is the endpoint 0, where gg is not continuous from the right, since lim⁡x→0+g(x)=0≠g(0).\lim_{x\to0^+} g(x) = 0 \ne g(0)\mathclose{\text{.}}

Notice also what the theorem does not say. It promises at least one c,c\mathclose{\text{,}} not exactly one: in Figure 3.2 there are three. And it does not say where cc is: it is an existence theorem. Section 3.4 turns it into a method for finding c.c\mathclose{\text{.}}

Example 3.5A root of a cubic✓ Checked

Show that the equation x3−2x−5=0x^3 - 2x - 5 = 0 has a solution between 2 and 3.

Let f(x)=x3−2x−5.f(x) = x^3 - 2x - 5\mathclose{\text{.}} It is a polynomial, so it is continuous on [2,3][2, 3] (Theorem 3.2). At the ends of the interval,

f(2)=8−4−5=−1,f(3)=27−6−5=16.\begin{aligned} f(2) &= 8 - 4 - 5 = -1, \\ f(3) &= 27 - 6 - 5 = 16. \end{aligned}

Since f(2)<0<f(3),f(2) < 0 < f(3)\mathclose{\text{,}} the Intermediate Value Theorem with N=0N = 0 gives a number cc in (2,3)(2, 3) with f(c)=0.f(c) = 0\mathclose{\text{.}} The theorem does not say where in (2,3);(2, 3)\mathclose{\text{;}} since f(2)=−1f(2) = -1 is much closer to 0 than f(3)=16,f(3) = 16\mathclose{\text{,}} you may guess that cc is nearer 2. Section 3.4 finds c≈2.0946.c \approx 2.0946\mathclose{\text{.}}

Example 3.6Solving cos⁡x=x\cos x = x✓ Checked

Show that the equation cos⁡x=x\cos x = x has a solution, and find an interval of length 1 that contains it.

No algebra solves cos⁡x=x.\cos x = x\mathclose{\text{.}} Rewrite it as f(x)=0f(x) = 0 with f(x)=cos⁡x−x,f(x) = \cos x - x\mathclose{\text{,}} which is continuous on R\R as a difference of continuous functions (Theorems 3.1 and 3.3). Try a few values, in radians as always:

f(0)=cos⁡0−0=1>0,f(1)=cos⁡1−1≈0.5403−1=−0.4597<0.\begin{aligned} f(0) &= \cos 0 - 0 = 1 > 0, \\ f(1) &= \cos 1 - 1 \approx 0.5403 - 1 \\ &= -0.4597 < 0. \end{aligned}

By the Intermediate Value Theorem, cos⁡x−x=0\cos x - x = 0 has a solution in (0,1).(0, 1)\mathclose{\text{.}} Equations of this kind, mixing a trigonometric function with a polynomial, are common in physics and engineering, and no formula solves them; Section 3.4 finds this solution, about 0.739.

Watch out

Check continuity on the whole interval before you use the theorem. tan⁡x\tan x changes sign on [π/4,3π/4],[\pi/4, 3\pi/4]\mathclose{\text{,}} from tan⁡(π/4)=1\tan(\pi/4) = 1 to tan⁡(3π/4)=−1,\tan(3\pi/4) = -1\mathclose{\text{,}} but it has no zero there (its zeros are the multiples of π).\pi\mathclose{\text{).}} Its graph does not cross the axis; it jumps from +∞+\infty to −∞-\infty at the asymptote x=π/2,x = \pi/2\mathclose{\text{,}} where tan⁡x\tan x is not continuous.

Going deeperWhy the Intermediate Value Theorem is true

A first reading may skip this proof. It takes one property of the real numbers as an axiom, and proves the rest.

Suppose that ff is continuous on [a,b][a, b] and f(a)<N<f(b).f(a) < N < f(b)\mathclose{\text{.}} (If f(a)>N>f(b),f(a) > N > f(b)\mathclose{\text{,}} apply the argument to −f-f and −N.)-N\mathclose{\text{.)}} Halve [a,b].[a, b]\mathclose{\text{.}} If ff takes the value NN at the midpoint, that midpoint is the cc wanted; otherwise keep the half at whose left end ff is below NN and at whose right end it is above. Repeat. Either some midpoint gives the value N,N\mathclose{\text{,}} or you get intervals [an,bn],[a_n, b_n]\mathclose{\text{,}} each half the one before, with f(an)<N<f(bn)f(a_n) < N < f(b_n) for every n:n\mathclose{\text{:}} the bisection method of the next section, with NN in place of 0.

The left ends a0≤a1≤a2≤⋯a_0 \le a_1 \le a_2 \le \cdots never decrease, the right ends b0≥b1≥b2≥⋯b_0 \ge b_1 \ge b_2 \ge \cdots never increase, and the width bn−an=(b−a)/2nb_n - a_n = (b - a)/2^n shrinks to 0. Here the proof needs the completeness of the real numbers: the number line has no gaps, so some number cc lies in every one of the intervals, an≤c≤bna_n \le c \le b_n for every n.n\mathclose{\text{.}} This is the axiom. (Module 14 states it as the Monotone Convergence Theorem: a sequence that never decreases and stays below a fixed bound has a limit. Here cc is the limit of the an.)a_n\mathclose{\text{.)}}

It remains to show that f(c)=N.f(c) = N\mathclose{\text{.}} Suppose not, and challenge the continuity of ff at cc with ε=∣f(c)−N∣.\varepsilon = \abs{f(c) - N}\mathclose{\text{.}} There is a δ>0\delta > 0 such that ∣f(x)−f(c)∣<ε\abs{f(x) - f(c)} < \varepsilon for every xx in [a,b][a, b] with ∣x−c∣<δ:\abs{x - c} < \delta\mathclose{\text{:}} all those f(x)f(x) are closer to f(c)f(c) than NN is, so they lie on the same side of NN as f(c).f(c)\mathclose{\text{.}} Take nn so large that bn−an<δ.b_n - a_n < \delta\mathclose{\text{.}} Since cc lies in [an,bn],[a_n, b_n]\mathclose{\text{,}} both ends are within δ\delta of c,c\mathclose{\text{,}} so f(an)f(a_n) and f(bn)f(b_n) lie on the same side of N.N\mathclose{\text{.}} But f(an)<N<f(bn).f(a_n) < N < f(b_n)\mathclose{\text{.}} So f(c)=N.f(c) = N\mathclose{\text{.}} Finally, cc is neither aa nor b,b\mathclose{\text{,}} because f(a)≠N≠f(b).f(a) \ne N \ne f(b)\mathclose{\text{.}}

Completeness is essential. Within the rational numbers alone the theorem is false: x2−2x^2 - 2 is negative at 1 and positive at 2, but no rational number cc has c2=2,c^2 = 2\mathclose{\text{,}} because 2\sqrt2 is irrational; the intervals [an,bn][a_n, b_n] close in on the gap where 2\sqrt2 would be. Courses in real analysis either build the real numbers and prove completeness, or take it as an axiom, as here.

4

The bisection method

The Intermediate Value Theorem says that x3−2x−5x^3 - 2x - 5 has a root in (2,3),(2, 3)\mathclose{\text{,}} but not where. The bisection method finds it by applying the theorem again and again: halve the interval, and keep the half where the sign changes.

Definition 3.4The bisection method

Let ff be continuous on [a,b],[a, b]\mathclose{\text{,}} with f(a)f(a) and f(b)f(b) of opposite signs. Start with the bracket [a0,b0]=[a,b].[a_0, b_0] = [a, b]\mathclose{\text{.}} For n=0,1,2,…:n = 0, 1, 2, \dots\mathclose{\text{:}}

  1. Compute the midpoint mn=an+bn2m_n = \dfrac{a_n + b_n}{2} and the value f(mn).f(m_n)\mathclose{\text{.}}
  2. If f(mn)=0,f(m_n) = 0\mathclose{\text{,}} stop: mnm_n is a root.
  3. If f(mn)f(m_n) has the same sign as f(an),f(a_n)\mathclose{\text{,}} the new bracket is [an+1,bn+1]=[mn,bn];[a_{n+1}, b_{n+1}] = [m_n, b_n]\mathclose{\text{;}} otherwise it is [an+1,bn+1]=[an,mn].[a_{n+1}, b_{n+1}] = [a_n, m_n]\mathclose{\text{.}}

Stop when the bracket is as narrow as you need.

Read ana_n as “a sub n”. Step 3 always keeps a half at whose ends ff has opposite signs, so, by the Intermediate Value Theorem, every bracket contains a root (Figure 3.3).

The bisection method for f(x) = x^2 - 2, starting from [1, 2], where f(1) = -1 < 0 < 2 = f(2). Each bracket [an, bn] is one half of the bracket above it: the half where f changes sign. Every bracket contains the root sqrt2 (dashed), and after six steps the bracket [1.40625, 1.421875] has width 1/64.
Figure 3.3

The bisection method for f(x)=x2−2,f(x) = x^2 - 2\mathclose{\text{,}} starting from [1,2],[1, 2]\mathclose{\text{,}} where f(1)=−1<0<2=f(2).f(1) = -1 < 0 < 2 = f(2)\mathclose{\text{.}} Each bracket [an,bn][a_n, b_n] is one half of the bracket above it: the half where ff changes sign. Every bracket contains the root 2\sqrt2 (dashed), and after six steps the bracket [1.40625,1.421875][1.40625, 1.421875] has width 1/64.1/64\mathclose{\text{.}}

Example 3.72\sqrt2 by bisection✓ Checked

Use the bisection method on f(x)=x2−2,f(x) = x^2 - 2\mathclose{\text{,}} starting from [1,2],[1, 2]\mathclose{\text{,}} to locate 2,\sqrt2\mathclose{\text{,}} the positive root of f.f\mathclose{\text{.}} Carry out six steps.

ff is continuous and f(1)=−1<0<2=f(2),f(1) = -1 < 0 < 2 = f(2)\mathclose{\text{,}} so the method can start. For n=0,n = 0\mathclose{\text{,}} m0=1.5m_0 = 1.5 and f(1.5)=2.25−2=0.25,f(1.5) = 2.25 - 2 = 0.25\mathclose{\text{,}} positive like f(b0):f(b_0)\mathclose{\text{:}} the root is in the left half, [a1,b1]=[1,1.5].[a_1, b_1] = [1, 1.5]\mathclose{\text{.}} For n=1,n = 1\mathclose{\text{,}} m1=1.25m_1 = 1.25 and f(1.25)=1.5625−2=−0.4375,f(1.25) = 1.5625 - 2 = -0.4375\mathclose{\text{,}} negative like f(a1):f(a_1)\mathclose{\text{:}} the root is in the right half, [a2,b2]=[1.25,1.5].[a_2, b_2] = [1.25, 1.5]\mathclose{\text{.}} Continuing in the same way, with f(mn)f(m_n) rounded to 4 significant digits:

nn ana_n bnb_n mnm_n f(mn)f(m_n)
0 1 2 1.5 0.25
1 1 1.5 1.25 −0.4375
2 1.25 1.5 1.375 −0.1094
3 1.375 1.5 1.4375 0.06641
4 1.375 1.4375 1.40625 −0.02246
5 1.40625 1.4375 1.421875 0.02173
6 1.40625 1.421875 1.4140625 −0.0004272

After six steps the root lies in [a6,b6]=[1.40625,1.421875],[a_6, b_6] = [1.40625, 1.421875]\mathclose{\text{,}} a bracket of width 164=0.015625.\tfrac{1}{64} = 0.015625\mathclose{\text{.}} Both ends begin 1.4, so 2=1.4…\sqrt2 = 1.4\ldots is certain; the second decimal is not yet, since the ends begin 1.40 and 1.42. The midpoint m6=1.4140625m_6 = 1.4140625 is within half the width, 1128=0.0078125,\tfrac{1}{128} = 0.0078125\mathclose{\text{,}} of 2.\sqrt2\mathclose{\text{.}} In fact 2=1.41421356…,\sqrt2 = 1.41421356\ldots\mathclose{\text{,}} so m6m_6 is off by only about 0.00015: the guarantee is a worst case.

The values f(mn)f(m_n) in the table are rounded, but the signs, which are all that the method uses, are exact.

Theorem 3.7The error of the bisection method

Let ff be continuous on [a,b],[a, b]\mathclose{\text{,}} with f(a)f(a) and f(b)f(b) of opposite signs. If the bisection method has not stopped at an exact root, then after nn steps the bracket [an,bn][a_n, b_n] contains a root rr of f,f\mathclose{\text{,}} and

bn−an=b−a2n,∣mn−r∣≤b−a2n+1.b_n - a_n = \frac{b - a}{2^n}, \quad \abs{m_n - r} \le \frac{b - a}{2^{n+1}}.
Proof

Step 3 of the method keeps a half of the bracket at whose ends ff has opposite signs: if f(mn)f(m_n) has the sign of f(an),f(a_n)\mathclose{\text{,}} it has the sign opposite to f(bn),f(b_n)\mathclose{\text{,}} and the new bracket is [mn,bn];[m_n, b_n]\mathclose{\text{;}} otherwise f(mn),f(m_n)\mathclose{\text{,}} which is not 0, has the sign opposite to f(an),f(a_n)\mathclose{\text{,}} and the new bracket is [an,mn].[a_n, m_n]\mathclose{\text{.}} So f(an)f(a_n) and f(bn)f(b_n) have opposite signs for every n.n\mathclose{\text{.}} Since ff is continuous on [an,bn],[a_n, b_n]\mathclose{\text{,}} a part of [a,b],[a, b]\mathclose{\text{,}} the Intermediate Value Theorem gives a root rr in (an,bn).(a_n, b_n)\mathclose{\text{.}} Each step halves the width of the bracket, so after nn steps the width is (b−a)/2n.(b - a)/2^n\mathclose{\text{.}} Finally, the midpoint of an interval is within half the interval’s width of every point of the interval, in particular of r:r\mathclose{\text{:}}

∣mn−r∣≤12⋅b−a2n=b−a2n+1.\abs{m_n - r} \le \frac12\cdot\frac{b - a}{2^n} = \frac{b - a}{2^{n+1}}.
∎

So the bisection method comes with a guarantee that most numerical methods lack: you know in advance how many steps give the accuracy you need. To make ∣mn−r∣≤ε,\abs{m_n - r} \le \varepsilon\mathclose{\text{,}} it is enough that (b−a)/2n+1≤ε,(b - a)/2^{n+1} \le \varepsilon\mathclose{\text{,}} that is,

2n+1≥b−aε.2^{n+1} \ge \frac{b - a}{\varepsilon}.
Example 3.8How many steps?✓ Checked

How many steps of bisection, starting from [1,2],[1, 2]\mathclose{\text{,}} guarantee that the midpoint mnm_n is within 10−610^{-6} of 2?\sqrt2\mathclose{\text{?}}

Here b−a=1,b - a = 1\mathclose{\text{,}} so the condition is 2n+1≥106.2^{n+1} \ge 10^6\mathclose{\text{.}} Since 219=524,2882^{19} = 524{,}288 is too small and 220=1,048,5762^{20} = 1{,}048{,}576 is large enough, n+1=20:n + 1 = 20\mathclose{\text{:}} after n=19n = 19 steps, m19m_{19} is within 2−20≈9.5×10−72^{-20} \approx 9.5 \times 10^{-7} of 2.\sqrt2\mathclose{\text{.}} In terms of logarithms, n+1≥log⁡2106≈19.93.n + 1 \ge \log_2 10^6 \approx 19.93\mathclose{\text{.}}

Each step gains one binary digit. Since 210=1024≈103,2^{10} = 1024 \approx 10^3\mathclose{\text{,}} ten steps gain about three decimal digits, so each decimal digit costs about 3.33.3 steps. Bisection is binary search on the number line, and the count is the one of Section 1.4: binary search in a sorted list of a million items takes about 20 steps for the same reason.

Strengths and weaknesses. Bisection always works when its hypotheses hold, with a guaranteed error. But it is slow, one binary digit per step whatever the function; Newton’s method (Module 7) usually doubles the number of correct digits at every step, though it can fail. Bisection needs a sign change, so it cannot find a root where the graph touches the axis without crossing it, as (x−1)2(x - 1)^2 does at 1; and when a bracket contains several roots, it finds only one.

Watch out

The bisection method needs continuity, as the theorem behind it does. On [1,2],[1, 2]\mathclose{\text{,}} f(x)=tan⁡xf(x) = \tan x has f(1)≈1.557>0f(1) \approx 1.557 > 0 and f(2)≈−2.185<0,f(2) \approx -2.185 < 0\mathclose{\text{,}} and bisection closes in on 1.5708…=π/2,1.5708\ldots = \pi/2\mathclose{\text{,}} the asymptote, where tan⁡x\tan x has no root at all. The warning sign is in the values f(mn):f(m_n)\mathclose{\text{:}} instead of shrinking towards 0, they grow in size, from f(m0)≈14.1f(m_0) \approx 14.1 to f(m3)≈120.5f(m_3) \approx 120.5 and f(m6)≈2067.f(m_6) \approx 2067\mathclose{\text{.}} Try it in the widget below.

Try it

Start with x2−2x^2 - 2 on [1,2].[1, 2]\mathclose{\text{.}} Press Step six times and compare the table with Example 3.7; the shaded band is the bracket. Press Run 10 steps: how many decimals of 2\sqrt2 are certain now? Choose x3−2x−5x^3 - 2x - 5 on [2,3][2, 3] (Example 3.5) and cos⁡x−x\cos x - x on [0,1][0, 1] (Example 3.6). For x2−2,x^2 - 2\mathclose{\text{,}} set a=−2:a = -2\mathclose{\text{:}} f(−2)f(-2) and f(2)f(2) have the same sign, so the method cannot start, although [−2,2][-2, 2] contains two roots. Choose x3−xx^3 - x on [−2,3],[-2, 3]\mathclose{\text{,}} which contains three roots: which one does the method find? Finally choose tan⁡x\tan x on [1,2][1, 2] and watch what happens without continuity.

Compute itThe bisection method in Python

The method takes a few lines of Python. This function runs n steps and returns the final bracket, or the pair (m, m) if it meets an exact root m:

Python
def bisection(f, a, b, n):
    """n steps of the bisection method on [a, b]; returns the last bracket."""
    if f(a) * f(b) >= 0:
        raise ValueError("f(a) and f(b) must have opposite signs")
    for _ in range(n):
        m = (a + b) / 2
        if f(m) == 0:
            return m, m                    # an exact root
        if (f(m) > 0) == (f(a) > 0):       # same sign as f(a): keep [m, b]
            a = m
        else:                              # otherwise keep [a, m]
            b = m
    return a, b

print(bisection(lambda x: x**2 - 2, 1, 2, 6))
Output
(1.40625, 1.421875)

That is the bracket [a6,b6][a_6, b_6] of Example 3.7. By Example 3.8, 19 steps give 2\sqrt2 to within 10−6;10^{-6}\mathclose{\text{;}} compare the midpoint’s real error with the guarantee 2−20:2^{-20}\mathclose{\text{:}}

Python
import math
a, b = bisection(lambda x: x**2 - 2, 1, 2, 19)
m = (a + b) / 2
print(m, abs(m - math.sqrt(2)), 2**-20)
Output
1.4142141342163086 5.718432134482754e-07 9.5367431640625e-07

The real error is smaller than the guarantee, as it often is. The same function solves the equations of Examples 3.5 and 3.6, x3−2x−5=0x^3 - 2x - 5 = 0 and cos⁡x=x.\cos x = x\mathclose{\text{.}} After 30 steps from an interval of width 1, each midpoint is within 2−31≈4.7×10−102^{-31} \approx 4.7 \times 10^{-10} of a root:

Python
a, b = bisection(lambda x: x**3 - 2*x - 5, 2, 3, 30)
print((a + b) / 2)
a, b = bisection(lambda x: math.cos(x) - x, 0, 1, 30)
print((a + b) / 2)
Output
2.094551481772214
0.7390851336531341

Without a sign change the method refuses to start. (x−1)2(x - 1)^2 has a root at 1, but it is positive on both sides:

Pythonraises an error on purpose
bisection(lambda x: (x - 1)**2, 0, 3, 10)
Error
ValueError: f(a) and f(b) must have opposite signs

Finally, floating-point numbers (Module 2) set a limit. Between 1 and 2 they are 2−52≈2.2×10−162^{-52} \approx 2.2 \times 10^{-16} apart, so after 52 steps from [1,2][1, 2] the ends of the bracket are neighbouring floating-point numbers, and further steps change nothing:

Python
a, b = bisection(lambda x: x**2 - 2, 1, 2, 60)
print(a, b, b - a)
Output
1.414213562373095 1.4142135623730951 2.220446049250313e-16
5

The Extreme Value Theorem

Over a whole day, from midnight to midnight, the outside temperature has a highest value and a lowest value, each reached at some moment of the day. That is not a fact about the weather: it holds for every continuous function on a closed interval.

Definition 3.5Maximum and minimum values

Let ff be defined on an interval I.I\mathclose{\text{.}} The number f(c),f(c)\mathclose{\text{,}} for a cc in I,I\mathclose{\text{,}} is the maximum value of ff on II if f(x)≤f(c)f(x) \le f(c) for every xx in I.I\mathclose{\text{.}} The number f(d),f(d)\mathclose{\text{,}} for a dd in I,I\mathclose{\text{,}} is the minimum value of ff on II if f(x)≥f(d)f(x) \ge f(d) for every xx in I.I\mathclose{\text{.}} Together they are the extreme values of ff on I.I\mathclose{\text{.}}

A maximum value must be a value: a number f(c)f(c) that ff actually takes, not merely a number that the values approach. Module 8 calls these the absolute maximum and minimum, and finds them with derivatives.

Theorem 3.8The Extreme Value Theorem

If ff is continuous on a closed interval [a,b],[a, b]\mathclose{\text{,}} then ff has a maximum value and a minimum value on [a,b]:[a, b]\mathclose{\text{:}} there are numbers cc and dd in [a,b][a, b] such that, for every xx in [a,b],[a, b]\mathclose{\text{,}}

f(d)≤f(x)≤f(c).f(d) \le f(x) \le f(c).

Its proof also rests on the completeness of the real numbers, but takes more work than the proof of the Intermediate Value Theorem; it belongs to a course in real analysis, and this series uses the theorem without proof. What you can see now is why each hypothesis is needed (Figure 3.4):

  • A closed interval. f(x)=xf(x) = x is continuous on the open interval (0,1)(0, 1) but has no maximum value there: for any xx in (0,1),(0, 1)\mathclose{\text{,}} the number x+12\tfrac{x + 1}{2} is in (0,1)(0, 1) too, and larger. The values approach 1, but the end where they would reach it is missing. Likewise there is no minimum value.
  • Continuity. On [0,1],[0, 1]\mathclose{\text{,}} let f(x)=xf(x) = x for 0≤x<10 \le x < 1 and f(1)=0.f(1) = 0\mathclose{\text{.}} Again the values approach 1 without reaching it: at 1, where ff is not continuous from the left, the value drops to 0. This ff has the minimum value 0, but no maximum value.
  • A bounded interval. [0,∞)[0, \infty) contains its endpoint but has no right end, so it is not a closed interval [a,b].[a, b]\mathclose{\text{.}} On it, f(x)=xx+1=1−1x+1f(x) = \dfrac{x}{x + 1} = 1 - \dfrac{1}{x + 1} is continuous, and it increases as xx increases, creeping up towards 1 (Section 3.7) without reaching it. Every value is beaten by a later one: no maximum value.
The Extreme Value Theorem. Left: f(x) = x^2 - 4x + 1 is continuous on the closed interval [0, 3] and reaches a maximum value 1 (at 0) and a minimum value -3 (at 2), as Example 3.9 shows. Centre: x on the open interval (0, 1) has neither; the hollow dots are the missing ends. Right: f(x) = x for 0 le x < 1 and f(1) = 0 is not continuous at 1, and its values approach 1 without reaching it.
Figure 3.4

The Extreme Value Theorem. Left: f(x)=x2−4x+1f(x) = x^2 - 4x + 1 is continuous on the closed interval [0,3][0, 3] and reaches a maximum value 1 (at 0) and a minimum value −3-3 (at 2), as Example 3.9 shows. Centre: xx on the open interval (0,1)(0, 1) has neither; the hollow dots are the missing ends. Right: f(x)=xf(x) = x for 0≤x<10 \le x < 1 and f(1)=0f(1) = 0 is not continuous at 1, and its values approach 1 without reaching it.

The theorem says that extreme values exist, not where: at an end of the interval, like the maximum in Figure 3.4, or inside it, like the minimum. In optimisation it guarantees that a best choice exists: a cost that depends continuously on a setting has a cheapest setting in every closed interval of settings. Module 8 shows how to find it.

Example 3.9Does the theorem apply?✓ Checked

Decide whether the Extreme Value Theorem guarantees a maximum and a minimum value, and find them where you can.

  • (a) f(x)=x2−4x+1f(x) = x^2 - 4x + 1 on [0,3][0, 3]
  • (b) g(x)=1x−1g(x) = \dfrac{1}{x - 1} on [2,4][2, 4]
  • (c) the same gg on [0,2][0, 2]

(a) ff is a polynomial, continuous on the closed interval [0,3],[0, 3]\mathclose{\text{,}} so the theorem guarantees both. To find them, complete the square: f(x)=(x−2)2−3.f(x) = (x - 2)^2 - 3\mathclose{\text{.}} Since (x−2)2≥0,(x - 2)^2 \ge 0\mathclose{\text{,}} with equality only at x=2,x = 2\mathclose{\text{,}} the minimum value is f(2)=−3.f(2) = -3\mathclose{\text{.}} On [0,3],[0, 3]\mathclose{\text{,}} (x−2)2(x - 2)^2 is largest where xx is farthest from 2, at x=0,x = 0\mathclose{\text{,}} so the maximum value is f(0)=1.f(0) = 1\mathclose{\text{.}} (At the other end, f(3)=−2.)f(3) = -2\mathclose{\text{.)}}

(b) gg is continuous wherever x≠1,x \ne 1\mathclose{\text{,}} in particular on the closed interval [2,4],[2, 4]\mathclose{\text{,}} so the theorem applies. As xx increases, x−1x - 1 increases and 1x−1\dfrac{1}{x - 1} decreases, so the maximum value is g(2)=1g(2) = 1 and the minimum value is g(4)=13.g(4) = \tfrac13\mathclose{\text{.}}

(c) gg is not defined at 1, which lies in [0,2],[0, 2]\mathclose{\text{,}} so gg is not continuous on [0,2],[0, 2]\mathclose{\text{,}} and the theorem does not apply. Indeed gg has no extreme values there: as xx approaches 1 from the right, 1x−1\dfrac{1}{x - 1} grows beyond any number you might propose as a maximum, and from the left it falls below any proposed minimum.

Watch out

Two slips. “ff is continuous on (0,1),(0, 1)\mathclose{\text{,}} so it has a maximum” is wrong, as f(x)=xf(x) = x shows: the theorem needs a closed interval [a,b].[a, b]\mathclose{\text{.}} And when the hypotheses fail, the theorem says nothing either way: on the open interval (−1,2),(-1, 2)\mathclose{\text{,}} x2x^2 has the minimum value 0, though no maximum value.

6

Infinite limits and vertical asymptotes

Module 1 noted that the values of 1/x1/x “become huge” near 0, “positive on the right and negative on the left”, and promised that this module would study such behaviour. Here are the numbers, for 1/x1/x and 1/x2:1/x^2\mathclose{\text{:}}

xx1x\dfrac{1}{x}1x2\dfrac{1}{x^2}
−0.1-0.1−10-10100100
−0.01-0.01−100-1001000010000
−0.001-0.001−1000-10001×1061\times10^{6}
0.0010.001100010001×1061\times10^{6}
0.010.011001001000010000
0.10.11010100100

As xx approaches 0 from either side, 1/x21/x^2 passes 100, 10,000, a million, and any bound MM you choose, and stays above it. Module 2 showed that no number is its limit; but the limit fails to exist in such a definite way that it gets its own notation.

Definition 3.6Infinite limits and vertical asymptotes

Let ff be defined on an open interval containing a,a\mathclose{\text{,}} except perhaps at aa itself. Then

lim⁡x→af(x)=∞,\lim_{x\to a} f(x) = \infty,

read “the limit of ff of xx as xx approaches aa is infinity”, means that, whatever number MM you choose, f(x)>Mf(x) > M for every x≠ax \ne a close enough to aa (how close depends on M).M\mathclose{\text{).}} Likewise lim⁡x→af(x)=−∞\lim_{x\to a} f(x) = -\infty means that, whatever number MM you choose, f(x)<Mf(x) < M for every x≠ax \ne a close enough to a.a\mathclose{\text{.}} One-sided infinite limits, such as lim⁡x→a+f(x)=∞,\lim_{x\to a^+} f(x) = \infty\mathclose{\text{,}} look only at xx on one side of a.a\mathclose{\text{.}}

The line x=ax = a is a vertical asymptote of the graph of ff if at least one of the one-sided limits lim⁡x→a−f(x)\lim_{x\to a^-} f(x) and lim⁡x→a+f(x)\lim_{x\to a^+} f(x) is ∞\infty or −∞.-\infty\mathclose{\text{.}}

So lim⁡x→01/x2=∞.\lim_{x\to0} 1/x^2 = \infty\mathclose{\text{.}} For 1/x1/x the two sides disagree,

lim⁡x→0+1x=∞,lim⁡x→0−1x=−∞,\lim_{x\to0^+}\frac1x = \infty, \qquad \lim_{x\to0^-}\frac1x = -\infty,

and 1/x1/x has no limit at 0, not even an infinite one. Both graphs have the vertical asymptote x=0:x = 0\mathclose{\text{:}} near it the graph runs alongside the line, up or down without end. Writing lim⁡f(x)=∞\lim f(x) = \infty does not make ∞\infty a number. The limit still does not exist; the notation records how it fails.

Most vertical asymptotes come from a fraction whose denominator tends to 0 while its numerator does not. A non-zero number divided by a tiny one is huge, and the signs decide whether it is huge and positive or huge and negative:

Theorem 3.9Non-zero over zero

Suppose that lim⁡x→a+f(x)=L,\lim_{x\to a^+} f(x) = L\mathclose{\text{,}} a number with L≠0,L \ne 0\mathclose{\text{,}} and lim⁡x→a+g(x)=0.\lim_{x\to a^+} g(x) = 0\mathclose{\text{.}} If g(x)>0g(x) > 0 for every xx in some interval (a,a+δ),(a, a + \delta)\mathclose{\text{,}} then

lim⁡x→a+f(x)g(x)=∞if L>0,lim⁡x→a+f(x)g(x)=−∞if L<0.\begin{aligned} \lim_{x\to a^+}\frac{f(x)}{g(x)} &= \infty \quad \text{if } L > 0, \\ \lim_{x\to a^+}\frac{f(x)}{g(x)} &= -\infty \quad \text{if } L < 0. \end{aligned}

If instead g(x)<0g(x) < 0 on such an interval, the two signs swap. The same holds for limits from the left and for two-sided limits.

Proof

Take L>0L > 0 and g(x)>0;g(x) > 0\mathclose{\text{;}} the other cases are alike. Since f(x)→L,f(x) \to L\mathclose{\text{,}} for xx close enough to aa (and greater than a)a\mathclose{\text{)}} f(x)f(x) is within L2\tfrac{L}{2} of L,L\mathclose{\text{,}} so f(x)>L2.f(x) > \tfrac{L}{2}\mathclose{\text{.}} Now let M>0M > 0 be any number. Since g(x)→0g(x) \to 0 through positive values, for xx close enough to aa also 0<g(x)<L2M.0 < g(x) < \tfrac{L}{2M}\mathclose{\text{.}} For such x,x\mathclose{\text{,}} both hold, and

f(x)g(x)>L/2L/(2M)=M.\frac{f(x)}{g(x)} > \frac{L/2}{L/(2M)} = M.

So f(x)/g(x)f(x)/g(x) exceeds every MM once xx is close enough to a:a\mathclose{\text{:}} its limit is ∞.\infty\mathclose{\text{.}}

∎
Example 3.10One-sided infinite limits✓ Checked

Find the one-sided limits and the vertical asymptotes of (a) r(x)=x2−4x2−x−2r(x) = \dfrac{x^2 - 4}{x^2 - x - 2} at −1;-1\mathclose{\text{;}} (b) ln⁡x\ln x at 0; (c) tan⁡x\tan x at π/2.\pi/2\mathclose{\text{.}}

(a) For xx near −1-1 (and x≠−1),x \ne -1\mathclose{\text{),}} r(x)=x+2x+1r(x) = \dfrac{x + 2}{x + 1} (Example 3.2). The numerator tends to 1, which is positive, and the denominator to 0. For xx slightly greater than −1,-1\mathclose{\text{,}} x+1>0;x + 1 > 0\mathclose{\text{;}} for xx slightly less, x+1<0.x + 1 < 0\mathclose{\text{.}} By Theorem 3.9,

lim⁡x→−1+r(x)=∞,lim⁡x→−1−r(x)=−∞,\begin{aligned} \lim_{x\to-1^+} r(x) &= \infty, \\ \lim_{x\to-1^-} r(x) &= -\infty, \end{aligned}

and the line x=−1x = -1 is a vertical asymptote. The other zero of the denominator, 2, gives no asymptote: there the limit is 43\tfrac43 (Example 3.2), and the graph has a hole.

(b) ln⁡x\ln x is defined only for x>0,x > 0\mathclose{\text{,}} so only the limit from the right makes sense. Since ln⁡\ln is increasing and ln⁡e−M=−M,\ln e^{-M} = -M\mathclose{\text{,}} ln⁡x\ln x is less than −M-M exactly when 0<x<e−M.0 < x < e^{-M}\mathclose{\text{.}} So ln⁡x\ln x falls below any number −M-M once xx is close enough to 0:

lim⁡x→0+ln⁡x=−∞,\lim_{x\to0^+}\ln x = -\infty,

and the yy-axis is a vertical asymptote of y=ln⁡x,y = \ln x\mathclose{\text{,}} as in Figure 1.3.

(c) As x→π/2,x \to \pi/2\mathclose{\text{,}} sin⁡x→1\sin x \to 1 and cos⁡x→0.\cos x \to 0\mathclose{\text{.}} On the unit circle, cos⁡x\cos x is positive for xx slightly less than π/2\pi/2 and negative for xx slightly greater. By Theorem 3.9,

lim⁡x→π/2−tan⁡x=∞,lim⁡x→π/2+tan⁡x=−∞,\begin{aligned} \lim_{x\to\pi/2^-}\tan x &= \infty, \\ \lim_{x\to\pi/2^+}\tan x &= -\infty, \end{aligned}

so x=π/2x = \pi/2 is a vertical asymptote of y=tan⁡x,y = \tan x\mathclose{\text{,}} and so is every line x=π/2+kπ,x = \pi/2 + k\pi\mathclose{\text{,}} since tan⁡\tan has period π.\pi\mathclose{\text{.}}

Watch out

∞\infty is not a number, so do not calculate with it. If f(x)→∞f(x) \to \infty and g(x)→∞,g(x) \to \infty\mathclose{\text{,}} then f(x)−g(x)f(x) - g(x) can do anything. As x→0,x \to 0\mathclose{\text{,}} 1x2+1\dfrac{1}{x^2} + 1 and 1x2\dfrac{1}{x^2} both tend to ∞,\infty\mathclose{\text{,}} and their difference is 1; 2x2\dfrac{2}{x^2} and 1x2\dfrac{1}{x^2} both tend to ∞,\infty\mathclose{\text{,}} their difference 1x2\dfrac{1}{x^2} tends to ∞,\infty\mathclose{\text{,}} and their quotient is 2. So “∞−∞=0\infty - \infty = 0” and “∞/∞=1\infty/\infty = 1” are wrong. Such forms are indeterminate: their value depends on the functions, and Module 7 shows how to find it. And do not write lim⁡x→01/x=∞:\lim_{x\to0} 1/x = \infty\mathclose{\text{:}} the two sides disagree.

7

Limits at infinity and asymptotes

Now let x,x\mathclose{\text{,}} rather than f(x),f(x)\mathclose{\text{,}} grow without bound. Here is the function rr of Example 3.2 far from the origin:

xxr(x)=x2−4x2−x−2r(x) = \dfrac{x^2 - 4}{x^2 - x - 2}
−1000-10000.9989990.998999
−100-1000.9898990.989899
−10-100.8888890.888889
10101.090911.09091
1001001.009901.00990
100010001.001001.00100

As xx grows, positive or negative, r(x)r(x) settles down to 1: from above for large positive x,x\mathclose{\text{,}} from below for large negative x.x\mathclose{\text{.}} The cancelled form shows why: for x≠2x \ne 2 and x≠−1,x \ne -1\mathclose{\text{,}}

r(x)=x+2x+1=1+1x+1,r(x) = \frac{x + 2}{x + 1} = 1 + \frac{1}{x + 1},

and 1x+1\dfrac{1}{x + 1} shrinks towards 0 as xx grows in size. It is positive when x>−1x > -1 and negative when x<−1,x < -1\mathclose{\text{,}} which is why r(x)r(x) approaches 1 from above on the right and from below on the left.

Definition 3.7Limits at infinity and horizontal asymptotes

Let ff be defined on an interval (c,∞).(c, \infty)\mathclose{\text{.}} Then

lim⁡x→∞f(x)=L,\lim_{x\to\infty} f(x) = L,

read “the limit of ff of xx as xx tends to infinity is LL”, means that f(x)f(x) can be made as close to LL as you like by taking xx large enough. For ff defined on an interval (−∞,c),(-\infty, c)\mathclose{\text{,}} lim⁡x→−∞f(x)=L\lim_{x\to-\infty} f(x) = L means the same, with xx negative and large enough in size. The line y=Ly = L is a horizontal asymptote of the graph of ff if lim⁡x→∞f(x)=L\lim_{x\to\infty} f(x) = L or lim⁡x→−∞f(x)=L.\lim_{x\to-\infty} f(x) = L\mathclose{\text{.}}

Similarly, lim⁡x→∞f(x)=∞\lim_{x\to\infty} f(x) = \infty means that, whatever number MM you choose, f(x)>Mf(x) > M for every large enough x;x\mathclose{\text{;}} and so on for −∞.-\infty\mathclose{\text{.}}

So the line y=1y = 1 is a horizontal asymptote of r,r\mathclose{\text{,}} at both ends (Figure 3.5). The limit laws, the squeeze theorem and Theorem 3.4 all hold for limits at infinity, with the same proofs.

Everything rests on one basic limit: for every p>0,p > 0\mathclose{\text{,}}

lim⁡x→∞1xp=0.\lim_{x\to\infty}\frac{1}{x^p} = 0.

Indeed, for x>0,x > 0\mathclose{\text{,}} 1xp<ε\dfrac{1}{x^p} < \varepsilon exactly when xp>1ε,x^p > \dfrac{1}{\varepsilon}\mathclose{\text{,}} that is, when x>ε−1/p;x > \varepsilon^{-1/p}\mathclose{\text{;}} so 1/xp1/x^p is within ε\varepsilon of 0 for every large enough x.x\mathclose{\text{.}} For whole numbers k≥1k \ge 1 also 1/xk→01/x^k \to 0 as x→−∞,x \to -\infty\mathclose{\text{,}} since ∣1/xk∣=1/∣x∣k.\abs{1/x^k} = 1/\abs{x}^k\mathclose{\text{.}}

Rational functions

To find the limit of a rational function at infinity, divide the numerator and the denominator by the highest power of xx in the denominator; then every term with xx left in its denominator tends to 0. Only the leading terms matter:

Theorem 3.10Rational functions at infinity

Let

f(x)=amxm+⋯+a1x+a0bnxn+⋯+b1x+b0,f(x) = \frac{a_m x^m + \dots + a_1x + a_0}{b_n x^n + \dots + b_1x + b_0},

with am≠0a_m \ne 0 and bn≠0,b_n \ne 0\mathclose{\text{,}} so that the numerator has degree mm and the denominator degree n.n\mathclose{\text{.}} As x→∞,x \to \infty\mathclose{\text{,}} and also as x→−∞,x \to -\infty\mathclose{\text{,}} f(x)f(x) behaves like the ratio of the leading terms, amxmbnxn:\dfrac{a_m x^m}{b_n x^n}\mathclose{\text{:}}

  • if m<n,m < n\mathclose{\text{,}} then f(x)→0,f(x) \to 0\mathclose{\text{,}} and the xx-axis is a horizontal asymptote;
  • if m=n,m = n\mathclose{\text{,}} then f(x)→ambn,f(x) \to \dfrac{a_m}{b_n}\mathclose{\text{,}} and the line y=ambny = \dfrac{a_m}{b_n} is a horizontal asymptote;
  • if m>n,m > n\mathclose{\text{,}} then f(x)→∞f(x) \to \infty or −∞,-\infty\mathclose{\text{,}} with the sign of ambnxm−n,\dfrac{a_m}{b_n}x^{m-n}\mathclose{\text{,}} and there is no horizontal asymptote.
Proof

For x≠0,x \ne 0\mathclose{\text{,}} take the leading term out of the numerator and out of the denominator:

f(x)=amxmbnxn⋅Q(x),whereQ(x)=1+c1/x+⋯+cm/xm1+d1/x+⋯+dn/xn\begin{aligned} f(x) &= \frac{a_m x^m}{b_n x^n} \cdot Q(x), \quad\text{where} \\ Q(x) &= \frac{1 + c_1/x + \dots + c_m/x^m}{1 + d_1/x + \dots + d_n/x^n} \end{aligned}

and ck=am−k/amc_k = a_{m-k}/a_m and dk=bn−k/bnd_k = b_{n-k}/b_n are constants. As x→±∞,x \to \pm\infty\mathclose{\text{,}} every term ck/xkc_k/x^k and dk/xkd_k/x^k tends to 0, so Q(x)Q(x) tends to 1+0+⋯+01+0+⋯+0=1.\dfrac{1 + 0 + \dots + 0}{1 + 0 + \dots + 0} = 1\mathclose{\text{.}} The first fraction equals ambnxm−n:\dfrac{a_m}{b_n}x^{m-n}\mathclose{\text{:}} it tends to 0 if m<n,m < n\mathclose{\text{,}} it is the constant ambn\dfrac{a_m}{b_n} if m=n,m = n\mathclose{\text{,}} and it tends to ∞\infty or −∞-\infty if m>n.m > n\mathclose{\text{.}} In the last case the product of a factor that grows without bound and a factor that tends to 1 grows without bound, with the same sign.

∎
Example 3.11Rational functions at infinity✓ Checked

Find

  • (a) lim⁡x→∞6x3−5x+12x3+x2\displaystyle\lim_{x\to\infty}\frac{6x^3 - 5x + 1}{2x^3 + x^2}
  • (b) lim⁡x→−∞4x−7x2+1\displaystyle\lim_{x\to-\infty}\frac{4x - 7}{x^2 + 1}
  • (c) lim⁡x→−∞x3−23x2+5\displaystyle\lim_{x\to-\infty}\frac{x^3 - 2}{3x^2 + 5}

(a) The degrees are equal, 3 and 3. Divide the numerator and the denominator by x3:x^3\mathclose{\text{:}}

6x3−5x+12x3+x2=6−5/x2+1/x32+1/x→6−0+02+0=3.\begin{aligned} \frac{6x^3 - 5x + 1}{2x^3 + x^2} &= \frac{6 - 5/x^2 + 1/x^3}{2 + 1/x} \\ &\to \frac{6 - 0 + 0}{2 + 0} = 3. \end{aligned}

The line y=3y = 3 is a horizontal asymptote, as Theorem 3.10 predicts: 3=6/2,3 = 6/2\mathclose{\text{,}} the ratio of the leading coefficients.

(b) Degree 1 over degree 2: divide by x2:x^2\mathclose{\text{:}}

4x−7x2+1=4/x−7/x21+1/x2→0−01+0=0.\frac{4x - 7}{x^2 + 1} = \frac{4/x - 7/x^2}{1 + 1/x^2} \to \frac{0 - 0}{1 + 0} = 0.

The xx-axis is a horizontal asymptote (at both ends, since the same computation works as x→∞).x \to \infty\mathclose{\text{).}}

(c) Degree 3 over degree 2. The ratio of the leading terms is x33x2=x3,\dfrac{x^3}{3x^2} = \dfrac{x}{3}\mathclose{\text{,}} which tends to −∞-\infty as x→−∞.x \to -\infty\mathclose{\text{.}} So, by Theorem 3.10,

lim⁡x→−∞x3−23x2+5=−∞,\lim_{x\to-\infty}\frac{x^3 - 2}{3x^2 + 5} = -\infty,

and there is no horizontal asymptote on the left (nor on the right, where the limit is ∞).\infty\mathclose{\text{).}}

Roots need one more idea: x2=∣x∣,\sqrt{x^2} = \abs{x}\mathclose{\text{,}} not xx (the pitfall of Section 1.4), and for x<0,x < 0\mathclose{\text{,}} ∣x∣=−x.\abs{x} = -x\mathclose{\text{.}}

Example 3.12Two different horizontal asymptotes✓ Checked

Find the horizontal asymptotes of f(x)=4x2+1x−3.f(x) = \dfrac{\sqrt{4x^2 + 1}}{x - 3}\mathclose{\text{.}}

The leading term under the root is 4x2,4x^2\mathclose{\text{,}} so take x2x^2 out of the root: for x≠0,x \ne 0\mathclose{\text{,}}

4x2+1=x2(4+1x2)=∣x∣4+1x2.\begin{aligned} \sqrt{4x^2 + 1} &= \sqrt{x^2\Big(4 + \frac{1}{x^2}\Big)} \\ &= \abs{x}\sqrt{4 + \frac{1}{x^2}}. \end{aligned}

For x>3,x > 3\mathclose{\text{,}} ∣x∣=x;\abs{x} = x\mathclose{\text{;}} divide the numerator and the denominator by x.x\mathclose{\text{.}} As x→∞,x \to \infty\mathclose{\text{,}}

f(x)=4+1/x21−3/x→41=2,f(x) = \frac{\sqrt{4 + 1/x^2}}{1 - 3/x} \to \frac{\sqrt4}{1} = 2,

using the continuity of the square root at 4 (Theorem 3.4). For x<0,x < 0\mathclose{\text{,}} ∣x∣=−x,\abs{x} = -x\mathclose{\text{,}} and

f(x)=−x4+1/x2x−3=−4+1/x21−3/x,\begin{aligned} f(x) &= \frac{-x\sqrt{4 + 1/x^2}}{x - 3} \\ &= -\frac{\sqrt{4 + 1/x^2}}{1 - 3/x}, \end{aligned}

which tends to −4/1=−2-\sqrt4/1 = -2 as x→−∞.x \to -\infty\mathclose{\text{.}} So the graph has two horizontal asymptotes: y=2y = 2 on the right and y=−2y = -2 on the left. Forgetting the sign of ∣x∣\abs{x} gives the wrong answer 2 on the left. (There is also the vertical asymptote x=3,x = 3\mathclose{\text{,}} by Theorem 3.9: the numerator tends to 37≠0\sqrt{37} \ne 0 there.)

Exponentials, logarithms and oscillations

Exponentials. Let a>1,a > 1\mathclose{\text{,}} and write a=1+qa = 1 + q with q>0.q > 0\mathclose{\text{.}} Then an=(1+q)n≥1+nqa^n = (1 + q)^n \ge 1 + nq for every whole number n≥1.n \ge 1\mathclose{\text{.}} It is an equality for n=1;n = 1\mathclose{\text{;}} and if it holds for some n,n\mathclose{\text{,}} multiplying both sides by the positive number 1+q1 + q shows that it holds for n+1:n + 1\mathclose{\text{:}}

(1+q)n+1≥(1+nq)(1+q)=1+(n+1)q+nq2≥1+(n+1)q.\begin{aligned} (1 + q)^{n+1} &\ge (1 + nq)(1 + q) \\ &= 1 + (n + 1)q + nq^2 \\ &\ge 1 + (n + 1)q. \end{aligned}

So it holds for n=2,n = 2\mathclose{\text{,}} then for n=3,n = 3\mathclose{\text{,}} and so on for every n.n\mathclose{\text{.}} Hence ana^n exceeds any number MM once n>M/q,n > M/q\mathclose{\text{,}} and since axa^x increases with x,x\mathclose{\text{,}} for every a>1a > 1

lim⁡x→∞ax=∞,lim⁡x→−∞ax=lim⁡x→−∞1a−x=0.\begin{aligned} \lim_{x\to\infty} a^x &= \infty, \\ \lim_{x\to-\infty} a^x &= \lim_{x\to-\infty}\frac{1}{a^{-x}} = 0. \end{aligned}

For 0<a<10 < a < 1 the two limits are swapped. In particular ex→∞e^x \to \infty as x→∞x \to \infty and ex→0e^x \to 0 as x→−∞:x \to -\infty\mathclose{\text{:}} the xx-axis is a horizontal asymptote of y=exy = e^x on the left, as Figure 1.3 shows.

Logarithms. ln⁡x\ln x grows without bound too, but slowly: ln⁡x>M\ln x > M exactly when x>eM,x > e^M\mathclose{\text{,}} so ln⁡x→∞\ln x \to \infty as x→∞,x \to \infty\mathclose{\text{,}} yet to pass 100, xx must exceed e100≈2.7×1043.e^{100} \approx 2.7 \times 10^{43}\mathclose{\text{.}}

Oscillations. sin⁡x\sin x has no limit as x→∞:x \to \infty\mathclose{\text{:}} it keeps swinging between −1-1 and 1. But sin⁡xx→0,\dfrac{\sin x}{x} \to 0\mathclose{\text{,}} by the squeeze theorem: for x>0,x > 0\mathclose{\text{,}}

−1x≤sin⁡xx≤1x,-\frac1x \le \frac{\sin x}{x} \le \frac1x,

and both bounds tend to 0. In the same way e−xsin⁡x→0,e^{-x}\sin x \to 0\mathclose{\text{,}} squeezed between −e−x-e^{-x} and e−x:e^{-x}\mathclose{\text{:}} a damped oscillation, like the vibration of a plucked string or the current in a circuit after a switch is opened, dies away to 0.

Watch out

A graph can cross its horizontal asymptote, even infinitely often: sin⁡xx\dfrac{\sin x}{x} is 0 at every non-zero multiple of π.\pi\mathclose{\text{.}} An asymptote describes the graph far out; it is not a line that the graph never touches.

Oblique asymptotes

When the degree of the numerator is one more than that of the denominator, a rational function grows without bound, but in a definite direction: its graph approaches a slanted line.

Definition 3.8Oblique asymptote

The line y=mx+c,y = mx + c\mathclose{\text{,}} with m≠0,m \ne 0\mathclose{\text{,}} is an oblique asymptote (or slant asymptote) of the graph of ff if

lim⁡x→∞[f(x)−(mx+c)]=0orlim⁡x→−∞[f(x)−(mx+c)]=0.\begin{aligned} \lim_{x\to\infty}\big[f(x) - (mx + c)\big] &= 0 \quad\text{or} \\ \lim_{x\to-\infty}\big[f(x) - (mx + c)\big] &= 0. \end{aligned}

The bracket is the vertical distance between the graph and the line, and it shrinks to 0. For a rational function p/qp/q whose numerator has degree one more than its denominator, divide: p(x)=q(x)(mx+c)+s(x),p(x) = q(x)(mx + c) + s(x)\mathclose{\text{,}} with a remainder ss of lower degree than qq (polynomial long division from school algebra, or the trick in the next example). Then

p(x)q(x)=mx+c+s(x)q(x),\frac{p(x)}{q(x)} = mx + c + \frac{s(x)}{q(x)},

and s(x)q(x)→0\dfrac{s(x)}{q(x)} \to 0 as x→±∞x \to \pm\infty by Theorem 3.10, so y=mx+cy = mx + c is an oblique asymptote at both ends.

Example 3.13An oblique asymptote✓ Checked

Find the asymptotes of f(x)=x2+1x−1,f(x) = \dfrac{x^2 + 1}{x - 1}\mathclose{\text{,}} and decide on which side of each the graph lies.

Divide x2+1x^2 + 1 by x−1.x - 1\mathclose{\text{.}} Here a trick avoids long division: x2+1=(x2−1)+2=(x−1)(x+1)+2.x^2 + 1 = (x^2 - 1) + 2 = (x - 1)(x + 1) + 2\mathclose{\text{.}} So, for x≠1,x \ne 1\mathclose{\text{,}}

f(x)=x+1+2x−1.f(x) = x + 1 + \frac{2}{x - 1}.

As x→±∞,x \to \pm\infty\mathclose{\text{,}} 2x−1→0,\dfrac{2}{x - 1} \to 0\mathclose{\text{,}} so y=x+1y = x + 1 is an oblique asymptote at both ends. For x>1,x > 1\mathclose{\text{,}} 2x−1>0,\dfrac{2}{x - 1} > 0\mathclose{\text{,}} so the graph lies above the asymptote; for x<1,x < 1\mathclose{\text{,}} it lies below. At x=1x = 1 the numerator is 2≠02 \ne 0 and the denominator tends to 0, positive on the right and negative on the left, so by Theorem 3.9

lim⁡x→1+f(x)=∞,lim⁡x→1−f(x)=−∞,\lim_{x\to1^+} f(x) = \infty, \qquad \lim_{x\to1^-} f(x) = -\infty,

and x=1x = 1 is a vertical asymptote. There is no horizontal asymptote: f(x)→∞f(x) \to \infty as x→∞x \to \infty and f(x)→−∞f(x) \to -\infty as x→−∞.x \to -\infty\mathclose{\text{.}} Figure 3.5 shows the graph and its asymptotes.

Asymptotes. Left: r(x) = dfrac{x^2 - 4}{x^2 - x - 2} of Examples 3.2 and 3.10, with the vertical asymptote x = -1, the horizontal asymptote y = 1 and the hole at big(2, tfrac43big). Right: f(x) = dfrac{x^2 + 1}{x - 1} of Example 3.13, with the vertical asymptote x = 1 and the oblique asymptote y = x + 1; the graph lies above the oblique asymptote for x > 1 and below it for x < 1.
Figure 3.5

Asymptotes. Left: r(x)=x2−4x2−x−2r(x) = \dfrac{x^2 - 4}{x^2 - x - 2} of Examples 3.2 and 3.10, with the vertical asymptote x=−1,x = -1\mathclose{\text{,}} the horizontal asymptote y=1y = 1 and the hole at (2,43).\big(2, \tfrac43\big)\mathclose{\text{.}} Right: f(x)=x2+1x−1f(x) = \dfrac{x^2 + 1}{x - 1} of Example 3.13, with the vertical asymptote x=1x = 1 and the oblique asymptote y=x+1;y = x + 1\mathclose{\text{;}} the graph lies above the oblique asymptote for x>1x > 1 and below it for x<1.x < 1\mathclose{\text{.}}

Compute itAsymptotes and continuity with SymPy

In SymPy, ∞\infty is sp.oo. Here are the limits of Example 3.12 at both ends, and on both sides of 3:

Python
import sympy as sp
x = sp.symbols('x')
f = sp.sqrt(4*x**2 + 1)/(x - 3)
print(sp.limit(f, x, sp.oo), sp.limit(f, x, -sp.oo))
print(sp.limit(f, x, 3, '+'), sp.limit(f, x, 3, '-'))
Output
2 -2
oo -oo

As Module 2 warned, a one-sided limit needs its direction: without one, limit approaches from the right. To see where a function is continuous, continuous_domain lists the intervals; here is the function rr of Example 3.2:

Python
from sympy.calculus.util import continuous_domain
r = (x**2 - 4)/(x**2 - x - 2)
print(continuous_domain(r, x, sp.S.Reals))
Output
Union(Interval.open(-oo, -1), Interval.open(-1, 2), Interval.open(2, oo))

Interval.open(-oo, -1) is the open interval (−∞,−1):(-\infty, -1)\mathclose{\text{:}} rr is continuous everywhere except at −1-1 and 2. The answer does not say what kind of discontinuity each point is, and for complicated formulas continuous_domain can be wrong, so compare it with your own reasoning. For an oblique asymptote, sp.div divides one polynomial by another and returns the quotient and the remainder:

Python
q, s = sp.div(x**2 + 1, x - 1)                  # Example 3.13
print(q, s)
print(sp.limit((x**2 + 1)/(x - 1) - q, x, sp.oo))
Output
x + 1 2
0

The quotient x+1x + 1 is the asymptote, and the last line confirms that the distance to it tends to 0.

Going deeperThe precise definitions

Module 2 made “f(x)f(x) approaches LL as xx approaches aa” precise with ε and δ. The new limits of this module are made precise in the same way.

  • lim⁡x→af(x)=∞\lim_{x\to a} f(x) = \infty means: for every number MM there is a δ>0\delta > 0 such that f(x)>Mf(x) > M whenever 0<∣x−a∣<δ.0 < \abs{x - a} < \delta\mathclose{\text{.}}
  • lim⁡x→∞f(x)=L\lim_{x\to\infty} f(x) = L means: for every ε>0\varepsilon > 0 there is a number NN such that ∣f(x)−L∣<ε\abs{f(x) - L} < \varepsilon whenever x>N.x > N\mathclose{\text{.}}
  • lim⁡x→∞f(x)=∞\lim_{x\to\infty} f(x) = \infty means: for every number MM there is a number NN such that f(x)>Mf(x) > M whenever x>N.x > N\mathclose{\text{.}}

The other cases (−∞,-\infty\mathclose{\text{,}} one-sided limits, x→−∞)x \to -\infty\mathclose{\text{)}} change the inequalities in the obvious way. For example, lim⁡x→01/x2=∞:\lim_{x\to0} 1/x^2 = \infty\mathclose{\text{:}} given M>0,M > 0\mathclose{\text{,}} take δ=1/M;\delta = 1/\sqrt M\mathclose{\text{;}} if 0<∣x∣<δ,0 < \abs{x} < \delta\mathclose{\text{,}} then x2<δ2=1/M,x^2 < \delta^2 = 1/M\mathclose{\text{,}} so 1/x2>M.1/x^2 > M\mathclose{\text{.}}

8

Orders of growth

The functions ln⁡x,\ln x\mathclose{\text{,}} x2,x^2\mathclose{\text{,}} 2x2^x and the factorial all tend to ∞,\infty\mathclose{\text{,}} but at very different speeds, and the differences decide what a computer can do in practice. Compare them at a few whole numbers n.n\mathclose{\text{.}} Here n!,n!\mathclose{\text{,}} read “nn factorial”, is the product 1⋅2⋅3⋯n,1 \cdot 2 \cdot 3 \cdots n\mathclose{\text{,}} the number of ways to put nn objects in a row:

nn101020205050100100
log⁡2n\log_2 n3.3223.3224.3224.3225.6445.6446.6446.644
n2n^2100100400400250025001000010000
2n2^n102410241.049×1061.049\times10^{6}1.126×10151.126\times10^{15}1.268×10301.268\times10^{30}
n!n!3.629×1063.629\times10^{6}2.433×10182.433\times10^{18}3.041×10643.041\times10^{64}9.333×101579.333\times10^{157}

The logarithm barely moves, n2n^2 grows steadily, and 2n2^n and n!n! explode: 100!100! has 158 digits. To compare growth precisely, compare ratios.

Definition 3.9Orders of growth

Let ff and gg be positive for all large x.x\mathclose{\text{.}} Then ff grows more slowly than gg as x→∞,x \to \infty\mathclose{\text{,}} written f≪gf \ll g and read “f is much smaller than g”, if

lim⁡x→∞f(x)g(x)=0.\lim_{x\to\infty}\frac{f(x)}{g(x)} = 0.

For functions defined at whole numbers n,n\mathclose{\text{,}} such as n!,n!\mathclose{\text{,}} the limit as n→∞n \to \infty means the same, with nn running through 1,2,3,…;1, 2, 3, \dots\mathclose{\text{;}} Module 14 studies such limits of sequences.

So far out, ff is a negligible fraction of g:g\mathclose{\text{:}} eventually below 1%, or 0.0001%, or any fraction you name. Among powers, the higher power wins: xp≪xqx^p \ll x^q whenever p<q,p < q\mathclose{\text{,}} since xpxq=1xq−p→0.\dfrac{x^p}{x^q} = \dfrac{1}{x^{q-p}} \to 0\mathclose{\text{.}}

Theorem 3.11Orders of growth

For every p>0p > 0 and every a>1,a > 1\mathclose{\text{,}} as x→∞,x \to \infty\mathclose{\text{,}}

ln⁡x≪xp≪ax,\ln x \ll x^p \ll a^x,

and, as n→∞n \to \infty through the whole numbers,

an≪n!≪nn.a^n \ll n! \ll n^n.

Every logarithm loses to every positive power, every power to every exponential with base greater than 1, and every exponential to the factorial. The two comparisons with n!n! need only simple inequalities.

Proof of the comparisons with the factorial

For n!nn,\dfrac{n!}{n^n}\mathclose{\text{,}} write the top and the bottom as products of nn factors:

n!nn=1n⋅2n⋯nn≤1n,\frac{n!}{n^n} = \frac{1}{n}\cdot\frac{2}{n}\cdots\frac{n}{n} \le \frac{1}{n},

because every factor after the first is at most 1. Since 0<n!nn≤1n0 < \dfrac{n!}{n^n} \le \dfrac1n and 1n→0,\dfrac1n \to 0\mathclose{\text{,}} the squeeze theorem gives n!nn→0.\dfrac{n!}{n^n} \to 0\mathclose{\text{.}}

For ann!,\dfrac{a^n}{n!}\mathclose{\text{,}} choose a whole number N≥2a.N \ge 2a\mathclose{\text{.}} For n>N,n > N\mathclose{\text{,}} split off the first NN factors of the top and of the bottom:

ann!=aNN!⋅aN+1⋅aN+2⋯an≤aNN!(12)n−N,\begin{aligned} \frac{a^n}{n!} &= \frac{a^N}{N!}\cdot\frac{a}{N + 1}\cdot\frac{a}{N + 2}\cdots\frac{a}{n} \\ &\le \frac{a^N}{N!}\Big(\frac12\Big)^{n - N}, \end{aligned}

because each of the last n−Nn - N factors is at most aN≤12.\dfrac{a}{N} \le \dfrac12\mathclose{\text{.}} The number aNN!\dfrac{a^N}{N!} is fixed, and (12)n−N→0\big(\tfrac12\big)^{n-N} \to 0 (Section 3.7), so ann!→0\dfrac{a^n}{n!} \to 0 by the squeeze theorem.

∎

The comparisons ln⁡x≪xp≪ax\ln x \ll x^p \ll a^x take a little more work. Module 7 proves them in a few lines with L’Hôpital’s rule, and the Going deeper box below proves them with the tools of this module. Numbers make them believable now:

xxln⁡x\ln xx\sqrt{x}ln⁡xx\dfrac{\ln x}{\sqrt x}
10102.3032.3033.1623.1620.72810.7281
1001004.6054.60510100.46050.4605
10000100009.2109.2101001000.092100.09210
1000000100000013.8213.82100010000.013820.01382

At x=10x = 10 the logarithm is already smaller than x,\sqrt x\mathclose{\text{,}} and the ratio keeps shrinking: by x=106,x = 10^6\mathclose{\text{,}} ln⁡x\ln x is less than 1.4% of x.\sqrt x\mathclose{\text{.}}

Going deeperLogarithms, powers and exponentials compared

To show that xpax→0\dfrac{x^p}{a^x} \to 0 for p>0p > 0 and a>1,a > 1\mathclose{\text{,}} start with whole numbers nn and the terms un=npan.u_n = \dfrac{n^p}{a^n}\mathclose{\text{.}} The ratio of consecutive terms,

un+1un=(n+1)pan+1⋅annp=1a(1+1n)p,\frac{u_{n+1}}{u_n} = \frac{(n + 1)^p}{a^{n+1}}\cdot\frac{a^n}{n^p} = \frac1a\Big(1 + \frac1n\Big)^p,

tends to 1a<1\frac1a < 1 as n→∞,n \to \infty\mathclose{\text{,}} because tp=epln⁡tt^p = e^{p\ln t} is continuous at t=1t = 1 (Theorems 3.3 and 3.5). So for a number ρ\rho between 1a\frac1a and 1 (the Greek letter rho), say ρ=12(1+1a),\rho = \frac12\big(1 + \frac1a\big)\mathclose{\text{,}} the ratio is less than ρ\rho for every nn from some NN on, and

uN+k≤uN ρkfor k=1,2,3,…u_{N+k} \le u_N\,\rho^k \quad\text{for } k = 1, 2, 3, \dots

Since ρk=1/(1/ρ)k\rho^k = 1/(1/\rho)^k and 1/ρ>1,1/\rho > 1\mathclose{\text{,}} ρk→0\rho^k \to 0 (Section 3.7), so un→0.u_n \to 0\mathclose{\text{.}} For a real number x≥1,x \ge 1\mathclose{\text{,}} let n=⌊x⌋,n = \lfloor x\rfloor\mathclose{\text{,}} so that n≤x<n+1;n \le x < n + 1\mathclose{\text{;}} then xp<(n+1)px^p < (n + 1)^p and ax≥an,a^x \ge a^n\mathclose{\text{,}} so

0<xpax<(n+1)pan=a un+1,0 < \frac{x^p}{a^x} < \frac{(n + 1)^p}{a^n} = a\,u_{n+1},

and the squeeze theorem gives xpax→0.\dfrac{x^p}{a^x} \to 0\mathclose{\text{.}} For ln⁡xxp,\dfrac{\ln x}{x^p}\mathclose{\text{,}} substitute x=et:x = e^t\mathclose{\text{:}} as x→∞,x \to \infty\mathclose{\text{,}} t=ln⁡x→∞,t = \ln x \to \infty\mathclose{\text{,}} and ln⁡xxp=t(ep)t,\dfrac{\ln x}{x^p} = \dfrac{t}{(e^p)^t}\mathclose{\text{,}} which tends to 0 by the first part, with the power 1 and the base ep>1.e^p > 1\mathclose{\text{.}} Comparing consecutive terms, as here and for n!,n!\mathclose{\text{,}} is the idea behind the ratio test for series in Module 14.

Watch out

Small tables can mislead. Compare n10n^{10} with 2n:2^n\mathclose{\text{:}}

nnn10n^{10}2n2^nn102n\dfrac{n^{10}}{2^n}
10101×10101\times10^{10}102410249.766×1069.766\times10^{6}
30305.905×10145.905\times10^{14}1.074×1091.074\times10^{9}549900549900
58584.308×10174.308\times10^{17}2.882×10172.882\times10^{17}1.4951.495
59595.111×10175.111\times10^{17}5.765×10175.765\times10^{17}0.88660.8866
1001001×10201\times10^{20}1.268×10301.268\times10^{30}7.889×10−117.889\times10^{-11}

For every nn from 2 to 58, n10n^{10} is the larger; only at n=59n = 59 does 2n2^n overtake it, and from then on it stays ahead while the ratio plunges. “Eventually” can be far away: n100n^{100} stays ahead of 1.01n1.01^n for every nn from 2 to 117,308. A comparison f≪gf \ll g says who wins in the end, not when.

Big-O notation and algorithms

Computer scientists compare algorithms by how their running time grows with the size nn of the input, such as the number of items to sort. Constant factors depend on the computer and the programmer, so the comparison ignores them.

Definition 3.10Big-O notation

Let ff and gg be functions of a whole number n.n\mathclose{\text{.}} Then f(n)=O(g(n))f(n) = O\big(g(n)\big) as n→∞,n \to \infty\mathclose{\text{,}} read “ff of nn is big-O of gg of nn”, if there are constants CC and NN such that

∣f(n)∣≤C ∣g(n)∣for every n≥N.\abs{f(n)} \le C\,\abs{g(n)} \quad\text{for every } n \ge N.

So f=O(g)f = O(g) says that ff grows no faster than a constant multiple of g;g\mathclose{\text{;}} constant factors, and small n,n\mathclose{\text{,}} do not matter. It is only an upper bound: n=O(n2)n = O(n^2) is true, if not informative. (The notation is also used as h→0:h \to 0\mathclose{\text{:}} Module 4 measures errors that way.) Limits give a quick test: if f(n)/g(n)f(n)/g(n) tends to a number L,L\mathclose{\text{,}} then f=O(g),f = O(g)\mathclose{\text{,}} since eventually ∣f(n)/g(n)∣<∣L∣+1.\abs{f(n)/g(n)} < \abs{L} + 1\mathclose{\text{.}} In particular f≪gf \ll g implies f=O(g),f = O(g)\mathclose{\text{,}} but then gg is not O(f),O(f)\mathclose{\text{,}} because g(n)/f(n)g(n)/f(n) grows without bound.

Example 3.14A big-O bound✓ Checked

Show that 3n2+5n+7=O(n2),3n^2 + 5n + 7 = O(n^2)\mathclose{\text{,}} and that n2n^2 is not O(n).O(n)\mathclose{\text{.}}

For n≥1,n \ge 1\mathclose{\text{,}} n≤n2n \le n^2 and 1≤n2,1 \le n^2\mathclose{\text{,}} so

3n2+5n+7≤3n2+5n2+7n2=15n2.\begin{aligned} 3n^2 + 5n + 7 &\le 3n^2 + 5n^2 + 7n^2 \\ &= 15n^2. \end{aligned}

That is the definition, with C=15C = 15 and N=1.N = 1\mathclose{\text{.}} The limit test gives the same: 3n2+5n+7n2=3+5n+7n2→3.\dfrac{3n^2 + 5n + 7}{n^2} = 3 + \dfrac5n + \dfrac{7}{n^2} \to 3\mathclose{\text{.}} The lower-order terms 5n+75n + 7 and the factor 3 do not matter.

On the other hand, n2n=n\dfrac{n^2}{n} = n grows without bound, so no constant CC gives n2≤Cnn^2 \le Cn for all large n:n\mathclose{\text{:}} n2n^2 is not O(n).O(n)\mathclose{\text{.}}

The common orders of growth in algorithm analysis, from the slowest-growing to the fastest:

Order Name Where it arises
O(log⁡2n)O(\log_2 n) logarithmic binary search: halve a sorted list at each step
O(n)O(n) linear one look at each item, as in finding the largest
O(nlog⁡2n)O(n\log_2 n) linearithmic sorting by merge sort
O(n2)O(n^2) quadratic comparing every pair of items
O(2n)O(2^n) exponential trying every subset of the items
O(n!)O(n!) factorial trying every order of the items

The base of a logarithm does not matter inside O:O\mathclose{\text{:}} log⁡2n=ln⁡nln⁡2\log_2 n = \dfrac{\ln n}{\ln 2} is a constant multiple of ln⁡n,\ln n\mathclose{\text{,}} so computer scientists often write O(log⁡n)O(\log n) without a base. Theorem 3.11 puts the orders of the table in a chain,

log⁡2n≪n≪nlog⁡2n≪n2≪2n≪n!,\log_2 n \ll n \ll n\log_2 n \ll n^2 \ll 2^n \ll n!,

since nnlog⁡2n=1log⁡2n→0\dfrac{n}{n\log_2 n} = \dfrac{1}{\log_2 n} \to 0 and nlog⁡2nn2=log⁡2nn→0.\dfrac{n\log_2 n}{n^2} = \dfrac{\log_2 n}{n} \to 0\mathclose{\text{.}}

What this means in practice: suppose, hypothetically, that a computer performs 10910^9 basic steps per second. For n=100,n = 100\mathclose{\text{,}} an algorithm that takes n2n^2 steps finishes in 10 microseconds; one that takes 2n2^n steps, about 1.27×1030,1.27 \times 10^{30}\mathclose{\text{,}} needs about 4.0×10134.0 \times 10^{13} years, and one that takes n!n! steps about 3×101413 \times 10^{141} years. Faster hardware does not rescue an exponential algorithm: a computer twice as fast lets a 2n2^n algorithm handle only one more item in the same time, since 2n+1=2⋅2n,2^{n+1} = 2 \cdot 2^n\mathclose{\text{,}} while an n2n^2 algorithm handles 2≈1.41\sqrt2 \approx 1.41 times as many, since (2 n)2=2n2.(\sqrt2\,n)^2 = 2n^2\mathclose{\text{.}}

Watch out

Big-O hides constant factors, and for small nn they matter. An algorithm that takes 100 nlog⁡2n100\,n\log_2 n steps beats one that takes n2n^2 steps only when n>100log⁡2n:n > 100\log_2 n\mathclose{\text{:}} for every nn from 2 to 996 the “worse” quadratic algorithm takes fewer steps, and only from n=997n = 997 on does the other win. Big-O says who wins in the end, not at the sizes you have. Measure as well.

Compute itGrowth rates with exact integers

Python’s whole numbers are exact, however large, so they can settle questions about growth without rounding errors. Where does 2n2^n overtake n10?n^{10}\mathclose{\text{?}}

Python
n = 2
while n**10 >= 2**n:          # exact integer arithmetic: no rounding
    n += 1
print(n, n**10, 2**n)
Output
59 511116753300641401 576460752303423488

How long would the algorithms of the table take, at a hypothetical 10910^9 steps per second?

Python
import math
speed = 10**9                         # steps per second (hypothetical)
year = 365.25 * 24 * 3600             # seconds in a year
for n in (20, 50, 100):
    for name, steps in (("n^2", n**2), ("2^n", 2**n), ("n!", math.factorial(n))):
        seconds = steps / speed
        print(f"n = {n:3}  {name:>3}: {seconds:9.3g} s = {seconds / year:9.3g} years")
Output
n =  20  n^2:     4e-07 s =  1.27e-14 years
n =  20  2^n:   0.00105 s =  3.32e-11 years
n =  20   n!:  2.43e+09 s =      77.1 years
n =  50  n^2:   2.5e-06 s =  7.92e-14 years
n =  50  2^n:  1.13e+06 s =    0.0357 years
n =  50   n!:  3.04e+55 s =  9.64e+47 years
n = 100  n^2:     1e-05 s =  3.17e-13 years
n = 100  2^n:  1.27e+21 s =  4.02e+13 years
n = 100   n!: 9.33e+148 s = 2.96e+141 years

The n2n^2 column stays below a thousandth of a second. The 2n2^n column passes from a millisecond at n=20n = 20 to about 13 days at n=50n = 50 (1.13×1061.13 \times 10^6 seconds), and the n!n! column is already about 77 years at n=20.n = 20\mathclose{\text{.}}

9

What you learned

  • ff is continuous at aa when lim⁡x→af(x)=f(a):\lim_{x\to a} f(x) = f(a)\mathclose{\text{:}} f(a)f(a) is defined, the limit exists, and the two are equal. One-sided continuity handles jumps and the ends of intervals.
  • A discontinuity is removable (the limit exists), a jump (the one-sided limits differ), infinite (the values grow without bound) or oscillating. Only a removable one can be repaired by changing one value.
  • Sums, products, quotients (where the denominator is not 0) and compositions of continuous functions are continuous, and limits pass inside continuous functions: lim⁡f(g(x))=f(lim⁡g(x)).\lim f\big(g(x)\big) = f\big(\lim g(x)\big)\mathclose{\text{.}} Polynomials, rational functions, roots, exponentials, logarithms and the trigonometric functions are continuous on their domains.
  • The Intermediate Value Theorem: a function continuous on [a,b][a, b] takes every value between f(a)f(a) and f(b),f(b)\mathclose{\text{,}} so a change of sign brackets a root.
  • The bisection method halves the bracket at every step: after nn steps its width is (b−a)/2n,(b - a)/2^n\mathclose{\text{,}} and its midpoint is within (b−a)/2n+1(b - a)/2^{n+1} of a root.
  • The Extreme Value Theorem: a function continuous on a closed interval [a,b][a, b] has a maximum and a minimum value there; on an open or unbounded interval, or with a discontinuity, it may not.
  • lim⁡x→af(x)=±∞\lim_{x\to a} f(x) = \pm\infty describes values that grow without bound; then x=ax = a is a vertical asymptote, typically where a non-zero numerator meets a zero denominator. ∞\infty is not a number: ∞−∞\infty - \infty and ∞/∞\infty/\infty have no fixed value.
  • lim⁡x→±∞f(x)=L\lim_{x\to\pm\infty} f(x) = L gives the horizontal asymptote y=L.y = L\mathclose{\text{.}} Rational functions behave like the ratio of their leading terms; when the numerator’s degree exceeds the denominator’s by one, division gives an oblique asymptote.
  • ln⁡x≪xp≪ax\ln x \ll x^p \ll a^x for p>0p > 0 and a>1,a > 1\mathclose{\text{,}} and an≪n!≪nn.a^n \ll n! \ll n^n\mathclose{\text{.}} Big-O notation, f=O(g),f = O(g)\mathclose{\text{,}} bounds ff by a constant multiple of gg and ranks algorithms by how their cost grows.
10

Exercises

Exercise 3.1★The three conditions

For each function, decide whether it is continuous at the given number. If it is not, say which of the three conditions of Definition 3.1 fails, and classify the discontinuity.

  • (a) f(x)=x2−9x−3,f(x) = \dfrac{x^2 - 9}{x - 3}\mathclose{\text{,}} at 3
  • (b) g(x)=x+1g(x) = x + 1 for x<1,x < 1\mathclose{\text{,}} and g(x)=3−xg(x) = 3 - x for x≥1,x \ge 1\mathclose{\text{,}} at 1
  • (c) h(x)=x2h(x) = x^2 for x≤0,x \le 0\mathclose{\text{,}} and h(x)=1xh(x) = \dfrac{1}{x} for x>0,x > 0\mathclose{\text{,}} at 0
  • (d) u(x)=∣x−1∣x−1,u(x) = \dfrac{\abs{x - 1}}{x - 1}\mathclose{\text{,}} at 1
Show solution✓ Checked

(a) f(3)=0/0f(3) = 0/0 is not defined: condition 1 fails. For x≠3,x \ne 3\mathclose{\text{,}} f(x)=(x−3)(x+3)x−3=x+3,f(x) = \dfrac{(x - 3)(x + 3)}{x - 3} = x + 3\mathclose{\text{,}} so lim⁡x→3f(x)=6.\lim_{x\to3} f(x) = 6\mathclose{\text{.}} The limit exists, so the discontinuity is removable: giving ff the value 6 at 3 makes it continuous.

(b) g(1)=3−1=2.g(1) = 3 - 1 = 2\mathclose{\text{.}} From the left, lim⁡x→1−(x+1)=2;\lim_{x\to1^-}(x + 1) = 2\mathclose{\text{;}} from the right, lim⁡x→1+(3−x)=2.\lim_{x\to1^+}(3 - x) = 2\mathclose{\text{.}} The one-sided limits agree, so lim⁡x→1g(x)=2=g(1):\lim_{x\to1} g(x) = 2 = g(1)\mathclose{\text{:}} gg is continuous at 1. The two pieces meet at the point (1,2).(1, 2)\mathclose{\text{.}}

(c) h(0)=02=0,h(0) = 0^2 = 0\mathclose{\text{,}} and from the left lim⁡x→0−x2=0=h(0),\lim_{x\to0^-} x^2 = 0 = h(0)\mathclose{\text{,}} so hh is continuous from the left at 0. From the right, h(x)=1/xh(x) = 1/x grows without bound: lim⁡x→0+h(x)=∞.\lim_{x\to0^+} h(x) = \infty\mathclose{\text{.}} So lim⁡x→0h(x)\lim_{x\to0} h(x) does not exist (condition 2 fails), and 0 is an infinite discontinuity.

(d) u(1)=0/0u(1) = 0/0 is not defined: condition 1 fails. For x>1,x > 1\mathclose{\text{,}} ∣x−1∣=x−1\abs{x - 1} = x - 1 and u(x)=1;u(x) = 1\mathclose{\text{;}} for x<1,x < 1\mathclose{\text{,}} ∣x−1∣=−(x−1)\abs{x - 1} = -(x - 1) and u(x)=−1.u(x) = -1\mathclose{\text{.}} The one-sided limits, 1 and −1,-1\mathclose{\text{,}} differ, so the limit does not exist either: a jump discontinuity.

Exercise 3.2★Repairing discontinuities

Each formula has a zero denominator at one or two numbers. At each of them, decide whether the discontinuity is removable, and if it is, give the value that repairs it.

  • (a) f(x)=x3−8x−2f(x) = \dfrac{x^3 - 8}{x - 2}
  • (b) g(x)=x+4−2xg(x) = \dfrac{\sqrt{x + 4} - 2}{x}
  • (c) h(x)=x+1x2−1h(x) = \dfrac{x + 1}{x^2 - 1}
Show solution✓ Checked

(a) ff is undefined at 2. Factor the difference of cubes: x3−8=(x−2)(x2+2x+4),x^3 - 8 = (x - 2)(x^2 + 2x + 4)\mathclose{\text{,}} so for x≠2,x \ne 2\mathclose{\text{,}} f(x)=x2+2x+4,f(x) = x^2 + 2x + 4\mathclose{\text{,}} which tends to 4+4+4=12.4 + 4 + 4 = 12\mathclose{\text{.}} The limit exists: the discontinuity is removable, and the value f(2)=12f(2) = 12 repairs it.

(b) gg is defined for x≥−4,x \ge -4\mathclose{\text{,}} except at 0. Rationalise, as in Module 2: multiply the numerator and the denominator by x+4+2.\sqrt{x + 4} + 2\mathclose{\text{.}} Since (x+4−2)(x+4+2)=(x+4)−4=x,\big(\sqrt{x + 4} - 2\big)\big(\sqrt{x + 4} + 2\big) = (x + 4) - 4 = x\mathclose{\text{,}} for x≠0x \ne 0

g(x)=xx(x+4+2)=1x+4+2.\begin{aligned} g(x) &= \frac{x}{x\big(\sqrt{x + 4} + 2\big)} \\ &= \frac{1}{\sqrt{x + 4} + 2}. \end{aligned}

The square root is continuous at 4, so the limit at 0 is 1/(2+2)=14:1/(2 + 2) = \tfrac14\mathclose{\text{:}} removable, repaired by g(0)=14.g(0) = \tfrac14\mathclose{\text{.}}

(c) hh is undefined where x2−1=(x−1)(x+1)=0,x^2 - 1 = (x - 1)(x + 1) = 0\mathclose{\text{,}} at −1-1 and 1. For other x,x\mathclose{\text{,}} h(x)=1/(x−1).h(x) = 1/(x - 1)\mathclose{\text{.}} At −1-1 the limit is 1/(−2)=−12:1/(-2) = -\tfrac12\mathclose{\text{:}} removable, repaired by h(−1)=−12.h(-1) = -\tfrac12\mathclose{\text{.}} At 1 the numerator of 1/(x−1)1/(x - 1) is 1 and the denominator tends to 0, so by Theorem 3.9 the values tend to ∞\infty on the right and to −∞-\infty on the left: an infinite discontinuity, which no value repairs.

Exercise 3.3★Roots by the Intermediate Value Theorem
  • (a) Show that x5+x−1=0x^5 + x - 1 = 0 has a solution in (0,1).(0, 1)\mathclose{\text{.}}
  • (b) Show that e−x=xe^{-x} = x has a solution in (0,1).(0, 1)\mathclose{\text{.}}
  • (c) f(x)=1xf(x) = \dfrac1x has f(−1)=−1<0<1=f(1).f(-1) = -1 < 0 < 1 = f(1)\mathclose{\text{.}} Why does the Intermediate Value Theorem not give a root in (−1,1)?(-1, 1)\mathclose{\text{?}} Does ff have one?
Show solution✓ Checked

(a) p(x)=x5+x−1p(x) = x^5 + x - 1 is a polynomial, continuous on [0,1],[0, 1]\mathclose{\text{,}} with p(0)=−1<0p(0) = -1 < 0 and p(1)=1>0.p(1) = 1 > 0\mathclose{\text{.}} By the Intermediate Value Theorem, p(c)=0p(c) = 0 for some cc in (0,1).(0, 1)\mathclose{\text{.}} (Bisection or a computer gives c≈0.7549.)c \approx 0.7549\mathclose{\text{.)}}

(b) Rewrite the equation as g(x)=0g(x) = 0 with g(x)=e−x−x,g(x) = e^{-x} - x\mathclose{\text{,}} continuous on R\R (e−xe^{-x} is the composition of eue^u with u=−x).u = -x\mathclose{\text{).}} Then g(0)=1>0g(0) = 1 > 0 and g(1)=e−1−1≈0.3679−1=−0.6321<0,g(1) = e^{-1} - 1 \approx 0.3679 - 1 = -0.6321 < 0\mathclose{\text{,}} so gg has a root in (0,1):(0, 1)\mathclose{\text{:}} e−x=xe^{-x} = x there. (It is c≈0.5671.)c \approx 0.5671\mathclose{\text{.)}}

(c) The theorem needs ff to be continuous on the whole of [−1,1],[-1, 1]\mathclose{\text{,}} and 1/x1/x is not even defined at 0: it has an infinite discontinuity there. So the theorem says nothing. And ff has no root: 1x=0\dfrac1x = 0 would need 1=0⋅x=0.1 = 0 \cdot x = 0\mathclose{\text{.}} The sign changes because the graph jumps from −∞-\infty to ∞\infty at the asymptote x=0,x = 0\mathclose{\text{,}} not because it crosses the axis.

Exercise 3.4★★Bisection by hand

Use the bisection method on f(x)=x3−2x−5,f(x) = x^3 - 2x - 5\mathclose{\text{,}} starting from [2,3][2, 3] (Example 3.5).

  • (a) Carry out four steps, and give the bracket [a4,b4].[a_4, b_4]\mathclose{\text{.}}
  • (b) What does Theorem 3.7 guarantee about the midpoint m4?m_4\mathclose{\text{?}} Compare with the root c≈2.0946.c \approx 2.0946\mathclose{\text{.}}
  • (c) How many steps from [2,3][2, 3] guarantee that the midpoint mnm_n is within 10−410^{-4} of the root?
Show solution✓ Checked

(a) f(2)=−1<0f(2) = -1 < 0 and f(3)=16>0.f(3) = 16 > 0\mathclose{\text{.}} At each step, compare the sign of f(mn)f(m_n) with the sign of f(an),f(a_n)\mathclose{\text{,}} which stays negative because ana_n only moves to midpoints where ff is negative (values of ff rounded to 4 significant digits):

nn ana_n bnb_n mnm_n f(mn)f(m_n)
0 2 3 2.5 5.625
1 2 2.5 2.25 1.891
2 2 2.25 2.125 0.3457
3 2 2.125 2.0625 −0.3513

The first three midpoints give positive values, so each replaces b;b\mathclose{\text{;}} the fourth gives a negative value and replaces a.a\mathclose{\text{.}} So [a4,b4]=[2.0625,2.125],[a_4, b_4] = [2.0625, 2.125]\mathclose{\text{,}} of width 116=0.0625.\tfrac{1}{16} = 0.0625\mathclose{\text{.}}

(b) The midpoint m4=2.09375m_4 = 2.09375 is within 3−225=132=0.03125\dfrac{3 - 2}{2^5} = \dfrac{1}{32} = 0.03125 of the root. In fact the root is about 2.0946, so the error is only about 0.0008.

(c) Theorem 3.7 needs 12n+1≤10−4,\dfrac{1}{2^{n+1}} \le 10^{-4}\mathclose{\text{,}} that is, 2n+1≥10,000.2^{n+1} \ge 10{,}000\mathclose{\text{.}} Since 213=81922^{13} = 8192 is too small and 214=16,3842^{14} = 16{,}384 is large enough, n+1=14:n + 1 = 14\mathclose{\text{:}} 13 steps.

Exercise 3.5★★Extreme values or not

For each function and interval, decide whether the Extreme Value Theorem applies. Then find the maximum and minimum values, or explain why there is none.

  • (a) f(x)=4x−x2f(x) = 4x - x^2 on [0,3][0, 3]
  • (b) g(x)=1x2g(x) = \dfrac{1}{x^2} on [−1,1],[-1, 1]\mathclose{\text{,}} where gg is not defined at 0
  • (c) h(x)=x2h(x) = x^2 on (−1,2)(-1, 2)
  • (d) ⌊x⌋\lfloor x\rfloor on [0,2][0, 2]
Show solution✓ Checked

(a) ff is a polynomial, continuous on the closed interval [0,3]:[0, 3]\mathclose{\text{:}} the theorem applies. Complete the square: f(x)=4−(x−2)2.f(x) = 4 - (x - 2)^2\mathclose{\text{.}} The maximum value is f(2)=4,f(2) = 4\mathclose{\text{,}} where the square is 0. The square is largest where xx is farthest from 2, at x=0,x = 0\mathclose{\text{,}} so the minimum value is f(0)=0f(0) = 0 (at the other end, f(3)=3).f(3) = 3\mathclose{\text{).}}

(b) gg is not defined at 0, which lies in [−1,1],[-1, 1]\mathclose{\text{,}} so it is not continuous there: the theorem does not apply. There is no maximum value, since g(x)→∞g(x) \to \infty as x→0.x \to 0\mathclose{\text{.}} But there is a minimum value: for 0<∣x∣≤1,0 < \abs{x} \le 1\mathclose{\text{,}} x2≤1,x^2 \le 1\mathclose{\text{,}} so 1x2≥1,\dfrac{1}{x^2} \ge 1\mathclose{\text{,}} with equality at x=±1.x = \pm1\mathclose{\text{.}} The minimum value is 1.

(c) hh is continuous, but (−1,2)(-1, 2) is open: the theorem does not apply. The minimum value is h(0)=0,h(0) = 0\mathclose{\text{,}} since x2≥0.x^2 \ge 0\mathclose{\text{.}} There is no maximum value: x2<4x^2 < 4 for every xx in (−1,2),(-1, 2)\mathclose{\text{,}} and as x→2−x \to 2^- the values approach 4, so any value h(x0)h(x_0) is beaten by hh at points closer to 2.

(d) ⌊x⌋\lfloor x\rfloor jumps at 1, and at 2 it is not continuous from the left (lim⁡x→2−⌊x⌋=1≠2),\lim_{x\to2^-}\lfloor x\rfloor = 1 \ne 2\mathclose{\text{),}} so it is not continuous on [0,2]:[0, 2]\mathclose{\text{:}} the theorem does not apply. Yet extreme values exist: the values are 0 (on [0,1)),[0, 1)\mathclose{\text{),}} 1 (on [1,2))[1, 2)\mathclose{\text{)}} and 2 (at x=2),x = 2\mathclose{\text{),}} so the maximum value is 2 and the minimum value is 0.

Parts (b), (c) and (d) show that the hypotheses are sufficient, not necessary: when they fail, extreme values may or may not exist.

Exercise 3.6★★Vertical asymptotes
  • (a) Find the vertical asymptotes of f(x)=x+2x2+x−2,f(x) = \dfrac{x + 2}{x^2 + x - 2}\mathclose{\text{,}} with the one-sided limits at each, and any holes in the graph.
  • (b) Find lim⁡x→0+e1/x\displaystyle\lim_{x\to0^+} e^{1/x} and lim⁡x→0−e1/x.\displaystyle\lim_{x\to0^-} e^{1/x}\mathclose{\text{.}} What kind of discontinuity does e1/xe^{1/x} have at 0? Does its graph have a horizontal asymptote?
Show solution✓ Checked

(a) Factor the denominator: x2+x−2=(x+2)(x−1).x^2 + x - 2 = (x + 2)(x - 1)\mathclose{\text{.}} So ff is not defined at −2-2 and at 1, and for every other xx

f(x)=x+2(x+2)(x−1)=1x−1.f(x) = \frac{x + 2}{(x + 2)(x - 1)} = \frac{1}{x - 1}.

At −2-2 the factor cancels, and lim⁡x→−2f(x)=1−3=−13:\lim_{x\to-2} f(x) = \dfrac{1}{-3} = -\dfrac13\mathclose{\text{:}} a hole at (−2,−13),\big(-2, -\tfrac13\big)\mathclose{\text{,}} not an asymptote. At 1 the numerator is 1 and the denominator x−1x - 1 tends to 0, positive on the right and negative on the left, so by Theorem 3.9

lim⁡x→1+f(x)=∞,lim⁡x→1−f(x)=−∞,\begin{aligned} \lim_{x\to1^+} f(x) &= \infty, \\ \lim_{x\to1^-} f(x) &= -\infty, \end{aligned}

and x=1x = 1 is the only vertical asymptote.

(b) As x→0+,x \to 0^+\mathclose{\text{,}} u=1xu = \dfrac1x grows without bound, and so does eue^u (Section 3.7): lim⁡x→0+e1/x=∞.\lim_{x\to0^+} e^{1/x} = \infty\mathclose{\text{.}} As x→0−,x \to 0^-\mathclose{\text{,}} u=1xu = \dfrac1x tends to −∞,-\infty\mathclose{\text{,}} and eu→0:e^u \to 0\mathclose{\text{:}} lim⁡x→0−e1/x=0.\lim_{x\to0^-} e^{1/x} = 0\mathclose{\text{.}} Since one one-sided limit is infinite, 0 is an infinite discontinuity, and x=0x = 0 is a vertical asymptote, on the right side only. As x→±∞,x \to \pm\infty\mathclose{\text{,}} 1x→0\dfrac1x \to 0 and eue^u is continuous at 0, so e1/x→e0=1e^{1/x} \to e^0 = 1 (Theorem 3.4): the line y=1y = 1 is a horizontal asymptote at both ends.

Exercise 3.7★★Limits at infinity

Find

  • (a) lim⁡x→∞2x3−x4x3+5x2+1\displaystyle\lim_{x\to\infty}\frac{2x^3 - x}{4x^3 + 5x^2 + 1}
  • (b) lim⁡x→−∞3x+1x2+4\displaystyle\lim_{x\to-\infty}\frac{3x + 1}{\sqrt{x^2 + 4}}
  • (c) lim⁡x→∞(x2+x−x).\displaystyle\lim_{x\to\infty}\Big(\sqrt{x^2 + x} - x\Big)\mathclose{\text{.}} (Hint: multiply and divide by x2+x+x.)\sqrt{x^2 + x} + x\mathclose{\text{.)}}
Show solution✓ Checked

(a) The degrees are equal, so divide the numerator and the denominator by x3:x^3\mathclose{\text{:}}

2x3−x4x3+5x2+1=2−1/x24+5/x+1/x3→24=12.\begin{aligned} &\frac{2x^3 - x}{4x^3 + 5x^2 + 1} \\ &\quad= \frac{2 - 1/x^2}{4 + 5/x + 1/x^3} \to \frac{2}{4} = \frac12. \end{aligned}

(b) For x<0,x < 0\mathclose{\text{,}} x2+4=∣x∣1+4/x2=−x1+4/x2.\sqrt{x^2 + 4} = \abs{x}\sqrt{1 + 4/x^2} = -x\sqrt{1 + 4/x^2}\mathclose{\text{.}} Dividing the numerator and the denominator by −x,-x\mathclose{\text{,}} which is positive,

3x+1x2+4=3x+1−x1+4/x2=−3+1/x1+4/x2→−31=−3.\begin{aligned} \frac{3x + 1}{\sqrt{x^2 + 4}} &= \frac{3x + 1}{-x\sqrt{1 + 4/x^2}} \\ &= -\frac{3 + 1/x}{\sqrt{1 + 4/x^2}} \\ &\to -\frac{3}{1} = -3. \end{aligned}

The common wrong answer 3 forgets that x2=∣x∣=−x\sqrt{x^2} = \abs{x} = -x for negative x.x\mathclose{\text{.}} (As x→∞x \to \infty the limit is 3.)

(c) Both x2+x\sqrt{x^2 + x} and xx tend to ∞,\infty\mathclose{\text{,}} and “∞−∞\infty - \infty” decides nothing, so rationalise, as in Module 2. For x>0,x > 0\mathclose{\text{,}} write s=x2+x,s = \sqrt{x^2 + x}\mathclose{\text{,}} so that s2=x2+x.s^2 = x^2 + x\mathclose{\text{.}} Multiply and divide by s+x,s + x\mathclose{\text{,}} and multiply out the difference of squares on top:

s−x=(s−x)(s+x)s+x=s2−x2s+x=xs+x.\begin{aligned} s - x &= \frac{(s - x)(s + x)}{s + x} \\ &= \frac{s^2 - x^2}{s + x} = \frac{x}{s + x}. \end{aligned}

Put s=x2+xs = \sqrt{x^2 + x} back, and divide the numerator and the denominator by x,x\mathclose{\text{,}} using x2+x=x1+1/x\sqrt{x^2 + x} = x\sqrt{1 + 1/x} for x>0:x > 0\mathclose{\text{:}}

xx2+x+x=11+1/x+1→11+1=12.\begin{aligned} \frac{x}{\sqrt{x^2 + x} + x} &= \frac{1}{\sqrt{1 + 1/x} + 1} \\ &\to \frac{1}{1 + 1} = \frac12. \end{aligned}

The answer is 12,\tfrac12\mathclose{\text{,}} not 0: the two terms grow together, and their difference settles at 12.\tfrac12\mathclose{\text{.}} On a computer the original form is also numerically dangerous. For large xx it subtracts two nearly equal numbers, and the cancellation of Module 2 destroys the digits; the rewritten form keeps them:

Python
import math
for x in (1e4, 1e8, 1e16):
    print(x, math.sqrt(x*x + x) - x, 1/(math.sqrt(1 + 1/x) + 1))
Output
10000.0 0.49998750062513864 0.49998750062496095
100000000.0 0.5 0.49999999875
1e+16 2.0 0.5

At x=1016x = 10^{16} the original form gives 2.0, while the rewritten form gives the correct 0.5.

Exercise 3.8★★An oblique asymptote

Let f(x)=2x2−3x+1x+1.f(x) = \dfrac{2x^2 - 3x + 1}{x + 1}\mathclose{\text{.}}

  • (a) Write f(x)f(x) in the form mx+c+dx+1.mx + c + \dfrac{d}{x + 1}\mathclose{\text{.}}
  • (b) Find all the asymptotes of the graph, and say on which side of the oblique asymptote the graph lies.
  • (c) Find where the graph crosses the axes, and describe its shape.
Show solution✓ Checked

(a) Divide 2x2−3x+12x^2 - 3x + 1 by x+1x + 1 by long division. First 2x2÷x=2x,2x^2 \div x = 2x\mathclose{\text{,}} and 2x(x+1)=2x2+2x;2x(x + 1) = 2x^2 + 2x\mathclose{\text{;}} subtracting leaves −5x+1.-5x + 1\mathclose{\text{.}} Then −5x÷x=−5,-5x \div x = -5\mathclose{\text{,}} and −5(x+1)=−5x−5;-5(x + 1) = -5x - 5\mathclose{\text{;}} subtracting leaves the remainder 6. So 2x2−3x+1=(x+1)(2x−5)+6,2x^2 - 3x + 1 = (x + 1)(2x - 5) + 6\mathclose{\text{,}} and for x≠−1x \ne -1

f(x)=2x−5+6x+1.f(x) = 2x - 5 + \frac{6}{x + 1}.

Check by expanding: (x+1)(2x−5)+6=2x2−3x−5+6=2x2−3x+1.(x + 1)(2x - 5) + 6 = 2x^2 - 3x - 5 + 6 = 2x^2 - 3x + 1\mathclose{\text{.}}

(b) As x→±∞,x \to \pm\infty\mathclose{\text{,}} 6x+1→0,\dfrac{6}{x + 1} \to 0\mathclose{\text{,}} so y=2x−5y = 2x - 5 is an oblique asymptote at both ends. For x>−1,x > -1\mathclose{\text{,}} 6x+1>0\dfrac{6}{x + 1} > 0 and the graph lies above it; for x<−1,x < -1\mathclose{\text{,}} below. At x=−1x = -1 the numerator is 2+3+1=6≠0,2 + 3 + 1 = 6 \ne 0\mathclose{\text{,}} so by Theorem 3.9 lim⁡x→−1+f(x)=∞\lim_{x\to-1^+} f(x) = \infty and lim⁡x→−1−f(x)=−∞:\lim_{x\to-1^-} f(x) = -\infty\mathclose{\text{:}} x=−1x = -1 is a vertical asymptote. There is no horizontal asymptote, since f(x)→±∞f(x) \to \pm\infty as x→±∞.x \to \pm\infty\mathclose{\text{.}}

(c) f(x)=0f(x) = 0 where 2x2−3x+1=(2x−1)(x−1)=0,2x^2 - 3x + 1 = (2x - 1)(x - 1) = 0\mathclose{\text{,}} at x=12x = \tfrac12 and x=1,x = 1\mathclose{\text{,}} and f(0)=1.f(0) = 1\mathclose{\text{.}} So the right-hand branch comes down from ∞\infty beside the line x=−1,x = -1\mathclose{\text{,}} crosses the yy-axis at 1, dips below the xx-axis between 12\tfrac12 and 1, and rises again along the oblique asymptote, above it. The left-hand branch stays below the oblique asymptote and plunges to −∞-\infty as x→−1−.x \to -1^-\mathclose{\text{.}}

Exercise 3.9★★★Orders of growth and big-O
  • (a) Arrange these functions in order of growth as n→∞,n \to \infty\mathclose{\text{,}} from the slowest-growing to the fastest, and justify each comparison: n100,n^{100}\mathclose{\text{,}} 2n,2^n\mathclose{\text{,}} (ln⁡n)3,(\ln n)^3\mathclose{\text{,}} nlog⁡2n,n\log_2 n\mathclose{\text{,}} n,\sqrt n\mathclose{\text{,}} 1.01n,1.01^n\mathclose{\text{,}} n!.n!\mathclose{\text{.}}
  • (b) A program takes T(n)=5nlog⁡2n+100nT(n) = 5n\log_2 n + 100n microseconds on an input of size n.n\mathclose{\text{.}} Show that T(n)=O(nlog⁡2n).T(n) = O(n\log_2 n)\mathclose{\text{.}}
Show solution✓ Checked

(a) The order is

(ln⁡n)3≪n≪nlog⁡2n≪n100≪1.01n≪2n≪n!.\begin{aligned} (\ln n)^3 &\ll \sqrt n \ll n\log_2 n \\ &\ll n^{100} \ll 1.01^n \\ &\ll 2^n \ll n!. \end{aligned}

Each comparison is a ratio that tends to 0:

  • (ln⁡n)3n=(ln⁡nn1/6)3→03=0,\dfrac{(\ln n)^3}{\sqrt n} = \Big(\dfrac{\ln n}{n^{1/6}}\Big)^3 \to 0^3 = 0\mathclose{\text{,}} because ln⁡n≪n1/6\ln n \ll n^{1/6} (Theorem 3.11 with p=16)p = \tfrac16\mathclose{\text{)}} and t3t^3 is continuous at 0 (Theorem 3.4).
  • nnlog⁡2n=1n log⁡2n→0,\dfrac{\sqrt n}{n\log_2 n} = \dfrac{1}{\sqrt n\,\log_2 n} \to 0\mathclose{\text{,}} since both factors of the denominator grow without bound.
  • nlog⁡2nn100=1ln⁡2⋅ln⁡nn99→0,\dfrac{n\log_2 n}{n^{100}} = \dfrac{1}{\ln 2}\cdot\dfrac{\ln n}{n^{99}} \to 0\mathclose{\text{,}} since ln⁡n≪n99.\ln n \ll n^{99}\mathclose{\text{.}}
  • n1001.01n→0,\dfrac{n^{100}}{1.01^n} \to 0\mathclose{\text{,}} since every power grows more slowly than every exponential with base greater than 1 (Theorem 3.11 with p=100,p = 100\mathclose{\text{,}} a=1.01).a = 1.01\mathclose{\text{).}}
  • 1.01n2n=0.505n→0,\dfrac{1.01^n}{2^n} = 0.505^n \to 0\mathclose{\text{,}} an exponential with base less than 1 (Section 3.7).
  • 2nn!→0,\dfrac{2^n}{n!} \to 0\mathclose{\text{,}} by Theorem 3.11 with a=2.a = 2\mathclose{\text{.}}

The fourth comparison holds only in the long run: n100n^{100} stays ahead of 1.01n1.01^n for every nn from 2 to 117,308 (Section 3.8).

(b) For n≥2,n \ge 2\mathclose{\text{,}} log⁡2n≥1,\log_2 n \ge 1\mathclose{\text{,}} so 100n≤100 nlog⁡2n,100n \le 100\,n\log_2 n\mathclose{\text{,}} and

T(n)≤5nlog⁡2n+100 nlog⁡2n=105 nlog⁡2n.\begin{aligned} T(n) &\le 5n\log_2 n + 100\,n\log_2 n \\ &= 105\,n\log_2 n. \end{aligned}

That is the definition of T(n)=O(nlog⁡2n),T(n) = O(n\log_2 n)\mathclose{\text{,}} with C=105C = 105 and N=2.N = 2\mathclose{\text{.}} With limits instead: T(n)nlog⁡2n=5+100log⁡2n→5.\dfrac{T(n)}{n\log_2 n} = 5 + \dfrac{100}{\log_2 n} \to 5\mathclose{\text{.}}

Exercise 3.10★★★Polynomials of odd degree
  • (a) Prove that every polynomial of odd degree has at least one real root.
  • (b) Give a polynomial of even degree that has no real root.
  • (c) Show that p(x)=x3−3x+1p(x) = x^3 - 3x + 1 has exactly three real roots, and find three intervals of length 1 that contain them.
Show solution✓ Checked

(a) Let p(x)=anxn+⋯+a1x+a0p(x) = a_nx^n + \dots + a_1x + a_0 with nn odd and an≠0.a_n \ne 0\mathclose{\text{.}} Dividing by ana_n does not change the roots, so take an=1.a_n = 1\mathclose{\text{.}} A polynomial is a rational function with denominator 1, so by Theorem 3.10 p(x)p(x) behaves like its leading term xnx^n as x→±∞.x \to \pm\infty\mathclose{\text{.}} Since nn is odd, xn→∞x^n \to \infty as x→∞x \to \infty and xn→−∞x^n \to -\infty as x→−∞;x \to -\infty\mathclose{\text{;}} hence

lim⁡x→∞p(x)=∞,lim⁡x→−∞p(x)=−∞.\begin{aligned} \lim_{x\to\infty} p(x) &= \infty, \\ \lim_{x\to-\infty} p(x) &= -\infty. \end{aligned}

The first limit means that p(x)>0p(x) > 0 for every large enough x:x\mathclose{\text{:}} pick such a number B,B\mathclose{\text{,}} so p(B)>0.p(B) > 0\mathclose{\text{.}} The second gives a number A<BA < B with p(A)<0.p(A) < 0\mathclose{\text{.}} The polynomial pp is continuous on [A,B],[A, B]\mathclose{\text{,}} so by the Intermediate Value Theorem it has a root in (A,B).(A, B)\mathclose{\text{.}}

(b) x2+1≥1>0x^2 + 1 \ge 1 > 0 for every real x,x\mathclose{\text{,}} so it has no real root. For even n,n\mathclose{\text{,}} xn→∞x^n \to \infty at both ends, and the argument of (a) breaks down.

(c) Evaluate pp at a few whole numbers:

xx −2-2 −1-1 00 11 22
p(x)p(x) −1-1 33 11 −1-1 33

pp changes sign on [−2,−1],[-2, -1]\mathclose{\text{,}} on [0,1][0, 1] and on [1,2],[1, 2]\mathclose{\text{,}} so by the Intermediate Value Theorem it has a root in each of (−2,−1),(-2, -1)\mathclose{\text{,}} (0,1)(0, 1) and (1,2):(1, 2)\mathclose{\text{:}} at least three roots, r1<r2<r3.r_1 < r_2 < r_3\mathclose{\text{.}} It has no more. A root rr of a polynomial gives a factor x−rx - r (Section 2.5), so p(x)=(x−r1) q(x)p(x) = (x - r_1)\,q(x) with qq quadratic, leading coefficient 1. Since p(r2)=0p(r_2) = 0 and r2≠r1,r_2 \ne r_1\mathclose{\text{,}} q(r2)=0,q(r_2) = 0\mathclose{\text{,}} so q(x)=(x−r2)(x−s)q(x) = (x - r_2)(x - s) for some number s;s\mathclose{\text{;}} and p(r3)=0p(r_3) = 0 forces s=r3.s = r_3\mathclose{\text{.}} So p(x)=(x−r1)(x−r2)(x−r3),p(x) = (x - r_1)(x - r_2)(x - r_3)\mathclose{\text{,}} which is not 0 at any other number: pp has exactly three real roots.

Exercise 3.11★★★The hiker’s theorem

A hiker leaves the bottom of a mountain path at 7:00 on Saturday and reaches the top at 15:00. On Sunday she leaves the top at 7:00 and walks down the same path, reaching the bottom at 15:00. Her speed varies on both days, and she stops to rest now and then. Prove that there is a time of day at which she is at exactly the same point of the path on both days.

Show solution✓ Checked

Measure her position by the distance along the path from the bottom, and let LL be the length of the path. Let u(t)u(t) be her position at time tt (in hours) on Saturday and d(t)d(t) her position at the same time on Sunday, for 7≤t≤15.7 \le t \le 15\mathclose{\text{.}} Both are continuous functions of t:t\mathclose{\text{:}} she cannot jump from one point of the path to another. So

g(t)=u(t)−d(t)g(t) = u(t) - d(t)

is continuous on [7,15][7, 15] (Theorem 3.1). At the start of the day g(7)=u(7)−d(7)=0−L=−L<0,g(7) = u(7) - d(7) = 0 - L = -L < 0\mathclose{\text{,}} and at the end g(15)=L−0=L>0.g(15) = L - 0 = L > 0\mathclose{\text{.}} By the Intermediate Value Theorem there is a time cc in (7,15)(7, 15) with g(c)=0,g(c) = 0\mathclose{\text{,}} that is, u(c)=d(c):u(c) = d(c)\mathclose{\text{:}} at time cc she is at the same point on both days.

The same argument as a picture: two hikers on one day, one walking up on Saturday’s schedule and one walking down on Sunday’s, must meet somewhere. The theorem promises at least one such time, but not when. For a hypothetical example, suppose that on Saturday she starts slowly, with u(t)=Ls2u(t) = Ls^2 where s=(t−7)/8s = (t - 7)/8 is the fraction of the day’s walk that has passed, and that on Sunday she walks down at a steady pace, d(t)=L(1−s).d(t) = L(1 - s)\mathclose{\text{.}} Then u=du = d when s2=1−s,s^2 = 1 - s\mathclose{\text{,}} that is, s2+s−1=0,s^2 + s - 1 = 0\mathclose{\text{,}} whose solution between 0 and 1 is

s=5−12≈0.618,t=7+8s≈11.94.\begin{aligned} s &= \frac{\sqrt5 - 1}{2} \approx 0.618, \\ t &= 7 + 8s \approx 11.94. \end{aligned}

So at about 11:57 on both days she is at the same point, about 38% of the way up (s2≈0.382).s^2 \approx 0.382\mathclose{\text{).}}

11

Check yourself

1
Let f(x)=x2−1x−1f(x) = \dfrac{x^2 - 1}{x - 1} for x≠1,x \ne 1\mathclose{\text{,}} and f(1)=3.f(1) = 3\mathclose{\text{.}} At x=1,x = 1\mathclose{\text{,}} ff is
2
The largest interval on which f(x)=x−1+ln⁡(4−x)f(x) = \sqrt{x - 1} + \ln(4 - x) is continuous is
3
A function ff is continuous on [1,4],[1, 4]\mathclose{\text{,}} with f(1)=5f(1) = 5 and f(4)=−2.f(4) = -2\mathclose{\text{.}} Which statement must be true?
4
The bisection method starts from the bracket [0,3].[0, 3]\mathclose{\text{.}} After 8 steps the width of the bracket is
5
For which function and interval does the Extreme Value Theorem guarantee a maximum value?
6
The vertical asymptotes of y=x2−4x2−3x+2y = \dfrac{x^2 - 4}{x^2 - 3x + 2} are
7
The graph of y=6x2+x2x2−8y = \dfrac{6x^2 + x}{2x^2 - 8} has
8
Which statement is false?
Finished this module?