Ran Wei/ Calculus/Module 7
中文
Calculus · Part II · Derivatives

Module 7Rates, approximation and L'Hôpital's rule

Put derivatives to work. Find how fast one quantity changes from how fast another does, approximate a function by its tangent line, estimate how errors in measurements spread into results, solve equations with Newton’s method, and evaluate the limits that the limit laws cannot, with L’Hôpital’s rule.

⏱ 255 minYou need: Modules 1 to 6 (the rules of differentiation, ex,e^x\mathclose{\text{,}} ln⁡x,\ln x\mathclose{\text{,}} implicit differentiation)

In this module you will

  • Solve related-rates problems with a diagram, an equation that holds at every instant and the chain rule
  • Approximate a function near a point by its linearisation, use differentials, and judge how good the approximation is
  • Estimate how a measurement error spreads into a computed result, as an absolute and as a relative error
  • Solve equations with Newton’s method, explain why its correct digits roughly double, and recognise when it fails
  • Evaluate limits of the forms 0/0,0/0\mathclose{\text{,}} ∞/∞,\infty/\infty\mathclose{\text{,}} 0⋅∞,0\cdot\infty\mathclose{\text{,}} ∞−∞,\infty-\infty\mathclose{\text{,}} 1∞,1^\infty\mathclose{\text{,}} 000^0 and ∞0\infty^0 with L’Hôpital’s rule and logarithms
  • Prove that logarithms grow more slowly than powers, and powers more slowly than exponentials
1

Related rates

When two quantities are linked by an equation and both change with time, their rates of change are linked too. Module 5’s chain rule, “rates multiply”, turns the equation between the quantities into an equation between their rates: if you know how fast one changes, you can work out how fast the other does. Such problems are called related rates problems.

Here is one. A ladder 5 metres long leans against a vertical wall, on level ground. Its foot starts 1 metre from the wall and is pulled away at a steady 0.5 m/s. After tt seconds the foot is x=1+0.5tx = 1 + 0.5t metres from the wall, and by Pythagoras’ theorem the top is y=25−x2y = \sqrt{25 - x^2} metres up the wall:

ttxxy=25−x2y = \sqrt{25 - x^2}
00114.8994.899
111.51.54.7704.770
22224.5834.583
332.52.54.3304.330
443344
553.53.53.5713.571
664433
774.54.52.1792.179

The foot moves steadily, but the top does not. In the first second the top falls 4.899−4.770≈0.134.899 - 4.770 \approx 0.13 metres; in the eighth second, from t=7t = 7 until it reaches the ground at t=8,t = 8\mathclose{\text{,}} when x=5,x = 5\mathclose{\text{,}} it falls the remaining 2.1792.179 metres. How fast is the top falling at the instant when the foot is 3 metres from the wall, at t=4?t = 4\mathclose{\text{?}} The drops in the seconds on either side of t=4t = 4 suggest a speed between 0.330 and 0.429 m/s. To find it exactly, you do not need the formula for yy at all: you need the equation that links xx and yy at every instant.

Key idea

A strategy for related rates.

  1. Draw a diagram. Give a letter to every quantity that changes with time, and write in the constants.
  2. Write the rate you know and the rate you want as derivatives with respect to time t,t\mathclose{\text{,}} with units: “dx/dt=0.5dx/dt = 0.5 m/s; find dy/dtdy/dt when x=3x = 3 m”.
  3. Find an equation that links the changing quantities and holds at every instant: from geometry (Pythagoras’ theorem, similar triangles, the formula for a volume) or from physics.
  4. Differentiate both sides with respect to t.t\mathclose{\text{.}} Each changing quantity is a function of t,t\mathclose{\text{,}} so the chain rule applies to each: ddt(x2)=2x dxdt.\dfrac{d}{dt}\big(x^2\big) = 2x\,\dfrac{dx}{dt}\mathclose{\text{.}}
  5. Only now substitute the values at the instant you care about, and solve for the rate you want. Check its sign and its units.
The four related-rates problems of this section, with the changing quantities named by letters: a ladder whose foot is pulled away from a wall (Example 7.1), a cone-shaped tank filling with water (Example 7.2), a person walking away from a street lamp (Example 7.3), and a balloon rising while an observer watches it (Example 7.4).
Figure 7.1

The four related-rates problems of this section, with the changing quantities named by letters: a ladder whose foot is pulled away from a wall (Example 7.1), a cone-shaped tank filling with water (Example 7.2), a person walking away from a street lamp (Example 7.3), and a balloon rising while an observer watches it (Example 7.4).

Example 7.1The sliding ladder✓ Checked

Find how fast the top of the ladder is falling when its foot is 3 metres from the wall.

Let xx be the distance from the wall to the foot and yy the height of the top, both in metres, at time tt in seconds (Figure 7.1, top left). You know dx/dt=0.5dx/dt = 0.5 and want dy/dtdy/dt when x=3.x = 3\mathclose{\text{.}} At every instant the ladder, the wall and the ground form a right triangle with hypotenuse 5, so

x2+y2=25.x^2 + y^2 = 25.

Differentiate both sides with respect to t.t\mathclose{\text{.}} By the chain rule the derivative of x2x^2 is 2x dx/dt,2x\,dx/dt\mathclose{\text{,}} and the derivative of the constant 25 is 0:

2x dxdt+2y dydt=0,sodydt=−xy dxdt.\begin{aligned} 2x\,\frac{dx}{dt} + 2y\,\frac{dy}{dt} &= 0, \\ \text{so}\qquad \frac{dy}{dt} &= -\frac{x}{y}\,\frac{dx}{dt}. \end{aligned}

Now substitute the values at the instant. When x=3,x = 3\mathclose{\text{,}} y=25−9=4,y = \sqrt{25 - 9} = 4\mathclose{\text{,}} and

dydt=−34⋅0.5=−0.375 m/s.\frac{dy}{dt} = -\frac{3}{4} \cdot 0.5 = -0.375 \text{ m/s}.

The minus sign says that yy is decreasing: the top slides down at 0.375 m/s, between the two estimates from the table.

The formula dy/dt=−(x/y) dx/dtdy/dt = -(x/y)\,dx/dt also explains the table: as the top nears the ground, yy approaches 0 and the speed of the top grows without bound. No real ladder can move like that, so the model, which assumes that the top stays on the wall, must break down before the top reaches the ground.

Watch out

Do not substitute the values of the instant before you differentiate. If you put x=3x = 3 into x2+y2=25x^2 + y^2 = 25 first, you get 9+y2=25,9 + y^2 = 25\mathclose{\text{,}} and differentiating that gives 2y dy/dt=0:2y\,dy/dt = 0\mathclose{\text{:}} the top does not move, which is wrong. The equation you differentiate must hold at every instant, not only at the one you care about.

Volumes, shadows and angles

Example 7.2Filling a cone-shaped tank✓ Checked

A tank has the shape of a cone with its vertex at the bottom. It is 4 m deep, and its top is a circle of radius 2 m. Water runs in at 2 m³ per minute. How fast is the water level rising when the water is 3 m deep?

Let hh be the depth of the water and rr the radius of its surface, in metres, at time tt in minutes (Figure 7.1, top right). You know dV/dt=2dV/dt = 2 and want dh/dtdh/dt when h=3.h = 3\mathclose{\text{.}} The water forms a cone of volume

V=13πr2h.V = \frac{1}{3}\pi r^2 h.

This links three changing quantities, so eliminate one first. A vertical cut through the axis shows two similar right triangles, the tank’s with legs 4 and 2 and the water’s with legs hh and r.r\mathclose{\text{.}} So r/h=2/4r/h = 2/4 at every instant, that is, r=h/2,r = h/2\mathclose{\text{,}} and

V=13π(h2)2h=π12h3.V = \frac{1}{3}\pi\Big(\frac{h}{2}\Big)^2 h = \frac{\pi}{12}h^3.

Differentiate with respect to t,t\mathclose{\text{,}} by the chain rule:

dVdt=π4h2 dhdt.\frac{dV}{dt} = \frac{\pi}{4}h^2\,\frac{dh}{dt}.

At h=3h = 3 this reads 2=9π4 dhdt,2 = \dfrac{9\pi}{4}\,\dfrac{dh}{dt}\mathclose{\text{,}} so

dhdt=89π≈0.283 m/min.\frac{dh}{dt} = \frac{8}{9\pi} \approx 0.283 \text{ m/min}.

The level rises about 28 cm per minute at that moment. It rises more slowly as the water deepens, because the same 2 m³ spreads over a wider surface.

Example 7.3A walker’s shadow✓ Checked

A street lamp is at the top of a 6 m pole. A person 1.8 m tall walks straight away from the pole at 1.5 m/s. How fast does the shadow lengthen, and how fast does the tip of the shadow move?

Let xx be the person’s distance from the pole and ss the length of the shadow, in metres (Figure 7.1, bottom left). The ray of light from the lamp to the tip of the shadow grazes the top of the person’s head, so the large triangle (pole, ground, ray) and the small one (person, shadow, ray) are similar. Height over base is the same in both:

6x+s=1.8s.\frac{6}{x + s} = \frac{1.8}{s}.

Multiply both sides by s(x+s):s(x + s)\mathclose{\text{:}} 6s=1.8x+1.8s,6s = 1.8x + 1.8s\mathclose{\text{,}} so 4.2s=1.8x4.2s = 1.8x and s=37x.s = \dfrac{3}{7}x\mathclose{\text{.}} Differentiating,

dsdt=37 dxdt=37⋅1.5=914≈0.643 m/s.\begin{aligned} \frac{ds}{dt} &= \frac{3}{7}\,\frac{dx}{dt} = \frac{3}{7} \cdot 1.5 \\ &= \frac{9}{14} \approx 0.643 \text{ m/s}. \end{aligned}

The tip is x+s=107xx + s = \dfrac{10}{7}x from the pole, so it moves at 107⋅1.5=157≈2.14\dfrac{10}{7} \cdot 1.5 = \dfrac{15}{7} \approx 2.14 m/s, faster than the person walks. Neither answer depends on where the person is: here the relation is linear, so the rates are constant.

Example 7.4Watching a balloon rise✓ Checked

A balloon rises straight up at a steady 2 m/s from a point on level ground 400 m from an observer. How fast is the angle of elevation of the observer’s line of sight increasing when the balloon is 300 m up?

Let hh be the balloon’s height in metres and θ\theta the angle of elevation in radians, at time tt in seconds (Figure 7.1, bottom right). You know dh/dt=2dh/dt = 2 and want dθ/dtd\theta/dt when h=300.h = 300\mathclose{\text{.}} In the right triangle formed by the observer, the launch point and the balloon,

tan⁡θ=h400.\tan\theta = \frac{h}{400}.

Differentiate both sides with respect to t.t\mathclose{\text{.}} The derivative of tan⁡θ\tan\theta is sec⁡2θ\sec^2\theta (Module 5), so by the chain rule

sec⁡2θ dθdt=1400 dhdt.\sec^2\theta\,\frac{d\theta}{dt} = \frac{1}{400}\,\frac{dh}{dt}.

When h=300,h = 300\mathclose{\text{,}} the line of sight has length 4002+3002=500,\sqrt{400^2 + 300^2} = 500\mathclose{\text{,}} so cos⁡θ=400/500=4/5\cos\theta = 400/500 = 4/5 and sec⁡2θ=25/16.\sec^2\theta = 25/16\mathclose{\text{.}} Then

dθdt=1400⋅2⋅1625=0.0032 rad/s,\frac{d\theta}{dt} = \frac{1}{400} \cdot 2 \cdot \frac{16}{25} = 0.0032 \text{ rad/s},

about 0.18∘0.18^\circ per second (multiply by 180/π).180/\pi\mathclose{\text{).}} Differentiating θ=arctan⁡(h/400)\theta = \arctan(h/400) instead (Module 6) gives the same answer.

Watch out

Two more slips are common. The first is a wrong sign: a quantity that decreases has a negative rate, so a tank that drains at 2 m³/min has dV/dt=−2.dV/dt = -2\mathclose{\text{.}} The second is degrees: the derivative of tan⁡θ\tan\theta is sec⁡2θ\sec^2\theta only when θ\theta is in radians (Section 5.4), so work in radians and convert the answer at the end, as in Example 7.4.

Compute itRelated rates with SymPy

SymPy can carry out step 4 of the strategy. Make xx and yy functions of tt with sp.Function, differentiate the equation of Example 7.1, and solve for dy/dt:dy/dt\mathclose{\text{:}}

Python
import sympy as sp
t = sp.symbols('t')
x = sp.Function('x')(t)          # the foot's distance from the wall at time t
y = sp.Function('y')(t)          # the height of the top
link = x**2 + y**2 - 25          # zero at every instant
dlink = sp.diff(link, t)
print(dlink)
dydt = sp.solve(dlink, sp.Derivative(y, t))[0]
print(dydt)
Output
2*x(t)*Derivative(x(t), t) + 2*y(t)*Derivative(y(t), t)
-x(t)*Derivative(x(t), t)/y(t)

SymPy writes dx/dtdx/dt as Derivative(x(t), t). The call sp.solve treats dlink as an expression equal to 0. Here it returns a list with one solution for dy/dt,dy/dt\mathclose{\text{,}} and [0] takes that first entry. Now substitute the values at the instant, the rate first:

Python
print(dydt.subs(sp.Derivative(x, t), sp.Rational(1, 2)).subs({x: 3, y: 4}))
print(dydt.subs({x: 3, y: 4}))
Output
-3/8
-3*Derivative(3, t)/4

The first line is Example 7.1’s answer, −3/8=−0.375.-3/8 = -0.375\mathclose{\text{.}} The second is the pitfall after that example, in SymPy: substituting x=3x = 3 first also replaces the x(t)x(t) inside dx/dt,dx/dt\mathclose{\text{,}} which becomes Derivative(3, t), the derivative of a constant, 0.

2

Linear approximation and differentials

Zoom in on the graph of a differentiable function near a point, and it looks more and more like a straight line: its tangent line. Near the point, then, the tangent line, which is easy to compute with, is a good stand-in for the function, which may not be. This section makes that precise and measures how good the stand-in is.

Definition 7.1Linearisation

Let ff be differentiable at a.a\mathclose{\text{.}} The linearisation of ff at aa is the function

L(x)=f(a)+f′(a)(x−a),L(x) = f(a) + f'(a)(x - a),

whose graph is the tangent line to y=f(x)y = f(x) at (a,f(a)).\big(a, f(a)\big)\mathclose{\text{.}} Using f(x)≈L(x)f(x) \approx L(x) for xx near aa is the linear approximation, or tangent line approximation, of ff at a.a\mathclose{\text{.}}

LL is the line through (a,f(a))\big(a, f(a)\big) with slope f′(a),f'(a)\mathclose{\text{,}} in the point-slope form of Section 1.4. It matches ff in value and in slope at a:a\mathclose{\text{:}} L(a)=f(a)L(a) = f(a) and L′(a)=f′(a).L'(a) = f'(a)\mathclose{\text{.}}

Left: the graph of y = sqrt x and its tangent line y = L(x) at a = 4; near a they are hard to tell apart. From a to a + dx (here dx = 3, exaggerated so that the gap shows), the curve rises by Delta y and the tangent line by dy; dx and dy are the differentials defined later in this section. Right: y = sintheta and its tangent line y = theta at 0; in the green band, abs{theta} le 0.5, they almost coincide.
Figure 7.2

Left: the graph of y=xy = \sqrt x and its tangent line y=L(x)y = L(x) at a=4;a = 4\mathclose{\text{;}} near aa they are hard to tell apart. From aa to a+dxa + dx (here dx=3,dx = 3\mathclose{\text{,}} exaggerated so that the gap shows), the curve rises by Δy\Delta y and the tangent line by dy;dy\mathclose{\text{;}} dxdx and dydy are the differentials defined later in this section. Right: y=sin⁡θy = \sin\theta and its tangent line y=θy = \theta at 0; in the green band, ∣θ∣≤0.5,\abs{\theta} \le 0.5\mathclose{\text{,}} they almost coincide.

Example 7.5Square roots near 4✓ Checked

Use the linearisation of f(x)=xf(x) = \sqrt x at a=4a = 4 to estimate 4.1\sqrt{4.1} and 3.9.\sqrt{3.9}\mathclose{\text{.}}

Here f(4)=2f(4) = 2 and f′(x)=12x,f'(x) = \dfrac{1}{2\sqrt x}\mathclose{\text{,}} so f′(4)=14f'(4) = \dfrac14 and

L(x)=2+14(x−4).L(x) = 2 + \frac{1}{4}(x - 4).

So 4.1≈L(4.1)=2+14(0.1)=2.025\sqrt{4.1} \approx L(4.1) = 2 + \tfrac14(0.1) = 2.025 and 3.9≈L(3.9)=2−14(0.1)=1.975.\sqrt{3.9} \approx L(3.9) = 2 - \tfrac14(0.1) = 1.975\mathclose{\text{.}} A calculator gives 4.1≈2.024846\sqrt{4.1} \approx 2.024846 and 3.9≈1.974842:\sqrt{3.9} \approx 1.974842\mathclose{\text{:}} both estimates are within 0.0002 of the true values, and both are a little too big, because the graph of x\sqrt x bends away below its tangent line (Figure 7.2, left).

How good is the approximation further from 4, and closer to it? The table compares x\sqrt x with L(x):L(x)\mathclose{\text{:}}

xxx\sqrt{x}L(x)L(x)x−L(x)\sqrt{x} - L(x)
331.732051.732051.751.75−0.0179492-0.0179492
3.93.91.974841.974841.9751.975−0.000158234-0.000158234
3.993.991.997501.997501.99751.9975−1.56446×10−6-1.56446\times10^{-6}
4.014.012.002502.002502.00252.0025−1.56055×10−6-1.56055\times10^{-6}
4.14.12.024852.024852.0252.025−0.000154327-0.000154327
552.236072.236072.252.25−0.0139320-0.0139320

Two things stand out. The error x−L(x)\sqrt x - L(x) is always negative: the tangent line lies above the graph. And each time xx moves ten times closer to 4, the error shrinks about a hundred times: it is 0.014 or 0.018 at distance 1, 0.00015 or 0.00016 at distance 0.1, and 0.0000016 at distance 0.01. The error behaves like a constant times (x−4)2.(x - 4)^2\mathclose{\text{.}}

How good is it?

Theorem 7.1The tangent line is the best linear approximation

Let ff be differentiable at a,a\mathclose{\text{,}} with linearisation L,L\mathclose{\text{,}} and let E(x)=f(x)−L(x)E(x) = f(x) - L(x) be the error of the linear approximation. Then

lim⁡x→aE(x)x−a=0.\lim_{x\to a}\frac{E(x)}{x - a} = 0.

That is, the error is small even compared with the distance x−a.x - a\mathclose{\text{.}} Moreover, LL is the only linear function with this property: if ℓ(x)=c+m(x−a)\ell(x) = c + m(x - a) and (f(x)−ℓ(x))/(x−a)→0\big(f(x) - \ell(x)\big)/(x - a) \to 0 as x→a,x \to a\mathclose{\text{,}} then c=f(a)c = f(a) and m=f′(a).m = f'(a)\mathclose{\text{.}}

Proof

For x≠a,x \ne a\mathclose{\text{,}}

E(x)x−a=f(x)−f(a)−f′(a)(x−a)x−a=f(x)−f(a)x−a−f′(a).\begin{aligned} \frac{E(x)}{x - a} &= \frac{f(x) - f(a) - f'(a)(x - a)}{x - a} \\ &= \frac{f(x) - f(a)}{x - a} - f'(a). \end{aligned}

As x→ax \to a the difference quotient approaches f′(a),f'(a)\mathclose{\text{,}} by the definition of the derivative (Module 4), so the whole expression approaches 0.

Now suppose ℓ(x)=c+m(x−a)\ell(x) = c + m(x - a) has the property. Then f(x)−ℓ(x)=f(x)−ℓ(x)x−a (x−a)f(x) - \ell(x) = \dfrac{f(x) - \ell(x)}{x - a}\,(x - a) approaches 0⋅0=0.0 \cdot 0 = 0\mathclose{\text{.}} But ff is continuous at a,a\mathclose{\text{,}} because it is differentiable there (Module 4), so f(x)−ℓ(x)f(x) - \ell(x) also approaches f(a)−c.f(a) - c\mathclose{\text{.}} Hence c=f(a),c = f(a)\mathclose{\text{,}} and then

f(x)−ℓ(x)x−a=f(x)−f(a)x−a−m→f′(a)−m.\begin{aligned} \frac{f(x) - \ell(x)}{x - a} &= \frac{f(x) - f(a)}{x - a} - m \\ &\to f'(a) - m. \end{aligned}

This limit is 0, so m=f′(a).m = f'(a)\mathclose{\text{.}}

∎

If you read the Going deeper box at the end of Section 4.4, you have met this theorem before, as “differentiable means locally linear”; here it is put to work. Differentiability is needed. At the corner of ∣x∣\abs{x} at 0, no line c+mxc + mx will do: cc must be ∣0∣=0,\abs{0} = 0\mathclose{\text{,}} and then (∣x∣−mx)/x\big(\abs{x} - mx\big)/x approaches 1−m1 - m from the right and −1−m-1 - m from the left, which cannot both be 0.

Theorem 7.1 says that the error is small compared with x−a,x - a\mathclose{\text{,}} but not how small. The table suggests a constant times (x−a)2,(x - a)^2\mathclose{\text{,}} and that is the usual case: if f′′f'' is continuous near a,a\mathclose{\text{,}} then, for xx near a,a\mathclose{\text{,}}

f(x)−L(x)≈f′′(a)2(x−a)2,f(x) - L(x) \approx \frac{f''(a)}{2}(x - a)^2,

in the sense that (f(x)−L(x))/(x−a)2\big(f(x) - L(x)\big)/(x - a)^2 approaches f′′(a)/2f''(a)/2 as x→a.x \to a\mathclose{\text{.}} And if ∣f′′∣≤M\abs{f''} \le M between aa and x,x\mathclose{\text{,}} then ∣f(x)−L(x)∣≤M2(x−a)2.\abs{f(x) - L(x)} \le \dfrac{M}{2}(x - a)^2\mathclose{\text{.}} Both follow from Taylor’s theorem, which Module 15 proves. For x\sqrt x at 4, f′′(x)=−14x−3/2,f''(x) = -\tfrac14 x^{-3/2}\mathclose{\text{,}} so f′′(4)=−132,f''(4) = -\tfrac{1}{32}\mathclose{\text{,}} and the error at x=4.1x = 4.1 should be about −164(0.1)2≈−0.000156;-\tfrac{1}{64}(0.1)^2 \approx -0.000156\mathclose{\text{;}} the table gives −0.000154.-0.000154\mathclose{\text{.}}

Watch out

A linear approximation is good only near a.a\mathclose{\text{.}} Far away the tangent line and the curve part company: L(9)=2+54=3.25,L(9) = 2 + \tfrac54 = 3.25\mathclose{\text{,}} while 9=3.\sqrt9 = 3\mathclose{\text{.}} Before trusting f(x)≈L(x),f(x) \approx L(x)\mathclose{\text{,}} ask how far xx is from a,a\mathclose{\text{,}} and how sharply the graph bends in between.

Example 7.6The small-angle approximation✓ Checked

Find the linearisation of sin⁡θ\sin\theta at 0, and the angles for which it is accurate to within 1%.

sin⁡0=0,\sin 0 = 0\mathclose{\text{,}} and the derivative of sin⁡θ\sin\theta is cos⁡θ\cos\theta (Module 5), with cos⁡0=1.\cos 0 = 1\mathclose{\text{.}} So L(θ)=0+1⋅(θ−0)=θ:L(\theta) = 0 + 1\cdot(\theta - 0) = \theta\mathclose{\text{:}}

sin⁡θ≈θfor θ near 0,\sin\theta \approx \theta \quad\text{for } \theta \text{ near } 0,

with θ\theta in radians. The table gives the relative error (θ−sin⁡θ)/sin⁡θ,(\theta - \sin\theta)/\sin\theta\mathclose{\text{,}} the error as a fraction of the true value (Section 7.3):

θ\thetasin⁡θ\sin\thetaθ−sin⁡θsin⁡θ\dfrac{\theta - \sin\theta}{\sin\theta}
0.010.010.010000.010001.667×10−51.667\times10^{-5}
0.050.050.049980.049980.00041680.0004168
0.10.10.099830.099830.0016690.001669
0.20.20.19870.19870.0066980.006698
0.50.50.47940.47940.042910.04291
110.84150.84150.18840.1884

The relative error stays below 0.01, that is 1%, for ∣θ∣\abs{\theta} up to about 0.24 radians, about 14∘14^\circ (a calculator shows that it passes 0.01 between θ=0.24\theta = 0.24 and θ=0.25);\theta = 0.25\mathclose{\text{);}} at θ=0.1\theta = 0.1 it is about 0.17%. Like the error of the linearisation of x\sqrt x above, it shrinks about a hundredfold when θ\theta shrinks tenfold. (The relative error is an even function of θ,\theta\mathclose{\text{,}} so negative angles behave the same.)

Physics and engineering use the small-angle approximation constantly. For a pendulum, replacing sin⁡θ\sin\theta by θ\theta turns its equation of motion into one that Module 13 solves exactly, which is why the usual formula for a pendulum’s period holds only for small swings. In degrees the approximation reads sin⁡(θ∘)≈πθ/180,\sin(\theta^\circ) \approx \pi\theta/180\mathclose{\text{,}} with an awkward factor: one more reason calculus works in radians.

Differentials

Leibniz’s notation dy/dxdy/dx looks like a fraction. Differentials give its two halves a meaning of their own.

Definition 7.2Differentials

Let y=f(x),y = f(x)\mathclose{\text{,}} with ff differentiable. The differential dxdx is an independent variable: it can be any real number. The differential dydy is then defined by

dy=f′(x) dx.dy = f'(x)\,dx.

So dydy depends on two numbers, xx and dx.dx\mathclose{\text{.}}

For dx≠0,dx \ne 0\mathclose{\text{,}} dividing by dxdx gives dy/dx=f′(x):dy/dx = f'(x)\mathclose{\text{:}} the derivative is a quotient of differentials after all. Compare dydy with the actual change of yy when xx changes by Δx=dx,\Delta x = dx\mathclose{\text{,}}

Δy=f(x+dx)−f(x).\Delta y = f(x + dx) - f(x).

In Figure 7.2 (left), Δy\Delta y is the rise of the curve and dydy the rise of the tangent line between aa and a+dx:a + dx\mathclose{\text{:}} dy=L(a+dx)−L(a).dy = L(a + dx) - L(a)\mathclose{\text{.}} By Theorem 7.1, Δy−dy\Delta y - dy is small compared with dxdx when dxdx is small, so Δy≈dy.\Delta y \approx dy\mathclose{\text{.}}

Example 7.7dydy and Δy\Delta y for a cube✓ Checked

Let y=x3.y = x^3\mathclose{\text{.}} Find dydy and Δy\Delta y when x=2x = 2 and dx=0.05.dx = 0.05\mathclose{\text{.}}

dy=3x2 dx=3⋅4⋅0.05=0.6.dy = 3x^2\,dx = 3 \cdot 4 \cdot 0.05 = 0.6\mathclose{\text{.}} The actual change is

Δy=2.053−23=8.615125−8=0.615125.\begin{aligned} \Delta y &= 2.05^3 - 2^3 \\ &= 8.615125 - 8 = 0.615125. \end{aligned}

The differential is off by 0.015125,0.015125\mathclose{\text{,}} about 2.5% of Δy.\Delta y\mathclose{\text{.}} Expanding shows where the difference comes from: (2+dx)3−8=12 dx+6 (dx)2+(dx)3,(2 + dx)^3 - 8 = 12\,dx + 6\,(dx)^2 + (dx)^3\mathclose{\text{,}} and dy=12 dxdy = 12\,dx keeps only the first term.

Watch out

dydy is not Δy.\Delta y\mathclose{\text{.}} The differential is the change along the tangent line, Δy\Delta y the change along the curve. They are close only when dxdx is small, and dydy is the one that is easy to compute, which is why it is useful.

3

Propagating measurement errors

Every measurement has an error, and whatever you compute from a measured quantity inherits an error too. Differentials estimate it: if xx is measured with an error Δx,\Delta x\mathclose{\text{,}} then y=f(x)y = f(x) is computed with an error

Δy≈dy=f′(x) Δx.\Delta y \approx dy = f'(x)\,\Delta x.
Definition 7.3Absolute and relative error

Suppose a quantity whose true value is xx is measured, or computed, as x~\tilde x (read “x tilde”). The error of x~\tilde x is Δx=x−x~:\Delta x = x - \tilde x\mathclose{\text{:}} the true value minus the approximation, the same order as in the error f(x)−L(x)f(x) - L(x) of Section 7.2. The absolute error is ∣Δx∣.\abs{\Delta x}\mathclose{\text{.}} For x≠0,x \ne 0\mathclose{\text{,}} the relative error is ∣Δx∣/∣x∣;\abs{\Delta x}/\abs{x}\mathclose{\text{;}} written as a percentage, it is the percentage error.

In practice you know neither the true value nor the error, only the measured value and a bound on the error, such as “10.0 cm, to within 0.1 cm”; you then divide the bound by the measured value. When the error is small, the difference does not matter.

Example 7.8The volume of a ball✓ Checked

Suppose the radius of a ball is measured as 10.0 cm, with an error of at most 0.1 cm.

  • (a) Estimate the largest possible error in the volume computed from it, as an absolute and as a relative error.
  • (b) How accurately must the radius be measured to know the volume to within 1%?

(a) V=43πr3,V = \tfrac43\pi r^3\mathclose{\text{,}} so dV=4πr2 dr.dV = 4\pi r^2\,dr\mathclose{\text{.}} With r=10r = 10 and ∣dr∣≤0.1,\abs{dr} \le 0.1\mathclose{\text{,}}

∣dV∣≤4π⋅102⋅0.1=40π≈126 cm3.\abs{dV} \le 4\pi \cdot 10^2 \cdot 0.1 = 40\pi \approx 126 \text{ cm}^3.

The computed volume is V=4000π3≈4189V = \tfrac{4000\pi}{3} \approx 4189 cm³, so the relative error is at most about

40π4000π/3=3100=3%.\frac{40\pi}{4000\pi/3} = \frac{3}{100} = 3\%.

The exact changes confirm the estimate: V(10.1)−V(10)≈126.9V(10.1) - V(10) \approx 126.9 cm³ and V(9.9)−V(10)≈−124.4V(9.9) - V(10) \approx -124.4 cm³.

(b) Divide dV=4πr2 drdV = 4\pi r^2\,dr by V=43πr3:V = \tfrac43\pi r^3\mathclose{\text{:}}

dVV=3 drr.\frac{dV}{V} = 3\,\frac{dr}{r}.

The relative error of the volume is three times that of the radius. For a volume within 1%, the radius must be within 13%:\tfrac13\%\mathclose{\text{:}} for r=10r = 10 cm, within 10×1300≈0.03310 \times \tfrac{1}{300} \approx 0.033 cm, a third of a millimetre.

The same computation works for any power. If y=c xk,y = c\,x^k\mathclose{\text{,}} with constants c≠0c \ne 0 and k,k\mathclose{\text{,}} then dy=ck xk−1 dx,dy = ck\,x^{k-1}\,dx\mathclose{\text{,}} and dividing by y,y\mathclose{\text{,}}

dyy=k dxx.\frac{dy}{y} = k\,\frac{dx}{x}.

So the relative error of a kkth power is about ∣k∣\abs{k} times the relative error of x.x\mathclose{\text{.}} A square doubles it, a cube triples it and a square root halves it, whatever the constant c.c\mathclose{\text{.}}

Watch out

The estimate Δy≈dy\Delta y \approx dy is a linear approximation, so it is good only for small errors. If the radius is measured 50% too large, the formula says that the volume is out by 3×50%=150%,3 \times 50\% = 150\%\mathclose{\text{,}} but 1.53=3.375,1.5^3 = 3.375\mathclose{\text{,}} so the true error is 237.5%.237.5\%\mathclose{\text{.}} For large errors, compute f(x+Δx)−f(x)f(x + \Delta x) - f(x) itself.

Good to know

Computers make relative errors too: a floating-point number carries a relative error of up to about 10−16.10^{-16}\mathclose{\text{.}} The rule above says how such an error grows when you compute f(x):f(x)\mathclose{\text{:}} it is multiplied by ∣xf′(x)/f(x)∣,\abs{x f'(x)/f(x)}\mathclose{\text{,}} the condition number of ff at x.x\mathclose{\text{.}} For xkx^k the condition number is ∣k∣;\abs{k}\mathclose{\text{;}} for x−1x - 1 it is ∣x/(x−1)∣,\abs{x/(x - 1)}\mathclose{\text{,}} huge near x=1,x = 1\mathclose{\text{,}} which is the cancellation error of Module 2. Exercise 7.12 explores condition numbers.

4

Newton’s method

Most equations cannot be solved exactly by algebra: no rearrangement of cos⁡x=x\cos x = x leaves xx alone on one side, and even where a formula exists, as for cubic equations such as x3−2x−5=0,x^3 - 2x - 5 = 0\mathclose{\text{,}} it is usually easier to compute the root numerically. Module 3’s bisection method halves an interval that contains a root, gaining one binary digit, about 0.3 decimal digits, per step. Newton’s method (also called the Newton–Raphson method) uses the derivative. Near a root it is far faster; but, unlike bisection, it comes with no guarantee, and the end of this section shows how it can fail.

The idea. Near a root rr of f,f\mathclose{\text{,}} replace the graph of ff by its tangent line at a point x0x_0 that you have, and solve the easy equation instead: where does the tangent line cross the xx-axis? Call that point x1.x_1\mathclose{\text{.}} It is usually much closer to rr (Figure 7.3). Then repeat from x1.x_1\mathclose{\text{.}}

The tangent line at (xn,f(xn)),\big(x_n, f(x_n)\big)\mathclose{\text{,}} where xnx_n is read “x sub n”, is y=f(xn)+f′(xn)(x−xn),y = f(x_n) + f'(x_n)(x - x_n)\mathclose{\text{,}} the linearisation of ff at xn.x_n\mathclose{\text{.}} It meets the xx-axis where y=0.y = 0\mathclose{\text{.}} If f′(xn)≠0,f'(x_n) \ne 0\mathclose{\text{,}} solving 0=f(xn)+f′(xn)(x−xn)0 = f(x_n) + f'(x_n)(x - x_n) for xx gives x=xn−f(xn)/f′(xn).x = x_n - f(x_n)/f'(x_n)\mathclose{\text{.}}

Definition 7.4Newton’s method

To solve f(x)=0,f(x) = 0\mathclose{\text{,}} where ff is differentiable, choose a starting value x0x_0 and compute

xn+1=xn−f(xn)f′(xn),n=0,1,2,…,x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}, \quad n = 0, 1, 2, \dots,

as long as f′(xn)≠0.f'(x_n) \ne 0\mathclose{\text{.}} The numbers x0,x1,x2,…x_0, x_1, x_2, \dots are the iterates. Stop when they no longer change to the accuracy you need.

Newton's method for f(x) = x^2 - 2, starting from x0 = 3. The tangent line at big(x0, f(x0)big) meets the x-axis at x1 approx 1.83; the tangent line at big(x1, f(x1)big) meets it at x2 approx 1.46. The next iterate, x3 approx 1.415, is too close to the root sqrt2 to tell apart at this scale.
Figure 7.3

Newton’s method for f(x)=x2−2,f(x) = x^2 - 2\mathclose{\text{,}} starting from x0=3.x_0 = 3\mathclose{\text{.}} The tangent line at (x0,f(x0))\big(x_0, f(x_0)\big) meets the xx-axis at x1≈1.83;x_1 \approx 1.83\mathclose{\text{;}} the tangent line at (x1,f(x1))\big(x_1, f(x_1)\big) meets it at x2≈1.46.x_2 \approx 1.46\mathclose{\text{.}} The next iterate, x3≈1.415,x_3 \approx 1.415\mathclose{\text{,}} is too close to the root 2\sqrt2 to tell apart at this scale.

To say how good an iterate is, count its correct decimals. An approximation x~\tilde x of a number rr is correct to dd decimal places if its absolute error is less than half a unit in the ddth decimal place: ∣r−x~∣<0.5×10−d.\abs{r - \tilde x} < 0.5 \times 10^{-d}\mathclose{\text{.}} Correct to 0 decimal places means within 0.5 of r;r\mathclose{\text{;}} further away, x~\tilde x has no correct decimals at all.

Example 7.9Newton’s method for 2\sqrt2✓ Checked

Use Newton’s method to compute 2,\sqrt2\mathclose{\text{,}} starting from x0=1.x_0 = 1\mathclose{\text{.}}

2\sqrt2 is the positive root of f(x)=x2−2,f(x) = x^2 - 2\mathclose{\text{,}} with f′(x)=2x.f'(x) = 2x\mathclose{\text{.}} The step simplifies:

xn+1=xn−xn2−22xn=2xn2−xn2+22xn=12(xn+2xn).\begin{aligned} x_{n+1} &= x_n - \frac{x_n^2 - 2}{2x_n} = \frac{2x_n^2 - x_n^2 + 2}{2x_n} \\ &= \frac12\Big(x_n + \frac{2}{x_n}\Big). \end{aligned}

From x0=1:x_0 = 1\mathclose{\text{:}}

x1=12(1+2)=32,x2=12(32+43)=1712,x3=12(1712+2417)=577408.\begin{aligned} x_1 &= \tfrac12(1 + 2) = \tfrac32, \\ x_2 &= \tfrac12\Big(\tfrac32 + \tfrac43\Big) = \tfrac{17}{12}, \\ x_3 &= \tfrac12\Big(\tfrac{17}{12} + \tfrac{24}{17}\Big) = \tfrac{577}{408}. \end{aligned}

Two more steps, done exactly by computer, give the table; compare 2=1.414213562373095…:\sqrt2 = 1.414213562373095\ldots\mathclose{\text{:}}

xnx_{n}xn in decimalsx_n\text{ in decimals}xn−2x_n - \sqrt{2}
111.0000000000000001.000000000000000−0.414213562373095-0.414213562373095
32\frac{3}{2}1.5000000000000001.5000000000000000.0857864376269050.085786437626905
1712\frac{17}{12}1.4166666666666671.4166666666666670.0024531042935720.002453104293572
577408\frac{577}{408}1.4142156862745101.4142156862745100.0000021239014150.000002123901415
665857470832\frac{665857}{470832}1.4142135623746901.4142135623746900.0000000000015950.000000000001595
886731088897627013566048\frac{886731088897}{627013566048}1.4142135623730951.4142135623730950.0000000000000000.000000000000000

The iterates x0,…,x5x_0, \dots, x_5 are correct to 0, 0, 2, 5, 11 and 23 decimal places: from x2x_2 on, each step roughly doubles the number of correct decimals. (The table shows 15 decimals, so the last row looks exact; its error is about 9×10−25.)9 \times 10^{-25}\mathclose{\text{.)}}

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

Show that cos⁡x=x\cos x = x has exactly one solution in [0,1],[0, 1]\mathclose{\text{,}} and find it with Newton’s method from x0=1.x_0 = 1\mathclose{\text{.}}

Let f(x)=cos⁡x−x.f(x) = \cos x - x\mathclose{\text{.}} Then f(0)=1>0f(0) = 1 > 0 and f(1)=cos⁡1−1<0,f(1) = \cos 1 - 1 < 0\mathclose{\text{,}} so by the Intermediate Value Theorem (Module 3) ff has a root in (0,1).(0, 1)\mathclose{\text{.}} There is only one: on [0,1],[0, 1]\mathclose{\text{,}} cos⁡x\cos x decreases (on the unit circle, the xx-coordinate of the point at angle xx decreases as xx goes from 0 to π)\pi\mathclose{\text{)}} and −x-x decreases too, so ff is strictly decreasing and takes the value 0 only once.

With f′(x)=−sin⁡x−1,f'(x) = -\sin x - 1\mathclose{\text{,}} Newton’s step is

xn+1=xn−cos⁡xn−xn−sin⁡xn−1=xn+cos⁡xn−xnsin⁡xn+1.\begin{aligned} x_{n+1} &= x_n - \frac{\cos x_n - x_n}{-\sin x_n - 1} \\ &= x_n + \frac{\cos x_n - x_n}{\sin x_n + 1}. \end{aligned}

From x0=1:x_0 = 1\mathclose{\text{:}} x1=1+cos⁡1−1sin⁡1+1≈1+−0.459701.84147≈0.75036.x_1 = 1 + \dfrac{\cos 1 - 1}{\sin 1 + 1} \approx 1 + \dfrac{-0.45970}{1.84147} \approx 0.75036\mathclose{\text{.}} Further steps (the compute box below does them) give

x2≈0.7391129,x3≈0.739085133385,x4≈0.739085133215161,\begin{aligned} x_2 &\approx 0.7391129, \\ x_3 &\approx 0.739085133385, \\ x_4 &\approx 0.739085133215161, \end{aligned}

correct to 1, 4, 9 and 19 decimal places for x1,…,x4.x_1, \dots, x_4\mathclose{\text{.}} The solution is x≈0.739085133215161,x \approx 0.739085133215161\mathclose{\text{,}} to 15 decimal places.

Compute itNewton’s method in Python

A few lines of Python carry out Newton’s method. Here are the iterates of Example 7.10, in floating point:

Python
import math

def newton(f, df, x, steps):
    for n in range(1, steps + 1):
        x = x - f(x)/df(x)
        print(f"x{n} = {x:.16f}   f(x{n}) = {f(x):.1e}")
    return x

f = lambda x: math.cos(x) - x
df = lambda x: -math.sin(x) - 1
root = newton(f, df, 1.0, 5)
Output
x1 = 0.7503638678402439   f(x1) = -1.9e-02
x2 = 0.7391128909113617   f(x2) = -4.6e-05
x3 = 0.7390851333852840   f(x3) = -2.8e-10
x4 = 0.7390851332151607   f(x4) = 0.0e+00
x5 = 0.7390851332151607   f(x5) = 0.0e+00

After four steps f(x4)f(x_4) is exactly 0 in floating point, and the fifth step changes nothing: the iterates have reached the limit of double precision, about 16 significant digits. Bisection would need more than 50 halvings of [0,1][0, 1] to get as close.

Square roots work the same way. This function computes a\sqrt a with the step of Example 7.9, xn+1=12(xn+a/xn).x_{n+1} = \tfrac12(x_n + a/x_n)\mathclose{\text{.}} It starts above a;\sqrt a\mathclose{\text{;}} Theorem 7.2 below shows that the iterates then decrease towards a,\sqrt a\mathclose{\text{,}} so the function stops as soon as they stop decreasing:

Python
def my_sqrt(a):
    x = max(a, 1.0)               # a starting value above sqrt(a)
    steps = 0
    while True:
        new = (x + a/x)/2
        steps += 1
        if new >= x:              # no longer decreasing: as good as it gets
            return x, steps
        x = new

for a in [2.0, 3.0, 1e6]:
    print(a, my_sqrt(a), math.sqrt(a))
Output
2.0 (1.414213562373095, 6) 1.4142135623730951
3.0 (1.7320508075688772, 6) 1.7320508075688772
1000000.0 (1000.0, 16) 1000.0

For 3 and 10610^6 the answers agree with math.sqrt to the last digit. For 2 they differ in the last binary digit, by 2−52≈2.2×10−16:2^{-52} \approx 2.2 \times 10^{-16}\mathclose{\text{:}} math.sqrt returns the floating-point number closest to 2,\sqrt2\mathclose{\text{,}} this function returns the next one down, and getting that last digit right takes more care than this short function does. The 16 steps for 10610^6 show the cost of a poor start: from x0=106,x_0 = 10^6\mathclose{\text{,}} each early step only halves x,x\mathclose{\text{,}} because a/xa/x is tiny next to x;x\mathclose{\text{;}} the digits start to double only near the root.

Why the digits double

For square roots, the doubling can be proved in a few lines. For iterates it is convenient to subtract the other way round from an error: write en=xn−r,e_n = x_n - r\mathclose{\text{,}} where rr is the root. This is the error of xnx_n (Definition 7.3) with its sign reversed: it is positive when xnx_n is too big, and ∣en∣\abs{e_n} is the absolute error.

Theorem 7.2Newton’s method for square roots

Let a>0a > 0 and x0>0,x_0 > 0\mathclose{\text{,}} and let xn+1=12(xn+a/xn)x_{n+1} = \tfrac12\big(x_n + a/x_n\big) for n=0,1,2,….n = 0, 1, 2, \dots\mathclose{\text{.}} Then

xn+1−a=(xn−a)22xn.x_{n+1} - \sqrt a = \frac{(x_n - \sqrt a)^2}{2x_n}.

Consequently xn≥ax_n \ge \sqrt a for every n≥1,n \ge 1\mathclose{\text{,}} the iterates decrease from x1x_1 on, and they approach a.\sqrt a\mathclose{\text{.}}

Proof

All the iterates are positive: x0>0,x_0 > 0\mathclose{\text{,}} and each step averages two positive numbers. Put the step over a common denominator and subtract a:\sqrt a\mathclose{\text{:}}

xn+1−a=xn2+a2xn−a=xn2−2a xn+a2xn=(xn−a)22xn.\begin{aligned} x_{n+1} - \sqrt a &= \frac{x_n^2 + a}{2x_n} - \sqrt a \\ &= \frac{x_n^2 - 2\sqrt a\,x_n + a}{2x_n} \\ &= \frac{(x_n - \sqrt a)^2}{2x_n}. \end{aligned}

The right side is never negative, so xn+1≥ax_{n+1} \ge \sqrt a for every n≥0:n \ge 0\mathclose{\text{:}} all the iterates from x1x_1 on are at least a.\sqrt a\mathclose{\text{.}} For such an xn,x_n\mathclose{\text{,}} a/xn≤a≤xn,a/x_n \le \sqrt a \le x_n\mathclose{\text{,}} so xn+1,x_{n+1}\mathclose{\text{,}} the average of a/xna/x_n and xn,x_n\mathclose{\text{,}} is at most xn:x_n\mathclose{\text{:}} the iterates decrease. Finally, here the root is a,\sqrt a\mathclose{\text{,}} so en=xn−a.e_n = x_n - \sqrt a\mathclose{\text{.}} For n≥1,n \ge 1\mathclose{\text{,}} 0≤en<xn,0 \le e_n < x_n\mathclose{\text{,}} so

en+1=en⋅en2xn≤en2,e_{n+1} = e_n \cdot \frac{e_n}{2x_n} \le \frac{e_n}{2},

and en≤e1/2n−1,e_n \le e_1/2^{n-1}\mathclose{\text{,}} which approaches 0.

∎

The identity explains the table of Example 7.9. Near the root 2xn≈22≈2.8,2x_n \approx 2\sqrt2 \approx 2.8\mathclose{\text{,}} so en+1≈en2/2.8:e_{n+1} \approx e_n^2/2.8\mathclose{\text{:}} an error of 10−510^{-5} becomes one of about 4×10−11.4 \times 10^{-11}\mathclose{\text{.}} Squaring the error doubles the number of zeros after the decimal point, so the number of correct digits doubles.

The same happens for any function with a nonzero derivative at its root.

Theorem 7.3Newton’s method converges quadratically

Let f(r)=0.f(r) = 0\mathclose{\text{.}} Suppose that f′f' and f′′f'' are continuous on an open interval containing r,r\mathclose{\text{,}} and that f′(r)≠0.f'(r) \ne 0\mathclose{\text{.}} Then there is a δ>0\delta > 0 such that, for every starting value x0x_0 with ∣x0−r∣<δ,\abs{x_0 - r} < \delta\mathclose{\text{,}} Newton’s method never meets f′(xn)=0,f'(x_n) = 0\mathclose{\text{,}} the iterates approach r,r\mathclose{\text{,}} and en=xn−re_n = x_n - r satisfies

lim⁡n→∞en+1en2=f′′(r)2f′(r)\lim_{n\to\infty}\frac{e_{n+1}}{e_n^2} = \frac{f''(r)}{2f'(r)}

(if no iterate lands exactly on r).r\mathclose{\text{).}} Each en+1e_{n+1} is roughly a fixed multiple of en2,e_n^2\mathclose{\text{,}} so each absolute error is roughly a fixed multiple of the square of the one before: Newton’s method converges quadratically.

The idea of the proof. Newton’s step solves Ln(x)=0,L_n(x) = 0\mathclose{\text{,}} where LnL_n is the linearisation of ff at xn.x_n\mathclose{\text{.}} The root solves f(r)=0f(r) = 0 instead, and by Section 7.2 the error of the linearisation at rr is f(r)−Ln(r)≈12f′′(xn)(r−xn)2,f(r) - L_n(r) \approx \tfrac12 f''(x_n)(r - x_n)^2\mathclose{\text{,}} so Ln(r)≈−12f′′(xn) en2.L_n(r) \approx -\tfrac12 f''(x_n)\,e_n^2\mathclose{\text{.}} But LnL_n is a line of slope f′(xn)f'(x_n) that is 0 at xn+1,x_{n+1}\mathclose{\text{,}} so Ln(r)=f′(xn)(r−xn+1)=−f′(xn) en+1.L_n(r) = f'(x_n)(r - x_{n+1}) = -f'(x_n)\,e_{n+1}\mathclose{\text{.}} Equating the two expressions for Ln(r)L_n(r) gives

en+1≈f′′(xn)2f′(xn) en2.e_{n+1} \approx \frac{f''(x_n)}{2f'(x_n)}\,e_n^2.

Taylor’s theorem (Module 15) controls the error of the first ≈\approx and turns this idea into a proof. For f(x)=x2−af(x) = x^2 - a the constant is 22⋅2a=12a,\dfrac{2}{2 \cdot 2\sqrt a} = \dfrac{1}{2\sqrt a}\mathclose{\text{,}} as in Theorem 7.2; for 2\sqrt2 it is 1/(22)≈0.354,1/(2\sqrt2) \approx 0.354\mathclose{\text{,}} and the iterates of Example 7.9 indeed give e5/e42≈0.354.e_5/e_4^2 \approx 0.354\mathclose{\text{.}}

How computers compute square roots

Programs compute square roots constantly, in graphics, physics simulations and machine learning, and a few Newton steps from a good starting value are one standard way to do it. Two ideas make it fast.

A good start. A floating-point number is stored as a=m×2e,a = m \times 2^e\mathclose{\text{,}} with 1≤m<21 \le m < 2 and a whole-number exponent e.e\mathclose{\text{.}} Moving one factor 2 into mm if ee is odd makes ee even and 1≤m<4,1 \le m < 4\mathclose{\text{,}} and then a=m×2e/2.\sqrt a = \sqrt m \times 2^{e/2}\mathclose{\text{.}} So only square roots of numbers between 1 and 4 are ever needed, and a small table, or a simple formula, can give a starting value with a small relative error, say at most 1%.

Few steps. Write xn=a (1+εn),x_n = \sqrt a\,(1 + \varepsilon_n)\mathclose{\text{,}} so that εn=en/a\varepsilon_n = e_n/\sqrt a (ε\varepsilon is the Greek “epsilon”) is positive when xnx_n is too big, and ∣εn∣\abs{\varepsilon_n} is the relative error of xn.x_n\mathclose{\text{.}} Substituting this into the identity of Theorem 7.2 and dividing by a\sqrt a gives

εn+1=εn22(1+εn).\varepsilon_{n+1} = \frac{\varepsilon_n^2}{2(1 + \varepsilon_n)}.

From ∣ε0∣≤0.01:\abs{\varepsilon_0} \le 0.01\mathclose{\text{:}} ε1≤0.0001/(2×0.99)≈5.1×10−5,\varepsilon_1 \le 0.0001/(2 \times 0.99) \approx 5.1 \times 10^{-5}\mathclose{\text{,}} and from then on εn≥0,\varepsilon_n \ge 0\mathclose{\text{,}} so εn+1≤εn2/2,\varepsilon_{n+1} \le \varepsilon_n^2/2\mathclose{\text{,}} which gives ε2≤1.3×10−9\varepsilon_2 \le 1.3 \times 10^{-9} and ε3≤8.2×10−19.\varepsilon_3 \le 8.2 \times 10^{-19}\mathclose{\text{.}} That is far below the precision of double-precision numbers, a relative error of about 1.1×10−16:1.1 \times 10^{-16}\mathclose{\text{:}} three steps are enough.

Division is slower than multiplication on most processors, so where speed matters a division-free variant is popular: Newton’s method applied to 1/y2−a=0,1/y^2 - a = 0\mathclose{\text{,}} whose root is 1/a,1/\sqrt a\mathclose{\text{,}} needs only multiplications (Exercise 7.10). Graphics programs, for example, need 1/a1/\sqrt a to scale vectors to length 1.

When Newton’s method fails

Theorem 7.3 promises success only when x0x_0 is close enough to a root at which f′f' is not 0 (with f′′f'' continuous near it). It does not say how close is close enough, and for other starting values it promises nothing. Outside those conditions Newton’s method can fail in several ways (Figure 7.4):

  • A horizontal tangent. If f′(xn)=0,f'(x_n) = 0\mathclose{\text{,}} the tangent line is horizontal and never meets the xx-axis: there is no next iterate. For f(x)=x2−2f(x) = x^2 - 2 this happens at x0=0.x_0 = 0\mathclose{\text{.}} If f′(xn)f'(x_n) is merely small, the next iterate lands far away: from x0=0.1,x_0 = 0.1\mathclose{\text{,}} x1=10.05.x_1 = 10.05\mathclose{\text{.}}
  • A cycle. For f(x)=x3−2x+2f(x) = x^3 - 2x + 2 from x0=0:x_0 = 0\mathclose{\text{:}} f(0)=2f(0) = 2 and f′(0)=−2,f'(0) = -2\mathclose{\text{,}} so x1=0−2/(−2)=1;x_1 = 0 - 2/(-2) = 1\mathclose{\text{;}} then f(1)=1f(1) = 1 and f′(1)=1,f'(1) = 1\mathclose{\text{,}} so x2=1−1=0.x_2 = 1 - 1 = 0\mathclose{\text{.}} The iterates alternate between 0 and 1 for ever, while the only real root is near −1.769.-1.769\mathclose{\text{.}}
  • Running away. The iterates move further and further from the root (Example 7.11).
  • Leaving the domain. For f(x)=ln⁡xf(x) = \ln x from x0=3,x_0 = 3\mathclose{\text{,}} x1=3−3ln⁡3≈−0.296,x_1 = 3 - 3\ln 3 \approx -0.296\mathclose{\text{,}} where ln⁡\ln is not defined.
  • Slow convergence. At a root where f′(r)=0f'(r) = 0 as well, such as the double root 1 of (x−1)2,(x - 1)^2\mathclose{\text{,}} the step is xn+1=xn−12(xn−1):x_{n+1} = x_n - \tfrac12(x_n - 1)\mathclose{\text{:}} the error only halves at each step, no better than bisection.
Example 7.11A root that Newton’s method cannot find✓ Checked

Show that Newton’s method for f(x)=x3f(x) = \sqrt[3]{x} moves away from the root 0, from every starting value x0≠0.x_0 \ne 0\mathclose{\text{.}}

For x≠0,x \ne 0\mathclose{\text{,}} f′(x)=13x3 2:f'(x) = \dfrac{1}{3\sqrt[3]{x}^{\,2}}\mathclose{\text{:}} x3\sqrt[3]{x} is the inverse of x3,x^3\mathclose{\text{,}} and the derivative of an inverse function (Module 6) is 1/(3u2)1/\big(3u^2\big) at u=x3.u = \sqrt[3]{x}\mathclose{\text{.}} So, writing u=xn3,u = \sqrt[3]{x_n}\mathclose{\text{,}} so that xn=u3,x_n = u^3\mathclose{\text{,}}

xn+1=xn−u1/(3u2)=xn−3u3=xn−3xn=−2xn.\begin{aligned} x_{n+1} &= x_n - \frac{u}{1/(3u^2)} = x_n - 3u^3 \\ &= x_n - 3x_n = -2x_n. \end{aligned}

Each step doubles the distance from the root and switches sides: from x0=1x_0 = 1 the iterates are −2,4,−8,16,…-2, 4, -8, 16, \dots (Figure 7.4, right). Theorem 7.3 does not apply, because f′(0)f'(0) does not exist: the graph has a vertical tangent at its root. At any other point (u3,u)(u^3, u) of the graph, the tangent has slope 1/(3u2),1/(3u^2)\mathclose{\text{,}} a third of the slope u/u3=1/u2u/u^3 = 1/u^2 of the line from that point to the root. So each tangent meets the axis three times as far from xnx_n as the root is: at −2xn,-2x_n\mathclose{\text{,}} beyond the root.

Two failures of Newton's method. Left: for f(x) = x^3 - 2x + 2 from x0 = 0, the tangent at x0 leads to x1 = 1, and the tangent at x1 leads back to 0; the only root, near -1.769 (green), is never reached. Right: for f(x) = sqrt[3]{x} from x0 = 1, each tangent overshoots the root 0 (green) and lands twice as far away on the other side.
Figure 7.4

Two failures of Newton’s method. Left: for f(x)=x3−2x+2f(x) = x^3 - 2x + 2 from x0=0,x_0 = 0\mathclose{\text{,}} the tangent at x0x_0 leads to x1=1,x_1 = 1\mathclose{\text{,}} and the tangent at x1x_1 leads back to 0; the only root, near −1.769-1.769 (green), is never reached. Right: for f(x)=x3f(x) = \sqrt[3]{x} from x0=1,x_0 = 1\mathclose{\text{,}} each tangent overshoots the root 0 (green) and lands twice as far away on the other side.

Tip

In practice: start close to the root (a graph, a table of values or a few steps of bisection tell you where it is), watch ∣f(xn)∣\abs{f(x_n)} and the step ∣xn+1−xn∣\abs{x_{n+1} - x_n} shrink, and give up after a fixed number of steps if they do not. Good equation solvers combine the safety of bisection with the speed of Newton’s method.

Try it

Choose a function and a starting point x0,x_0\mathclose{\text{,}} then press Step: each step draws the tangent line at the current point down to the xx-axis, and the table lists xn,x_n\mathclose{\text{,}} its number of correct decimal places, and f(xn).f(x_n)\mathclose{\text{.}} With x2−2x^2 - 2 from x0=1,x_0 = 1\mathclose{\text{,}} watch the correct decimals go 0, 0, 2, 5, 11, 15; the last is the limit of double precision. Then try the failures: x0=0x_0 = 0 for x2−2;x^2 - 2\mathclose{\text{;}} x3−2x+2x^3 - 2x + 2 from x0=0;x_0 = 0\mathclose{\text{;}} x3\sqrt[3]{x} from any x0≠0;x_0 \ne 0\mathclose{\text{;}} and type ln(x) with x0=3.x_0 = 3\mathclose{\text{.}} Finally try x3−2x−5x^3 - 2x - 5 from x0=0.8,x_0 = 0.8\mathclose{\text{,}} near a point where f′(x)=0,f'(x) = 0\mathclose{\text{,}} and see how far the first step goes.

5

L’Hôpital’s rule

Module 2 evaluated limits of the form 0/00/0 by algebra: factor and cancel, rationalise, or squeeze. Many such limits resist algebra. What is

lim⁡x→0e2x−1sin⁡3x?\lim_{x\to0}\frac{e^{2x} - 1}{\sin 3x}?

The numerator and the denominator both approach 0, and there is nothing to cancel. The numbers suggest 2/3:2/3\mathclose{\text{:}}

xxe2x−1e^{2x} - 1sin⁡3x\sin 3xe2x−1sin⁡3x\dfrac{e^{2x} - 1}{\sin 3x}
0.10.10.2214030.2214030.2955200.2955200.7491970.749197
0.010.010.02020130.02020130.02999550.02999550.6734790.673479
0.0010.0010.002002000.002002000.003000000.003000000.6673350.667335
−0.001-0.001−0.00199800-0.00199800−0.00300000-0.003000000.6660010.666001
−0.01-0.01−0.0198013-0.0198013−0.0299955-0.02999550.6601430.660143
−0.1-0.1−0.181269-0.181269−0.295520-0.2955200.6133900.613390

Figure 7.5 shows why. Near 0 each function is close to its tangent line there: e2x−1≈2x,e^{2x} - 1 \approx 2x\mathclose{\text{,}} since its derivative at 0 is 2, and sin⁡3x≈3x,\sin 3x \approx 3x\mathclose{\text{,}} since its derivative at 0 is 3. So the ratio is close to 2x/3x=2/3:2x/3x = 2/3\mathclose{\text{:}} the ratio of the slopes.

Left: e^{2x} - 1 and sin 3x both pass through the origin, close to their tangent lines y = 2x and y = 3x (dashed). Right: their ratio, which is not defined at 0 (the hollow dot), approaches 2/3, the ratio of the slopes of the tangent lines.
Figure 7.5

Left: e2x−1e^{2x} - 1 and sin⁡3x\sin 3x both pass through the origin, close to their tangent lines y=2xy = 2x and y=3xy = 3x (dashed). Right: their ratio, which is not defined at 0 (the hollow dot), approaches 2/3,2/3\mathclose{\text{,}} the ratio of the slopes of the tangent lines.

Definition 7.5Indeterminate forms 0/00/0 and ∞/∞\infty/\infty

If f(x)→0f(x) \to 0 and g(x)→0g(x) \to 0 as x→a,x \to a\mathclose{\text{,}} the limit of f(x)/g(x)f(x)/g(x) has the indeterminate form 0/0.0/0\mathclose{\text{.}} If f(x)→±∞f(x) \to \pm\infty and g(x)→±∞,g(x) \to \pm\infty\mathclose{\text{,}} it has the indeterminate form ∞/∞.\infty/\infty\mathclose{\text{.}} Here aa may be a number, ∞\infty or −∞,-\infty\mathclose{\text{,}} and the limits may be one-sided.

“Indeterminate” means that the form alone does not decide the limit. As x→0,x \to 0\mathclose{\text{,}} x/x→1,x/x \to 1\mathclose{\text{,}} x2/x→0x^2/x \to 0 and x/x3→∞,x/x^3 \to \infty\mathclose{\text{,}} all of the form 0/0:0/0\mathclose{\text{:}} you must look more closely at ff and g.g\mathclose{\text{.}}

The rule

Theorem 7.4L’Hôpital’s rule, simple form

Let ff and gg be defined on an open interval containing a,a\mathclose{\text{,}} with f(a)=g(a)=0.f(a) = g(a) = 0\mathclose{\text{.}} If f′(a)f'(a) and g′(a)g'(a) exist and g′(a)≠0,g'(a) \ne 0\mathclose{\text{,}} then

lim⁡x→af(x)g(x)=f′(a)g′(a).\lim_{x\to a}\frac{f(x)}{g(x)} = \frac{f'(a)}{g'(a)}.
Proof

For x≠ax \ne a in the interval, subtract f(a)=0f(a) = 0 and g(a)=0,g(a) = 0\mathclose{\text{,}} then divide the numerator and the denominator by x−a≠0:x - a \ne 0\mathclose{\text{:}}

f(x)g(x)=f(x)−f(a)g(x)−g(a)=f(x)−f(a)x−ag(x)−g(a)x−a.\frac{f(x)}{g(x)} = \frac{f(x) - f(a)}{g(x) - g(a)} = \frac{\dfrac{f(x) - f(a)}{x - a}}{\dfrac{g(x) - g(a)}{x - a}}.

As x→a,x \to a\mathclose{\text{,}} the numerator approaches f′(a)f'(a) and the denominator approaches g′(a),g'(a)\mathclose{\text{,}} by the definition of the derivative (Module 4). Since g′(a)≠0,g'(a) \ne 0\mathclose{\text{,}} the quotient law for limits (Module 2) gives the limit f′(a)/g′(a).f'(a)/g'(a)\mathclose{\text{.}}

One detail remains: f(x)/g(x)f(x)/g(x) must be defined for xx near a,a\mathclose{\text{,}} that is, g(x)≠0.g(x) \ne 0\mathclose{\text{.}} The difference quotient of gg approaches g′(a)≠0,g'(a) \ne 0\mathclose{\text{,}} so for xx close enough to aa it lies within ∣g′(a)∣/2\abs{g'(a)}/2 of g′(a)g'(a) and is not 0; then g(x)=(x−a)⋅g(x)−g(a)x−a≠0g(x) = (x - a) \cdot \dfrac{g(x) - g(a)}{x - a} \ne 0 for those x≠a.x \ne a\mathclose{\text{.}}

∎
Example 7.12The ratio of the slopes✓ Checked

Find lim⁡x→0e2x−1sin⁡3x.\displaystyle\lim_{x\to0}\frac{e^{2x} - 1}{\sin 3x}\mathclose{\text{.}}

Let f(x)=e2x−1f(x) = e^{2x} - 1 and g(x)=sin⁡3x.g(x) = \sin 3x\mathclose{\text{.}} Both are differentiable everywhere, with f(0)=e0−1=0f(0) = e^0 - 1 = 0 and g(0)=sin⁡0=0.g(0) = \sin 0 = 0\mathclose{\text{.}} By the chain rule f′(x)=2e2xf'(x) = 2e^{2x} and g′(x)=3cos⁡3x,g'(x) = 3\cos 3x\mathclose{\text{,}} so f′(0)=2f'(0) = 2 and g′(0)=3≠0.g'(0) = 3 \ne 0\mathclose{\text{.}} By Theorem 7.4,

lim⁡x→0e2x−1sin⁡3x=f′(0)g′(0)=23,\lim_{x\to0}\frac{e^{2x} - 1}{\sin 3x} = \frac{f'(0)}{g'(0)} = \frac{2}{3},

as the table and Figure 7.5 suggested.

The simple form needs f(a)=g(a)=0f(a) = g(a) = 0 and g′(a)≠0,g'(a) \ne 0\mathclose{\text{,}} and often one of these fails: ff and gg may not be defined at a,a\mathclose{\text{,}} aa may be ∞,\infty\mathclose{\text{,}} or g′(a)g'(a) may be 0 as well. The general rule compares the limit of f/gf/g with the limit of f′/g′f'/g' instead of with values at a.a\mathclose{\text{.}}

Theorem 7.5L’Hôpital’s rule

Let ff and gg be differentiable on an open interval II containing a,a\mathclose{\text{,}} except possibly at aa itself, with g′(x)≠0g'(x) \ne 0 for every x≠ax \ne a in I.I\mathclose{\text{.}} Suppose that the limit of f(x)/g(x)f(x)/g(x) as x→ax \to a has one of the indeterminate forms 0/00/0 or ∞/∞.\infty/\infty\mathclose{\text{.}} If

lim⁡x→af′(x)g′(x)=L,\lim_{x\to a}\frac{f'(x)}{g'(x)} = L,

where LL is a real number, ∞\infty or −∞,-\infty\mathclose{\text{,}} then

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

The same holds for one-sided limits, with II an open interval that has aa as an endpoint, and for x→∞x \to \infty or x→−∞,x \to -\infty\mathclose{\text{,}} with II an interval (b,∞)(b, \infty) or (−∞,b).(-\infty, b)\mathclose{\text{.}}

Module 8 proves this general form, in a Going deeper box, with Cauchy’s mean value theorem; the proof needs tools that you do not have yet. Each hypothesis is needed. The form must be indeterminate (the first pitfall below); g′g' must not be 0 near a,a\mathclose{\text{,}} so that f′/g′f'/g' is defined there; and the limit of f′/g′f'/g' must exist: if it does not, the rule says nothing (the third pitfall).

Example 7.13Using the rule twice✓ Checked

Find lim⁡x→0ex−1−xx2.\displaystyle\lim_{x\to0}\frac{e^x - 1 - x}{x^2}\mathclose{\text{.}}

At x=0x = 0 the numerator is 1−1−0=01 - 1 - 0 = 0 and the denominator is 0: the form is 0/0.0/0\mathclose{\text{.}} The simple form does not apply, because the derivative of x2,x^2\mathclose{\text{,}} 2x,2x\mathclose{\text{,}} is 0 at 0. Theorem 7.5 applies (near 0, 2x≠02x \ne 0 except at 0) and says that the limit equals

lim⁡x→0ex−12x,\lim_{x\to0}\frac{e^x - 1}{2x},

if this limit exists. It has the form 0/00/0 again, and now the simple form applies: f1(x)=ex−1f_1(x) = e^x - 1 and g1(x)=2xg_1(x) = 2x have f1(0)=g1(0)=0,f_1(0) = g_1(0) = 0\mathclose{\text{,}} f1′(0)=e0=1f_1'(0) = e^0 = 1 and g1′(0)=2≠0,g_1'(0) = 2 \ne 0\mathclose{\text{,}} so this limit is 12.\tfrac12\mathclose{\text{.}} Therefore

lim⁡x→0ex−1−xx2=12.\lim_{x\to0}\frac{e^x - 1 - x}{x^2} = \frac12.

The answer says something about ex:e^x\mathclose{\text{:}} near 0, ex−1−x≈12x2,e^x - 1 - x \approx \tfrac12 x^2\mathclose{\text{,}} that is, ex≈1+x+12x2,e^x \approx 1 + x + \tfrac12 x^2\mathclose{\text{,}} a better approximation than the linearisation 1+x.1 + x\mathclose{\text{.}} Module 15 takes this idea much further.

Example 7.14A limit at infinity✓ Checked

In machine learning, the softplus function s(x)=ln⁡(1+ex)s(x) = \ln(1 + e^x) is a smooth version of the function ReLU⁡(x)=max⁡(0,x)\operatorname{ReLU}(x) = \max(0, x) of Section 1.3. Show that s(x)/x→1s(x)/x \to 1 as x→∞.x \to \infty\mathclose{\text{.}}

As x→∞,x \to \infty\mathclose{\text{,}} ln⁡(1+ex)→∞\ln(1 + e^x) \to \infty and x→∞:x \to \infty\mathclose{\text{:}} the form is ∞/∞.\infty/\infty\mathclose{\text{.}} The derivatives are ex1+ex\dfrac{e^x}{1 + e^x} (chain rule) and 1, which is never 0, and dividing the numerator and the denominator by ex,e^x\mathclose{\text{,}}

lim⁡x→∞ex/(1+ex)1=lim⁡x→∞1e−x+1=10+1=1.\begin{aligned} \lim_{x\to\infty}\frac{e^x/(1 + e^x)}{1} &= \lim_{x\to\infty}\frac{1}{e^{-x} + 1} \\ &= \frac{1}{0 + 1} = 1. \end{aligned}

By Theorem 7.5, s(x)/x→1:s(x)/x \to 1\mathclose{\text{:}} for large x,x\mathclose{\text{,}} softplus behaves like ReLU, which equals xx there.

Using the rule correctly

Watch out

Check the form first. L’Hôpital’s rule applies only to 0/00/0 and ∞/∞.\infty/\infty\mathclose{\text{.}} Take lim⁡x→01−cos⁡xx+x2.\displaystyle\lim_{x\to0}\frac{1 - \cos x}{x + x^2}\mathclose{\text{.}} It has the form 0/0,0/0\mathclose{\text{,}} and the rule gives lim⁡x→0sin⁡x1+2x=01=0,\displaystyle\lim_{x\to0}\frac{\sin x}{1 + 2x} = \frac{0}{1} = 0\mathclose{\text{,}} the right answer. Applying the rule again, to sin⁡x1+2x,\dfrac{\sin x}{1 + 2x}\mathclose{\text{,}} which is not indeterminate, gives cos⁡x2→12:\dfrac{\cos x}{2} \to \dfrac12\mathclose{\text{:}} wrong. At each stage, substitute first, and differentiate only if the result is 0/00/0 or ∞/∞.\infty/\infty\mathclose{\text{.}}

Watch out

Differentiate the top and the bottom separately. The rule uses f′(x)g′(x),\dfrac{f'(x)}{g'(x)}\mathclose{\text{,}} the quotient of two derivatives, not (fg)′(x),\Big(\dfrac{f}{g}\Big)'(x)\mathclose{\text{,}} the derivative of the quotient. Reaching for the quotient rule of Module 5 here is a common slip, and it gives a different expression with, in general, a different limit.

Watch out

The converse is false. If f′/g′f'/g' has no limit, the rule says nothing about f/g.f/g\mathclose{\text{.}} As x→∞,x \to \infty\mathclose{\text{,}} x+sin⁡xx=1+sin⁡xx→1\dfrac{x + \sin x}{x} = 1 + \dfrac{\sin x}{x} \to 1 (by the squeeze theorem, since ∣sin⁡x/x∣≤1/x),\abs{\sin x/x} \le 1/x\mathclose{\text{),}} but the quotient of the derivatives, 1+cos⁡x1,\dfrac{1 + \cos x}{1}\mathclose{\text{,}} keeps swinging between 0 and 2 and has no limit.

Good to know

L’Hôpital’s rule gives lim⁡θ→0sin⁡θθ=cos⁡01=1\displaystyle\lim_{\theta\to0}\frac{\sin\theta}{\theta} = \frac{\cos 0}{1} = 1 in one line, but as a proof that would be circular: the derivative of sin⁡,\sin\mathclose{\text{,}} which the rule uses, was found from this very limit (Modules 2 and 5). The rule is a tool for limits whose ingredients you can already differentiate.

6

Other indeterminate forms

Products, differences and powers have indeterminate forms too. As x→∞,x \to \infty\mathclose{\text{,}} 1/x→01/x \to 0 and x→∞,x \to \infty\mathclose{\text{,}} yet

1x⋅x→1,1x2⋅x→0,1x⋅x2→∞.\frac{1}{x}\cdot x \to 1, \quad \frac{1}{x^2}\cdot x \to 0, \quad \frac{1}{x}\cdot x^2 \to \infty.

A product of the form 0⋅∞0\cdot\infty can approach anything. The same is true of differences of the form ∞−∞\infty - \infty and of powers of the forms 1∞,1^\infty\mathclose{\text{,}} 000^0 and ∞0;\infty^0\mathclose{\text{;}} these are indeterminate forms too. The strategy for each is to rewrite the expression as a quotient of the form 0/00/0 or ∞/∞,\infty/\infty\mathclose{\text{,}} and use L’Hôpital’s rule.

Products and differences

A product fgfg of the form 0⋅∞0\cdot\infty becomes a quotient when you divide by the reciprocal of one factor: fg=f1/g,fg = \dfrac{f}{1/g}\mathclose{\text{,}} of the form 0/0,0/0\mathclose{\text{,}} or fg=g1/f,fg = \dfrac{g}{1/f}\mathclose{\text{,}} of the form ∞/∞.\infty/\infty\mathclose{\text{.}} Choose the one with the simpler derivatives.

Example 7.15xln⁡xx\ln x near 0✓ Checked

Find lim⁡x→0+xln⁡x.\displaystyle\lim_{x\to0^+} x\ln x\mathclose{\text{.}}

As x→0+,x \to 0^+\mathclose{\text{,}} x→0x \to 0 and ln⁡x→−∞:\ln x \to -\infty\mathclose{\text{:}} the form is 0⋅∞.0\cdot\infty\mathclose{\text{.}} Write the product as ln⁡x1/x,\dfrac{\ln x}{1/x}\mathclose{\text{,}} of the form ∞/∞\infty/\infty (the top approaches −∞,-\infty\mathclose{\text{,}} the bottom ∞).\infty\mathclose{\text{).}} The quotient of the derivatives is

1/x−1/x2=−x  →  0,\frac{1/x}{-1/x^2} = -x \;\to\; 0,

and −1/x2≠0,-1/x^2 \ne 0\mathclose{\text{,}} so by Theorem 7.5

lim⁡x→0+xln⁡x=0.\lim_{x\to0^+} x\ln x = 0.

The factor xx wins against ln⁡x.\ln x\mathclose{\text{.}} The other choice, x1/ln⁡x,\dfrac{x}{1/\ln x}\mathclose{\text{,}} leads to 1−1/(x(ln⁡x)2)=−x(ln⁡x)2,\dfrac{1}{-1/\big(x(\ln x)^2\big)} = -x(\ln x)^2\mathclose{\text{,}} which is worse than where you started.

A difference of the form ∞−∞\infty - \infty usually becomes a quotient when you put it over a common denominator; sometimes factoring or rationalising does it.

Example 7.16A difference of the form ∞−∞\infty - \infty✓ Checked

Find lim⁡x→1(xx−1−1ln⁡x).\displaystyle\lim_{x\to1}\Big(\frac{x}{x - 1} - \frac{1}{\ln x}\Big)\mathclose{\text{.}}

As x→1+x \to 1^+ both terms approach ∞,\infty\mathclose{\text{,}} and as x→1−x \to 1^- both approach −∞.-\infty\mathclose{\text{.}} Over the common denominator (x−1)ln⁡x,(x - 1)\ln x\mathclose{\text{,}}

xx−1−1ln⁡x=xln⁡x−(x−1)(x−1)ln⁡x,\frac{x}{x - 1} - \frac{1}{\ln x} = \frac{x\ln x - (x - 1)}{(x - 1)\ln x},

of the form 0/00/0 at x=1.x = 1\mathclose{\text{.}} Differentiate the top and the bottom, each with the product rule:

ln⁡x+1−1ln⁡x+(x−1)/x=ln⁡xln⁡x+1−1/x.\frac{\ln x + 1 - 1}{\ln x + (x - 1)/x} = \frac{\ln x}{\ln x + 1 - 1/x}.

Theorem 7.5 needs the derivative of the bottom to be non-zero near 1, except at 1, and it is: for x>1,x > 1\mathclose{\text{,}} ln⁡x\ln x and 1−1/x1 - 1/x are both positive, and for 0<x<10 < x < 1 both are negative. The new quotient is 0/00/0 again, and now the simple form applies with f(x)=ln⁡xf(x) = \ln x and g(x)=ln⁡x+1−1/x:g(x) = \ln x + 1 - 1/x\mathclose{\text{:}} f′(1)=1f'(1) = 1 and, since g′(x)=1/x+1/x2,g'(x) = 1/x + 1/x^2\mathclose{\text{,}} g′(1)=2.g'(1) = 2\mathclose{\text{.}} So, by Theorems 7.4 and 7.5,

lim⁡x→1(xx−1−1ln⁡x)=12.\lim_{x\to1}\Big(\frac{x}{x - 1} - \frac{1}{\ln x}\Big) = \frac12.

Powers

The forms 1∞,1^\infty\mathclose{\text{,}} 000^0 and ∞0\infty^0 arise in limits of f(x)g(x),f(x)^{g(x)}\mathclose{\text{,}} with f(x)>0.f(x) > 0\mathclose{\text{.}} Take logarithms: if y=f(x)g(x),y = f(x)^{g(x)}\mathclose{\text{,}} then

ln⁡y=g(x)ln⁡f(x),\ln y = g(x)\ln f(x),

which has the form 0⋅∞0\cdot\infty in all three cases. Find the limit LL of ln⁡y;\ln y\mathclose{\text{;}} then, because exe^x is continuous (Module 3), y=eln⁡yy = e^{\ln y} approaches eL.e^L\mathclose{\text{.}}

Example 7.17The limit that defines ee✓ Checked

Show that lim⁡x→∞(1+ax)x=ea\displaystyle\lim_{x\to\infty}\Big(1 + \frac{a}{x}\Big)^x = e^a for every real number a,a\mathclose{\text{,}} and deduce that (1+1n)n→e\Big(1 + \dfrac1n\Big)^n \to e as n→∞.n \to \infty\mathclose{\text{.}}

For a=0a = 0 every value is 1x=1=e0.1^x = 1 = e^0\mathclose{\text{.}} For a≠0a \ne 0 the form is 1∞.1^\infty\mathclose{\text{.}} Let y=(1+a/x)x,y = (1 + a/x)^x\mathclose{\text{,}} for x>∣a∣,x > \abs{a}\mathclose{\text{,}} so that 1+a/x>0.1 + a/x > 0\mathclose{\text{.}} Then

ln⁡y=xln⁡(1+ax)=ln⁡(1+a/x)1/x,\ln y = x\ln\Big(1 + \frac{a}{x}\Big) = \frac{\ln(1 + a/x)}{1/x},

of the form 0/0.0/0\mathclose{\text{.}} The top and the bottom are differentiable for x>∣a∣,x > \abs{a}\mathclose{\text{,}} and the derivative of the bottom, −1/x2,-1/x^2\mathclose{\text{,}} is never 0. Differentiate the top (chain rule) and the bottom:

11+a/x⋅(−ax2)−1x2=a1+a/x  →  a.\frac{\dfrac{1}{1 + a/x}\cdot\Big(-\dfrac{a}{x^2}\Big)}{-\dfrac{1}{x^2}} = \frac{a}{1 + a/x} \;\to\; a.

So ln⁡y→a\ln y \to a by Theorem 7.5, and y→ea.y \to e^a\mathclose{\text{.}} With a=1,a = 1\mathclose{\text{,}} (1+1/x)x→e(1 + 1/x)^x \to e as x→∞,x \to \infty\mathclose{\text{,}} and therefore also as xx runs through the whole numbers n=1,2,3,….n = 1, 2, 3, \dots\mathclose{\text{.}}

This is the compound interest of Module 6, whose Theorem 6.6 proved the same limit for whole numbers n,n\mathclose{\text{,}} from the derivative of ln⁡\ln at 1; L’Hôpital’s rule gives a second proof, for every real x.x\mathclose{\text{.}} Interest at a rate aa a year, added nn times a year, multiplies money by (1+a/n)n(1 + a/n)^n in a year, and as nn grows that approaches ea,e^a\mathclose{\text{,}} the factor for interest added continuously.

Example 7.18000^0 and ∞0\infty^0✓ Checked

Find lim⁡x→0+xx\displaystyle\lim_{x\to0^+} x^x and lim⁡x→∞x1/x.\displaystyle\lim_{x\to\infty} x^{1/x}\mathclose{\text{.}}

xx,x^x\mathclose{\text{,}} of the form 00.0^0\mathclose{\text{.}} ln⁡(xx)=xln⁡x→0\ln\big(x^x\big) = x\ln x \to 0 as x→0+,x \to 0^+\mathclose{\text{,}} by Example 7.15. So xx→e0=1.x^x \to e^0 = 1\mathclose{\text{.}}

x1/x,x^{1/x}\mathclose{\text{,}} of the form ∞0.\infty^0\mathclose{\text{.}} ln⁡(x1/x)=ln⁡xx,\ln\big(x^{1/x}\big) = \dfrac{\ln x}{x}\mathclose{\text{,}} of the form ∞/∞.\infty/\infty\mathclose{\text{.}} The derivative of the bottom is 1, never 0, and the quotient of the derivatives is 1/x1→0.\dfrac{1/x}{1} \to 0\mathclose{\text{.}} So, by Theorem 7.5, ln⁡(x1/x)→0,\ln\big(x^{1/x}\big) \to 0\mathclose{\text{,}} and x1/x→e0=1;x^{1/x} \to e^0 = 1\mathclose{\text{;}} for example, 10001/1000≈1.0069.1000^{1/1000} \approx 1.0069\mathclose{\text{.}}

Watch out

Indeterminate means undecided, not “equal to 1”. By Example 7.17, forms 1∞1^\infty can approach e,e\mathclose{\text{,}} or any positive number ea.e^a\mathclose{\text{.}} Forms 000^0 need not approach 1 either: for 0<x<1,0 < x < 1\mathclose{\text{,}} x1/ln⁡x=eln⁡x/ln⁡x=e,x^{1/\ln x} = e^{\ln x/\ln x} = e\mathclose{\text{,}} so as x→0+,x \to 0^+\mathclose{\text{,}} where it has the form 00,0^0\mathclose{\text{,}} it approaches e.e\mathclose{\text{.}} And remember the last step: when ln⁡y→L,\ln y \to L\mathclose{\text{,}} the answer is eL,e^L\mathclose{\text{,}} not L.L\mathclose{\text{.}}

Compute itLimits with SymPy, and indeterminate forms in floating point

SymPy’s limit evaluates the limits of this section and the last. Its fourth argument is the direction: '+-' for a two-sided limit, '+' or '-' for a one-sided one. Leave it out and SymPy takes the limit from the right, which is not what x→0x \to 0 means. The answers agree with the examples:

Python
import sympy as sp
x = sp.symbols('x')
print(sp.limit((sp.exp(2*x) - 1)/sp.sin(3*x), x, 0, '+-'))
print(sp.limit((sp.exp(x) - 1 - x)/x**2, x, 0, '+-'))
print(sp.limit(x*sp.log(x), x, 0, '+'))
print(sp.limit(x/(x - 1) - 1/sp.log(x), x, 1, '+-'))
print(sp.limit((1 + 1/x)**x, x, sp.oo))
Output
2/3
1/2
0
1/2
E

Floating-point arithmetic has its own answers to indeterminate forms, mostly fixed by the IEEE 754 standard for floating-point arithmetic. The forms 0⋅∞,0\cdot\infty\mathclose{\text{,}} ∞−∞\infty - \infty and ∞/∞\infty/\infty give nan, “not a number”, and in Python 0/00/0 raises an error:

Python
import math
inf = math.inf
print(0.0*inf, inf - inf, inf/inf)
print(0.0**0.0, 1.0**inf, inf**0.0)
Output
nan nan nan
1.0 1.0 1.0
Pythonraises an error on purpose
print(0.0/0.0)
Error
ZeroDivisionError: float division by zero

The three powers come out as 1.0. That is a convention, convenient in programs, not a limit: (1+1/n)n(1 + 1/n)^n has the form 1∞1^\infty and approaches e.e\mathclose{\text{.}} Floating point can even get that limit badly wrong:

Python
for n in [10, 10**6, 10**12, 10**15, 10**16]:
    print(n, (1 + 1/n)**n)
Output
10 2.5937424601000023
1000000 2.7182804690957534
1000000000000 2.7185234960372378
1000000000000000 3.035035206549262
10000000000000000 1.0

Up to n=106n = 10^6 the values approach e=2.71828…;e = 2.71828\ldots\mathclose{\text{;}} then they go wrong. For n=1016,n = 10^{16}\mathclose{\text{,}} 1+10−161 + 10^{-16} rounds to exactly 1, and 1n=1.1^n = 1\mathclose{\text{.}} For n=1012n = 10^{12} and 1015,10^{15}\mathclose{\text{,}} 1+1/n1 + 1/n is stored with a tiny relative error, and raising it to the power nn multiplies that error by about n:n\mathclose{\text{:}} the condition number of unu^n is nn (the note in Section 7.3). The cure is to avoid forming 1+1/n1 + 1/n at all: math.log1p(u) computes ln⁡(1+u)\ln(1 + u) accurately for small u,u\mathclose{\text{,}} and (1+1/n)n=enln⁡(1+1/n).(1 + 1/n)^n = e^{n\ln(1 + 1/n)}\mathclose{\text{.}}

Python
n = 10**15
print(math.exp(n*math.log1p(1/n)), math.e)
Output
2.7182818284590438 2.718281828459045
7

Comparing growth rates

Module 3 ranked functions by how fast they grow as x→∞x \to \infty (Theorem 3.11): logarithms grow more slowly than powers, and powers more slowly than exponentials. That ranking is why an algorithm whose running time grows like n2n^2 beats one that grows like 2n2^n on large inputs. Module 3 proved it in a Going deeper box with the tools it had; L’Hôpital’s rule proves it in a few lines.

Theorem 7.6Logarithms grow more slowly than powers

For every p>0,p > 0\mathclose{\text{,}}

lim⁡x→∞ln⁡xxp=0.\lim_{x\to\infty}\frac{\ln x}{x^p} = 0.
Proof

As x→∞,x \to \infty\mathclose{\text{,}} ln⁡x→∞\ln x \to \infty and xp→∞,x^p \to \infty\mathclose{\text{,}} and the derivative of xp,x^p\mathclose{\text{,}} pxp−1px^{p-1} (Module 6), is not 0 for x>0.x > 0\mathclose{\text{.}} The quotient of the derivatives is

1/xpxp−1=1pxp  →  0,\frac{1/x}{px^{p-1}} = \frac{1}{px^p} \;\to\; 0,

so by L’Hôpital’s rule (Theorem 7.5) ln⁡x/xp→0.\ln x/x^p \to 0\mathclose{\text{.}}

∎

The theorem holds for every p>0,p > 0\mathclose{\text{,}} however small, but for small pp the limit takes its time. The table shows ln⁡x/x0.1:\ln x/x^{0.1}\mathclose{\text{:}} it climbs to a largest value of 10/e≈3.68,10/e \approx 3.68\mathclose{\text{,}} at x=e10≈22 026x = e^{10} \approx 22\,026 (Module 8 shows how to find such maxima), and only then falls, slowly.

xxln⁡xx0.1\dfrac{\ln x}{x^{0.1}}
10101.8291.829
10410^{4}3.6673.667
101010^{10}2.3032.303
102010^{20}0.46050.4605
105010^{50}0.0011510.001151
1010010^{100}2.303×10−82.303\times10^{-8}
Theorem 7.7Powers grow more slowly than exponentials

For every real number pp and every a>1,a > 1\mathclose{\text{,}}

lim⁡x→∞xpax=0.\lim_{x\to\infty}\frac{x^p}{a^x} = 0.
Proof

First let a=ea = e and let p=np = n be a whole number, n≥1.n \ge 1\mathclose{\text{.}} The quotient xn/exx^n/e^x has the form ∞/∞,\infty/\infty\mathclose{\text{,}} and the derivative of exe^x is never 0. L’Hôpital’s rule turns it into nxn−1/ex,nx^{n-1}/e^x\mathclose{\text{,}} which has the form ∞/∞\infty/\infty again if n≥2.n \ge 2\mathclose{\text{.}} After nn applications,

xnex,  nxn−1ex,  n(n−1)xn−2ex,  …,  n!ex,\frac{x^n}{e^x},\; \frac{nx^{n-1}}{e^x},\; \frac{n(n-1)x^{n-2}}{e^x},\; \dots,\; \frac{n!}{e^x},

where n!=n(n−1)⋯2⋅1n! = n(n-1)\cdots2\cdot1 (Module 3). The last quotient approaches 0. By Theorem 7.5 each quotient in the list has the same limit as the next one, so, working backwards, all of them approach 0. (For n=0,n = 0\mathclose{\text{,}} 1/ex→01/e^x \to 0 directly.)

Next, any real p:p\mathclose{\text{:}} choose a whole number n≥p.n \ge p\mathclose{\text{.}} For x≥1,x \ge 1\mathclose{\text{,}} xp≤xn,x^p \le x^n\mathclose{\text{,}} so 0<xp/ex≤xn/ex,0 < x^p/e^x \le x^n/e^x\mathclose{\text{,}} and the squeeze theorem (Module 2) gives xp/ex→0.x^p/e^x \to 0\mathclose{\text{.}}

Finally, any a>1:a > 1\mathclose{\text{:}} then ln⁡a>0\ln a > 0 and ax=exln⁡a.a^x = e^{x\ln a}\mathclose{\text{.}} Put u=xln⁡a,u = x\ln a\mathclose{\text{,}} which approaches ∞\infty with x;x\mathclose{\text{;}} then

xpax=(u/ln⁡a)peu=1(ln⁡a)p⋅upeu  →  0.\frac{x^p}{a^x} = \frac{(u/\ln a)^p}{e^u} = \frac{1}{(\ln a)^p}\cdot\frac{u^p}{e^u} \;\to\; 0.
∎

Again the limit can take its time. With p=10:p = 10\mathclose{\text{:}}

xxx10ex\dfrac{x^{10}}{e^x}
1010454000454000
20202110021100
303055.355.3
40400.04450.0445
50501.88×10−51.88\times10^{-5}
1001003.72×10−243.72\times10^{-24}

At x=10,x = 10\mathclose{\text{,}} x10x^{10} is about 450,000 times as large as ex;e^x\mathclose{\text{;}} at x=100x = 100 it is smaller by a factor of about 3×1023.3 \times 10^{23}\mathclose{\text{.}}

Key idea

As x→∞,x \to \infty\mathclose{\text{,}} for every p>0,p > 0\mathclose{\text{,}} q>0q > 0 and a>1:a > 1\mathclose{\text{:}}   ln⁡x≪xp≪ax  \;\ln x \ll x^p \ll a^x\; and   (ln⁡x)q≪xp,\;(\ln x)^q \ll x^p\mathclose{\text{,}} where f≪gf \ll g (Module 3’s notation, read “f is much smaller than g”) means f(x)/g(x)→0.f(x)/g(x) \to 0\mathclose{\text{.}} The last follows from the first: (ln⁡x)q/xp=(ln⁡x/xp/q)q→0.(\ln x)^q/x^p = \big(\ln x/x^{p/q}\big)^q \to 0\mathclose{\text{.}} Any power of a logarithm loses to any positive power of x,x\mathclose{\text{,}} and any power of xx loses to any exponential with base greater than 1, whatever the constants.

Watch out

A growth rate is a statement about large xx only. x10x^{10} is larger than exe^x at x=10x = 10 and at x=30,x = 30\mathclose{\text{,}} and ln⁡x\ln x is larger than x0.1x^{0.1} for every xx from about 3 to about 3×1015.3 \times 10^{15}\mathclose{\text{.}} The same caution applies to algorithms: one that takes n2n^2 steps beats one that takes 2n2^n steps for large n,n\mathclose{\text{,}} but for n=3n = 3 the second takes 8 steps and the first 9.

8

What you learned

  • Related rates: draw a diagram, find an equation that links the changing quantities at every instant, differentiate it with respect to time (each quantity is a function of t,t\mathclose{\text{,}} so the chain rule applies), and only then substitute the values at the instant.
  • The linearisation L(x)=f(a)+f′(a)(x−a)L(x) = f(a) + f'(a)(x - a) is the tangent line at a,a\mathclose{\text{,}} and f(x)≈L(x)f(x) \approx L(x) near a.a\mathclose{\text{.}} Its error is small compared with x−ax - a (Theorem 7.1), and usually close to 12f′′(a)(x−a)2.\tfrac12 f''(a)(x - a)^2\mathclose{\text{.}} Examples: 4.1≈2.025,\sqrt{4.1} \approx 2.025\mathclose{\text{,}} sin⁡θ≈θ.\sin\theta \approx \theta\mathclose{\text{.}}
  • Differentials: dy=f′(x) dxdy = f'(x)\,dx is the change along the tangent line, Δy\Delta y the change along the curve, and Δy≈dy\Delta y \approx dy when dxdx is small.
  • Errors propagate as Δy≈f′(x) Δx.\Delta y \approx f'(x)\,\Delta x\mathclose{\text{.}} The relative error of xkx^k is about ∣k∣\abs{k} times that of x,x\mathclose{\text{,}} so a ball’s volume has three times the relative error of its radius.
  • Newton’s method xn+1=xn−f(xn)/f′(xn)x_{n+1} = x_n - f(x_n)/f'(x_n) follows tangent lines to the xx-axis. Near a root with f′(r)≠0f'(r) \ne 0 it converges quadratically, roughly doubling the correct digits at each step; for square roots, xn+1=12(xn+a/xn).x_{n+1} = \tfrac12(x_n + a/x_n)\mathclose{\text{.}} It fails at horizontal tangents, can cycle, run away or leave the domain, and is slow at multiple roots.
  • L’Hôpital’s rule: for the forms 0/00/0 and ∞/∞,\infty/\infty\mathclose{\text{,}} with g′≠0g' \ne 0 near a,a\mathclose{\text{,}} lim⁡f/g=lim⁡f′/g′\lim f/g = \lim f'/g' whenever the second limit exists. The simple form, f′(a)/g′(a)f'(a)/g'(a) when f(a)=g(a)=0f(a) = g(a) = 0 and g′(a)≠0,g'(a) \ne 0\mathclose{\text{,}} follows from the definition of the derivative. Check the form before each use, and differentiate the top and the bottom separately.
  • The other indeterminate forms: turn 0⋅∞0\cdot\infty into a quotient, put ∞−∞\infty - \infty over a common denominator, and take logarithms of 1∞,1^\infty\mathclose{\text{,}} 000^0 and ∞0.\infty^0\mathclose{\text{.}} In particular (1+a/x)x→ea.(1 + a/x)^x \to e^a\mathclose{\text{.}}
  • Growth rates: ln⁡x≪xp≪ax\ln x \ll x^p \ll a^x for p>0p > 0 and a>1,a > 1\mathclose{\text{,}} though “eventually” may mean “only for very large xx”.
9

Exercises

Exercise 7.1★A spherical balloon

Air is pumped into a spherical balloon at 100 cm³ per second.

  • (a) How fast is the radius increasing when the radius is 10 cm?
  • (b) How fast is the surface area S=4πr2S = 4\pi r^2 increasing at that moment?
  • (c) How fast is the radius increasing when the radius is 20 cm? Why is it slower?
Show solution✓ Checked

(a) The volume is V=43πr3.V = \tfrac43\pi r^3\mathclose{\text{.}} Differentiate with respect to tt (chain rule): dVdt=4πr2 drdt.\dfrac{dV}{dt} = 4\pi r^2\,\dfrac{dr}{dt}\mathclose{\text{.}} With dV/dt=100dV/dt = 100 and r=10:r = 10\mathclose{\text{:}} 100=400π drdt,100 = 400\pi\,\dfrac{dr}{dt}\mathclose{\text{,}} so

drdt=14π≈0.0796 cm/s.\frac{dr}{dt} = \frac{1}{4\pi} \approx 0.0796 \text{ cm/s}.

(b) dSdt=8πr drdt=8π⋅10⋅14π=20\dfrac{dS}{dt} = 8\pi r\,\dfrac{dr}{dt} = 8\pi \cdot 10 \cdot \dfrac{1}{4\pi} = 20 cm²/s.

(c) At r=20:r = 20\mathclose{\text{:}} 100=4π⋅400 drdt,100 = 4\pi \cdot 400\,\dfrac{dr}{dt}\mathclose{\text{,}} so drdt=116π≈0.0199\dfrac{dr}{dt} = \dfrac{1}{16\pi} \approx 0.0199 cm/s, a quarter of the rate in (a). The same 100 cm³ per second is spread over a surface 4πr24\pi r^2 that is four times as large, so the radius grows four times as slowly.

Exercise 7.2★Linear approximations
  • (a) Find the linearisation of f(x)=x3f(x) = \sqrt[3]{x} at a=27,a = 27\mathclose{\text{,}} and use it to estimate 263\sqrt[3]{26} and 283.\sqrt[3]{28}\mathclose{\text{.}}
  • (b) Find the linearisation of ln⁡x\ln x at a=1,a = 1\mathclose{\text{,}} and use it to estimate ln⁡1.1\ln 1.1 and ln⁡0.9.\ln 0.9\mathclose{\text{.}}
  • (c) Compare all four estimates with a calculator. Are they too big or too small?
Show solution✓ Checked

(a) f(27)=3f(27) = 3 and f′(x)=13x−2/3,f'(x) = \tfrac13 x^{-2/3}\mathclose{\text{,}} so f′(27)=13⋅9=127f'(27) = \dfrac{1}{3 \cdot 9} = \dfrac{1}{27} and

L(x)=3+x−2727.L(x) = 3 + \frac{x - 27}{27}.

So 263≈3−127=8027≈2.96296\sqrt[3]{26} \approx 3 - \tfrac{1}{27} = \tfrac{80}{27} \approx 2.96296 and 283≈3+127=8227≈3.03704.\sqrt[3]{28} \approx 3 + \tfrac{1}{27} = \tfrac{82}{27} \approx 3.03704\mathclose{\text{.}}

(b) ln⁡1=0\ln 1 = 0 and the derivative of ln⁡x\ln x is 1/x,1/x\mathclose{\text{,}} which is 1 at x=1.x = 1\mathclose{\text{.}} So L(x)=x−1,L(x) = x - 1\mathclose{\text{,}} and ln⁡1.1≈0.1,\ln 1.1 \approx 0.1\mathclose{\text{,}} ln⁡0.9≈−0.1.\ln 0.9 \approx -0.1\mathclose{\text{.}}

(c) A calculator gives 263≈2.96250,\sqrt[3]{26} \approx 2.96250\mathclose{\text{,}} 283≈3.03659,\sqrt[3]{28} \approx 3.03659\mathclose{\text{,}} ln⁡1.1≈0.09531\ln 1.1 \approx 0.09531 and ln⁡0.9≈−0.10536.\ln 0.9 \approx -0.10536\mathclose{\text{.}} All four estimates are slightly too big: by 0.00047 and 0.00045 for the cube roots, and by 0.0047 and 0.0054 for the logarithms. Both graphs bend downwards, so their tangent lines lie above them. The sizes of the errors match the rule f(x)−L(x)≈12f′′(a)(x−a)2f(x) - L(x) \approx \tfrac12 f''(a)(x - a)^2 of Section 7.2. For x3,\sqrt[3]{x}\mathclose{\text{,}} f′′(x)=−29x−5/3,f''(x) = -\tfrac29 x^{-5/3}\mathclose{\text{,}} so f′′(27)=−22187≈−0.00091f''(27) = -\tfrac{2}{2187} \approx -0.00091 and 12(0.00091)(1)2≈0.00046.\tfrac12(0.00091)(1)^2 \approx 0.00046\mathclose{\text{.}} For ln⁡x,\ln x\mathclose{\text{,}} f′′(1)=−1f''(1) = -1 and 12(1)(0.1)2=0.005.\tfrac12(1)(0.1)^2 = 0.005\mathclose{\text{.}}

Exercise 7.3★Is it indeterminate?

For each limit, say whether L’Hôpital’s rule applies, then find the limit.

  • (a) lim⁡x→0e3x−1x\displaystyle\lim_{x\to0}\frac{e^{3x} - 1}{x}
  • (b) lim⁡x→πsin⁡xx−π\displaystyle\lim_{x\to\pi}\frac{\sin x}{x - \pi}
  • (c) lim⁡x→0cos⁡x1+x\displaystyle\lim_{x\to0}\frac{\cos x}{1 + x}
  • (d) lim⁡x→∞2x+35x−1\displaystyle\lim_{x\to\infty}\frac{2x + 3}{5x - 1}
Show solution✓ Checked

(a) At x=0x = 0 the top is e0−1=0e^0 - 1 = 0 and the bottom is 0: the form is 0/0.0/0\mathclose{\text{.}} Both are differentiable, and the derivative of the bottom is 1, never 0, so the rule applies. The quotient of the derivatives is 3e3x1→3,\dfrac{3e^{3x}}{1} \to 3\mathclose{\text{,}} so the limit is 3.

(b) sin⁡π=0\sin\pi = 0 and π−π=0:\pi - \pi = 0\mathclose{\text{:}} the form is 0/0,0/0\mathclose{\text{,}} and the derivative of the bottom is again 1. The quotient of the derivatives is cos⁡x1→cos⁡π=−1,\dfrac{\cos x}{1} \to \cos\pi = -1\mathclose{\text{,}} so the limit is −1.-1\mathclose{\text{.}} (The simple form, Theorem 7.4, gives the same: f′(π)/g′(π)=−1/1.)f'(\pi)/g'(\pi) = -1/1\mathclose{\text{.)}}

(c) At x=0x = 0 the top is cos⁡0=1\cos 0 = 1 and the bottom is 1: not an indeterminate form, so the rule does not apply. Substitute: the limit is 1/1=1.1/1 = 1\mathclose{\text{.}} Applying the rule anyway would give −sin⁡x1→0,\dfrac{-\sin x}{1} \to 0\mathclose{\text{,}} which is wrong.

(d) Both the top and the bottom approach ∞:\infty\mathclose{\text{:}} the form is ∞/∞,\infty/\infty\mathclose{\text{,}} and the derivative of the bottom, 5, is never 0. The quotient of the derivatives is the constant 2/5,2/5\mathclose{\text{,}} so the limit is 25.\tfrac25\mathclose{\text{.}} Dividing the top and the bottom by xx (Module 3) gives the same: 2+3/x5−1/x→25.\dfrac{2 + 3/x}{5 - 1/x} \to \dfrac25\mathclose{\text{.}}

Exercise 7.4★Newton’s method by hand

The equation x3−2x−5=0x^3 - 2x - 5 = 0 has a root near 2.

  • (a) Write down Newton’s step for f(x)=x3−2x−5,f(x) = x^3 - 2x - 5\mathclose{\text{,}} and simplify it to a single fraction.
  • (b) Starting from x0=2,x_0 = 2\mathclose{\text{,}} compute x1x_1 and x2x_2 by hand (x2x_2 as a fraction and to six decimal places).
  • (c) The root is r=2.0945514815…;r = 2.0945514815\ldots\mathclose{\text{;}} to how many decimal places are x0,x_0\mathclose{\text{,}} x1x_1 and x2x_2 correct?
  • (d) Why is x0=0.8x_0 = 0.8 a poor starting value? Compute x1x_1 from it.
Show solution✓ Checked

(a) f′(x)=3x2−2.f'(x) = 3x^2 - 2\mathclose{\text{.}} Write xx for xn,x_n\mathclose{\text{,}} and put the step over the common denominator 3x2−2:3x^2 - 2\mathclose{\text{:}}

x−x3−2x−53x2−2=3x3−2x−x3+2x+53x2−2=2x3+53x2−2.\begin{aligned} &x - \frac{x^3 - 2x - 5}{3x^2 - 2} \\ &\quad= \frac{3x^3 - 2x - x^3 + 2x + 5}{3x^2 - 2} \\ &\quad= \frac{2x^3 + 5}{3x^2 - 2}. \end{aligned}

So xn+1=2xn3+53xn2−2.x_{n+1} = \dfrac{2x_n^3 + 5}{3x_n^2 - 2}\mathclose{\text{.}}

(b) x1=2⋅8+53⋅4−2=2110=2.1.x_1 = \dfrac{2 \cdot 8 + 5}{3 \cdot 4 - 2} = \dfrac{21}{10} = 2.1\mathclose{\text{.}} Then, with 2.13=9.2612.1^3 = 9.261 and 2.12=4.41,2.1^2 = 4.41\mathclose{\text{,}}

x2=2⋅9.261+53⋅4.41−2=23.52211.23=117615615≈2.094568.\begin{aligned} x_2 &= \frac{2 \cdot 9.261 + 5}{3 \cdot 4.41 - 2} = \frac{23.522}{11.23} \\ &= \frac{11761}{5615} \approx 2.094568. \end{aligned}

(c) The errors are ∣x0−r∣≈0.095,\abs{x_0 - r} \approx 0.095\mathclose{\text{,}} ∣x1−r∣≈0.0054\abs{x_1 - r} \approx 0.0054 and ∣x2−r∣≈0.000017.\abs{x_2 - r} \approx 0.000017\mathclose{\text{.}} Compare them with 0.5×10−d:0.5 \times 10^{-d}\mathclose{\text{:}} x0x_0 is correct to 0 decimal places (0.095<0.50.095 < 0.5 but not <0.05),< 0.05\mathclose{\text{),}} x1x_1 to 1 (0.0054<0.050.0054 < 0.05 but not <0.005)< 0.005\mathclose{\text{)}} and x2x_2 to 4 (0.000017<0.000050.000017 < 0.00005 but not <0.000005).< 0.000005\mathclose{\text{).}} The next iterate is correct to 9 decimal places.

(d) f′(0.8)=3⋅0.64−2=−0.08f'(0.8) = 3 \cdot 0.64 - 2 = -0.08 is nearly 0: 0.80.8 is close to 2/3≈0.816,\sqrt{2/3} \approx 0.816\mathclose{\text{,}} where f′(x)=0,f'(x) = 0\mathclose{\text{,}} so the tangent line at x0x_0 is nearly horizontal and meets the xx-axis far away. With f(0.8)=0.512−1.6−5=−6.088,f(0.8) = 0.512 - 1.6 - 5 = -6.088\mathclose{\text{,}}

x1=0.8−−6.088−0.08=0.8−76.1=−75.3,\begin{aligned} x_1 &= 0.8 - \frac{-6.088}{-0.08} \\ &= 0.8 - 76.1 = -75.3, \end{aligned}

about 77 units from the root. Here the method recovers, slowly: for large ∣xn∣\abs{x_n} the step 2xn3+53xn2−2\dfrac{2x_n^3 + 5}{3x_n^2 - 2} is close to 23xn,\tfrac23 x_n\mathclose{\text{,}} so each step shrinks the iterate by only about a third, and x12≈1.97x_{12} \approx 1.97 is the first iterate near the root again. From there the correct digits double as usual. The widget of Section 7.4 shows the whole journey.

Exercise 7.5★★Two cars

Car A is 0.3 km north of a crossroads, driving south towards it at 90 km/h. Car B is 0.4 km east of the crossroads, driving west towards it at 60 km/h. How fast is the distance between the cars changing? Is it growing or shrinking?

Show solution✓ Checked

Let xx be B’s distance east of the crossroads, yy A’s distance north of it, and zz the distance between the cars, in kilometres, at time tt in hours. Both cars approach the crossroads, so xx and yy decrease: dx/dt=−60dx/dt = -60 and dy/dt=−90.dy/dt = -90\mathclose{\text{.}} By Pythagoras’ theorem, at every instant

z2=x2+y2.z^2 = x^2 + y^2.

Differentiate with respect to t:t\mathclose{\text{:}} 2z dzdt=2x dxdt+2y dydt.2z\,\dfrac{dz}{dt} = 2x\,\dfrac{dx}{dt} + 2y\,\dfrac{dy}{dt}\mathclose{\text{.}} At the instant, x=0.4x = 0.4 and y=0.3,y = 0.3\mathclose{\text{,}} so z=0.16+0.09=0.5,z = \sqrt{0.16 + 0.09} = 0.5\mathclose{\text{,}} and

dzdt=x dx/dt+y dy/dtz=0.4(−60)+0.3(−90)0.5=−24−270.5=−102 km/h.\begin{aligned} \frac{dz}{dt} &= \frac{x\,dx/dt + y\,dy/dt}{z} \\ &= \frac{0.4(-60) + 0.3(-90)}{0.5} \\ &= \frac{-24 - 27}{0.5} = -102 \text{ km/h}. \end{aligned}

The distance is shrinking at 102 km/h. The common slip is to take both rates as positive, which gives +102:+102\mathclose{\text{:}} a distance that decreases has a negative rate.

Exercise 7.6★★Measuring a cube

The edge of a cube is measured as 30 cm, with an error of at most 0.1 cm.

  • (a) Estimate the largest error in the computed volume, as an absolute and as a relative error.
  • (b) Do the same for the computed surface area.
  • (c) How accurately must the edge be measured for the volume to be within 0.5%?
Show solution✓ Checked

(a) V=x3,V = x^3\mathclose{\text{,}} so dV=3x2 dx.dV = 3x^2\,dx\mathclose{\text{.}} With x=30x = 30 and ∣dx∣≤0.1:\abs{dx} \le 0.1\mathclose{\text{:}} ∣dV∣≤3⋅900⋅0.1=270\abs{dV} \le 3 \cdot 900 \cdot 0.1 = 270 cm³. The volume is 303=27 00030^3 = 27\,000 cm³, so the relative error is at most 270/27 000=0.01=1%.270/27\,000 = 0.01 = 1\%\mathclose{\text{.}} As a check, the rule for powers gives 3×0.130=1%.3 \times \tfrac{0.1}{30} = 1\%\mathclose{\text{.}}

(b) S=6x2,S = 6x^2\mathclose{\text{,}} so dS=12x dx,dS = 12x\,dx\mathclose{\text{,}} and ∣dS∣≤12⋅30⋅0.1=36\abs{dS} \le 12 \cdot 30 \cdot 0.1 = 36 cm². The area is 6⋅900=54006 \cdot 900 = 5400 cm², so the relative error is at most 36/5400=1150≈0.67%:36/5400 = \tfrac{1}{150} \approx 0.67\%\mathclose{\text{:}} twice the relative error of the edge, since SS is a square.

(c) dVV=3 dxx,\dfrac{dV}{V} = 3\,\dfrac{dx}{x}\mathclose{\text{,}} so the volume is within 0.5% when ∣dx∣x≤0.0053=1600,\dfrac{\abs{dx}}{x} \le \dfrac{0.005}{3} = \dfrac{1}{600}\mathclose{\text{,}} that is, ∣dx∣≤30600=0.05\abs{dx} \le \dfrac{30}{600} = 0.05 cm: half a millimetre.

Exercise 7.7★★L’Hôpital’s rule in practice

Find each limit.

  • (a) lim⁡x→0x−sin⁡xx3\displaystyle\lim_{x\to0}\frac{x - \sin x}{x^3}
  • (b) lim⁡x→0+x2ln⁡x\displaystyle\lim_{x\to0^+} x^2\ln x
  • (c) lim⁡x→0(1x−1ex−1)\displaystyle\lim_{x\to0}\Big(\frac{1}{x} - \frac{1}{e^x - 1}\Big)
Show solution✓ Checked

(a) The form is 0/0.0/0\mathclose{\text{.}} Apply the rule three times, checking the form each time (the bottoms x3,x^3\mathclose{\text{,}} 3x23x^2 and 6x6x have the derivatives 3x2,3x^2\mathclose{\text{,}} 6x6x and 6, which are not 0 near 0 except at 0):

x−sin⁡xx3,  1−cos⁡x3x2,sin⁡x6x,  cos⁡x6.\begin{aligned} &\frac{x - \sin x}{x^3},\; \frac{1 - \cos x}{3x^2}, \\ &\frac{\sin x}{6x},\; \frac{\cos x}{6}. \end{aligned}

The first three have the form 0/0;0/0\mathclose{\text{;}} the last approaches 16.\tfrac16\mathclose{\text{.}} Working backwards with Theorem 7.5, the limit is 16.\tfrac16\mathclose{\text{.}} (At the third stage the simple form also applies: cos⁡06=16.)\dfrac{\cos 0}{6} = \dfrac16\mathclose{\text{.)}}

(b) The form is 0⋅(−∞).0\cdot(-\infty)\mathclose{\text{.}} Write x2ln⁡x=ln⁡xx−2,x^2\ln x = \dfrac{\ln x}{x^{-2}}\mathclose{\text{,}} of the form ∞/∞\infty/\infty (the top approaches −∞,-\infty\mathclose{\text{,}} the bottom ∞).\infty\mathclose{\text{).}} The derivative of the bottom, −2x−3,-2x^{-3}\mathclose{\text{,}} is not 0 for x>0,x > 0\mathclose{\text{,}} and the quotient of the derivatives is

1/x−2x−3=−x22  →  0,\frac{1/x}{-2x^{-3}} = -\frac{x^2}{2} \;\to\; 0,

so the limit is 0.

(c) The form is ∞−∞\infty - \infty (from the right; −∞+∞-\infty + \infty from the left). Over a common denominator,

1x−1ex−1=ex−1−xx(ex−1),\frac1x - \frac{1}{e^x - 1} = \frac{e^x - 1 - x}{x(e^x - 1)},

of the form 0/0.0/0\mathclose{\text{.}} Differentiating the top, and the bottom with the product rule, gives ex−1ex−1+xex,\dfrac{e^x - 1}{e^x - 1 + xe^x}\mathclose{\text{,}} again 0/0,0/0\mathclose{\text{,}} and once more gives ex2ex+xex=12+x→12.\dfrac{e^x}{2e^x + xe^x} = \dfrac{1}{2 + x} \to \dfrac12\mathclose{\text{.}} The limit is 12.\tfrac12\mathclose{\text{.}} (The derivatives of the bottoms, ex−1+xexe^x - 1 + xe^x and 2ex+xex,2e^x + xe^x\mathclose{\text{,}} are not 0 near 0 except at 0: the first has the sign of x,x\mathclose{\text{,}} and the second is positive near 0.)

Exercise 7.8★★Exponential forms
  • (a) A data set has nn items. A bootstrap sample, used in statistics and machine learning, draws nn items from it at random, one at a time, with replacement. The chance that a given item is never drawn is (1−1/n)n.(1 - 1/n)^n\mathclose{\text{.}} What does it approach as n→∞?n \to \infty\mathclose{\text{?}}
  • (b) Find lim⁡x→0+(sin⁡x)x.\displaystyle\lim_{x\to0^+}(\sin x)^x\mathclose{\text{.}}
  • (c) Find lim⁡x→∞(ln⁡x)1/x.\displaystyle\lim_{x\to\infty}(\ln x)^{1/x}\mathclose{\text{.}}
Show solution✓ Checked

(a) The form is 1∞.1^\infty\mathclose{\text{.}} By Example 7.17 with a=−1,a = -1\mathclose{\text{,}} (1−1/x)x→e−1(1 - 1/x)^x \to e^{-1} as x→∞,x \to \infty\mathclose{\text{,}} so

(1−1n)n→1e≈0.368.\Big(1 - \frac1n\Big)^n \to \frac1e \approx 0.368.

For a large data set, about 36.8% of the items are left out of any one bootstrap sample.

(b) The form is 00.0^0\mathclose{\text{.}} Let y=(sin⁡x)x,y = (\sin x)^x\mathclose{\text{,}} for 0<x<π.0 < x < \pi\mathclose{\text{.}} Then ln⁡y=xln⁡sin⁡x=ln⁡sin⁡x1/x,\ln y = x\ln\sin x = \dfrac{\ln\sin x}{1/x}\mathclose{\text{,}} of the form ∞/∞\infty/\infty (the top approaches −∞).-\infty\mathclose{\text{).}} The derivative of the bottom, −1/x2,-1/x^2\mathclose{\text{,}} is never 0, and the quotient of the derivatives is

cos⁡x/sin⁡x−1/x2=−x⋅xsin⁡x⋅cos⁡x→0⋅1⋅1=0,\begin{aligned} \frac{\cos x/\sin x}{-1/x^2} &= -x \cdot \frac{x}{\sin x} \cdot \cos x \\ &\to 0 \cdot 1 \cdot 1 = 0, \end{aligned}

using x/sin⁡x→1x/\sin x \to 1 (Module 2). So ln⁡y→0\ln y \to 0 and y→e0=1.y \to e^0 = 1\mathclose{\text{.}}

(c) The form is ∞0.\infty^0\mathclose{\text{.}} Let y=(ln⁡x)1/x,y = (\ln x)^{1/x}\mathclose{\text{,}} for x>1.x > 1\mathclose{\text{.}} Then ln⁡y=ln⁡(ln⁡x)x,\ln y = \dfrac{\ln(\ln x)}{x}\mathclose{\text{,}} of the form ∞/∞.\infty/\infty\mathclose{\text{.}} The derivative of ln⁡(ln⁡x)\ln(\ln x) is 1xln⁡x\dfrac{1}{x\ln x} (chain rule) and that of the bottom is 1, so the quotient of the derivatives is 1xln⁡x→0.\dfrac{1}{x\ln x} \to 0\mathclose{\text{.}} So ln⁡y→0\ln y \to 0 and y→1.y \to 1\mathclose{\text{.}}

Exercise 7.9★★Solving e−x=xe^{-x} = x
  • (a) Show that the equation e−x=xe^{-x} = x has exactly one solution in [0,1].[0, 1]\mathclose{\text{.}}
  • (b) Show that Newton’s method for f(x)=x−e−xf(x) = x - e^{-x} has the step xn+1=1+xn1+exn.x_{n+1} = \dfrac{1 + x_n}{1 + e^{x_n}}\mathclose{\text{.}}
  • (c) Starting from x0=0.5,x_0 = 0.5\mathclose{\text{,}} compute x1x_1 and x2.x_2\mathclose{\text{.}} Given that the solution is 0.5671432904…,0.5671432904\ldots\mathclose{\text{,}} how many decimal places of each are correct?
Show solution✓ Checked

(a) f(x)=x−e−xf(x) = x - e^{-x} is continuous, with f(0)=−1<0f(0) = -1 < 0 and f(1)=1−1/e>0,f(1) = 1 - 1/e > 0\mathclose{\text{,}} so it has a root in (0,1)(0, 1) by the Intermediate Value Theorem. It has only one: xx increases, and e−xe^{-x} decreases, so −e−x-e^{-x} increases, and ff is the sum of two increasing functions, strictly increasing because xx is.

(b) f′(x)=1+e−x.f'(x) = 1 + e^{-x}\mathclose{\text{.}} Then

x−x−e−x1+e−x=x+xe−x−x+e−x1+e−x=(1+x)e−x1+e−x=1+xex+1,\begin{aligned} &x - \frac{x - e^{-x}}{1 + e^{-x}} \\ &\quad= \frac{x + xe^{-x} - x + e^{-x}}{1 + e^{-x}} \\ &\quad= \frac{(1 + x)e^{-x}}{1 + e^{-x}} = \frac{1 + x}{e^x + 1}, \end{aligned}

multiplying the top and the bottom by exe^x in the last step.

(c) x1=1.5e0.5+1≈1.52.648721≈0.566311,x_1 = \dfrac{1.5}{e^{0.5} + 1} \approx \dfrac{1.5}{2.648721} \approx 0.566311\mathclose{\text{,}} and x2=1.566311…e0.566311…+1≈0.5671431650.x_2 = \dfrac{1.566311\ldots}{e^{0.566311\ldots} + 1} \approx 0.5671431650\mathclose{\text{.}} The errors are about 0.067, 0.00083 and 1.3×10−7,1.3 \times 10^{-7}\mathclose{\text{,}} so x0,x_0\mathclose{\text{,}} x1x_1 and x2x_2 are correct to 0, 2 and 6 decimal places; x3x_3 is correct to 14 and x4x_4 to 29. The pattern 0, 2, 6, 14, 29 is the doubling of Theorem 7.3.

Exercise 7.10★★★The reciprocal square root

Programs that must avoid division compute 1/a,1/\sqrt a\mathclose{\text{,}} for a>0,a > 0\mathclose{\text{,}} as the positive root of g(y)=1y2−a.g(y) = \dfrac{1}{y^2} - a\mathclose{\text{.}}

  • (a) Show that Newton’s method for gg has the step yn+1=12yn(3−ayn2),y_{n+1} = \tfrac12 y_n\big(3 - ay_n^2\big)\mathclose{\text{,}} which needs no division.
  • (b) Write yn=(1+εn)/a,y_n = (1 + \varepsilon_n)/\sqrt a\mathclose{\text{,}} so that ∣εn∣\abs{\varepsilon_n} is the relative error of yn.y_n\mathclose{\text{.}} Show that εn+1=−12εn2(3+εn).\varepsilon_{n+1} = -\tfrac12\varepsilon_n^2(3 + \varepsilon_n)\mathclose{\text{.}}
  • (c) If ∣ε0∣≤0.01,\abs{\varepsilon_0} \le 0.01\mathclose{\text{,}} how many steps make the relative error smaller than 10−15?10^{-15}\mathclose{\text{?}}
Show solution✓ Checked

(a) g(y)=y−2−a,g(y) = y^{-2} - a\mathclose{\text{,}} so g′(y)=−2y−3.g'(y) = -2y^{-3}\mathclose{\text{.}} Then

y−g(y)g′(y)=y−y−2−a−2y−3=y+y3(y−2−a)2=y+y−ay32=3y−ay32=12y(3−ay2).\begin{aligned} y - \frac{g(y)}{g'(y)} &= y - \frac{y^{-2} - a}{-2y^{-3}} \\ &= y + \frac{y^3\big(y^{-2} - a\big)}{2} \\ &= y + \frac{y - ay^3}{2} \\ &= \frac{3y - ay^3}{2} \\ &= \frac12 y\big(3 - ay^2\big). \end{aligned}

The step uses only multiplications, a subtraction and the halving, which in binary is exact and cheap.

(b) With yn=(1+εn)/a,y_n = (1 + \varepsilon_n)/\sqrt a\mathclose{\text{,}} ayn2=(1+εn)2,ay_n^2 = (1 + \varepsilon_n)^2\mathclose{\text{,}} so

yn+1=1+εn2a(3−(1+εn)2)=(1+εn)(2−2εn−εn2)2a.\begin{aligned} y_{n+1} &= \frac{1 + \varepsilon_n}{2\sqrt a}\big(3 - (1 + \varepsilon_n)^2\big) \\ &= \frac{(1 + \varepsilon_n)\big(2 - 2\varepsilon_n - \varepsilon_n^2\big)}{2\sqrt a}. \end{aligned}

Expanding, (1+ε)(2−2ε−ε2)=2−3ε2−ε3,(1 + \varepsilon)(2 - 2\varepsilon - \varepsilon^2) = 2 - 3\varepsilon^2 - \varepsilon^3\mathclose{\text{,}} so

yn+1=1−32εn2−12εn3a,y_{n+1} = \frac{1 - \tfrac32\varepsilon_n^2 - \tfrac12\varepsilon_n^3}{\sqrt a},

that is, εn+1=−32εn2−12εn3=−12εn2(3+εn):\varepsilon_{n+1} = -\tfrac32\varepsilon_n^2 - \tfrac12\varepsilon_n^3 = -\tfrac12\varepsilon_n^2(3 + \varepsilon_n)\mathclose{\text{:}} quadratic convergence again.

(c) While ∣εn∣≤0.01,\abs{\varepsilon_n} \le 0.01\mathclose{\text{,}} ∣εn+1∣≤12εn2⋅3.01.\abs{\varepsilon_{n+1}} \le \tfrac12\varepsilon_n^2 \cdot 3.01\mathclose{\text{.}} From ∣ε0∣≤0.01\abs{\varepsilon_0} \le 0.01 this gives, with each bound rounded up, ∣ε1∣≤1.51×10−4,\abs{\varepsilon_1} \le 1.51 \times 10^{-4}\mathclose{\text{,}} ∣ε2∣≤3.41×10−8,\abs{\varepsilon_2} \le 3.41 \times 10^{-8}\mathclose{\text{,}} ∣ε3∣≤1.75×10−15\abs{\varepsilon_3} \le 1.75 \times 10^{-15} and ∣ε4∣≤4.61×10−30;\abs{\varepsilon_4} \le 4.61 \times 10^{-30}\mathclose{\text{;}} all are below 0.01, so the inequality applies at every step. Three steps are not quite enough by this bound; four steps are.

Exercise 7.11★★★How late is “eventually”?
  • (a) Prove that lim⁡x→∞(ln⁡x)10x0.1=0.\displaystyle\lim_{x\to\infty}\frac{(\ln x)^{10}}{x^{0.1}} = 0\mathclose{\text{.}}
  • (b) Show that, nevertheless, (ln⁡x)10(\ln x)^{10} is much larger than x0.1x^{0.1} at x=10100.x = 10^{100}\mathclose{\text{.}}
  • (c) With u=ln⁡x,u = \ln x\mathclose{\text{,}} the two functions are equal where 10ln⁡u=0.1u,10\ln u = 0.1u\mathclose{\text{,}} that is, where g(u)=u−100ln⁡ug(u) = u - 100\ln u is 0. Use Newton’s method from u0=600u_0 = 600 to find the large solution to 5 decimal places, and write the corresponding xx as a power of 10.
Show solution✓ Checked

(a) Write the quotient as a tenth power:

(ln⁡x)10x0.1=(ln⁡xx0.01)10.\frac{(\ln x)^{10}}{x^{0.1}} = \Big(\frac{\ln x}{x^{0.01}}\Big)^{10}.

By Theorem 7.6 with p=0.01,p = 0.01\mathclose{\text{,}} the quotient in brackets approaches 0, and t↦t10t \mapsto t^{10} is continuous, so the tenth power approaches 010=0.0^{10} = 0\mathclose{\text{.}}

(b) At x=10100,x = 10^{100}\mathclose{\text{,}} ln⁡x=100ln⁡10≈230.26,\ln x = 100\ln 10 \approx 230.26\mathclose{\text{,}} so (ln⁡x)10≈4.19×1023,(\ln x)^{10} \approx 4.19 \times 10^{23}\mathclose{\text{,}} while x0.1=1010.x^{0.1} = 10^{10}\mathclose{\text{.}} The logarithm’s power is still more than 101310^{13} times larger.

(c) g′(u)=1−100/u,g'(u) = 1 - 100/u\mathclose{\text{,}} so the step is un+1=un−un−100ln⁡un1−100/un.u_{n+1} = u_n - \dfrac{u_n - 100\ln u_n}{1 - 100/u_n}\mathclose{\text{.}} From u0=600:u_0 = 600\mathclose{\text{:}} u1≈647.63156,u_1 \approx 647.63156\mathclose{\text{,}} u2≈647.27753,u_2 \approx 647.27753\mathclose{\text{,}} u3≈647.27751,u_3 \approx 647.27751\mathclose{\text{,}} and u4u_4 agrees with u3u_3 to many more places. So u≈647.27751,u \approx 647.27751\mathclose{\text{,}} and

x=e647.27751=10647.27751/ln⁡10≈10281.1.\begin{aligned} x = e^{647.27751} &= 10^{647.27751/\ln 10} \\ &\approx 10^{281.1}. \end{aligned}

So (ln⁡x)10(\ln x)^{10} stays ahead of x0.1x^{0.1} until about x=10281.x = 10^{281}\mathclose{\text{.}} (Module 8’s tools show that gg increases for u>100,u > 100\mathclose{\text{,}} so beyond this point x0.1x^{0.1} stays ahead for good.)

Exercise 7.12★★★Condition numbers

Suppose xx is known with a small relative error ρ\rho (Greek “rho”), and y=f(x)y = f(x) is computed from it.

  • (a) Use differentials to show that the relative error of yy is about κ(x) ρ,\kappa(x)\,\rho\mathclose{\text{,}} where κ(x)=∣xf′(x)f(x)∣\kappa(x) = \abs{\dfrac{x f'(x)}{f(x)}} (Greek “kappa”) is the condition number of ff at x.x\mathclose{\text{.}}
  • (b) Find the condition number of xk,x^k\mathclose{\text{,}} of ex,e^x\mathclose{\text{,}} of ln⁡x\ln x and of x−1.x - 1\mathclose{\text{.}}
  • (c) A computer stores x=1+10−8x = 1 + 10^{-8} with a relative error of about 10−16.10^{-16}\mathclose{\text{.}} About how large is the relative error of ln⁡x\ln x computed from it? Explain the results for (1+1/n)n(1 + 1/n)^n in the compute box at the end of Section 7.6.
Show solution✓ Checked

(a) If xx is off by dx,dx\mathclose{\text{,}} then yy is off by about dy=f′(x) dx,dy = f'(x)\,dx\mathclose{\text{,}} so the relative error of yy is about

∣dyy∣=∣f′(x) dxf(x)∣=∣xf′(x)f(x)∣⋅∣dxx∣=κ(x) ρ.\begin{aligned} \abs{\frac{dy}{y}} &= \abs{\frac{f'(x)\,dx}{f(x)}} \\ &= \abs{\frac{xf'(x)}{f(x)}}\cdot\abs{\frac{dx}{x}} \\ &= \kappa(x)\,\rho. \end{aligned}

(b) For xk:x^k\mathclose{\text{:}} ∣x⋅kxk−1xk∣=∣k∣,\abs{\dfrac{x \cdot kx^{k-1}}{x^k}} = \abs{k}\mathclose{\text{,}} the rule of Section 7.3. For ex:e^x\mathclose{\text{:}} ∣xexex∣=∣x∣.\abs{\dfrac{xe^x}{e^x}} = \abs{x}\mathclose{\text{.}} For ln⁡x:\ln x\mathclose{\text{:}} ∣x⋅(1/x)ln⁡x∣=1∣ln⁡x∣.\abs{\dfrac{x \cdot (1/x)}{\ln x}} = \dfrac{1}{\abs{\ln x}}\mathclose{\text{.}} For x−1:x - 1\mathclose{\text{:}} ∣xx−1∣.\abs{\dfrac{x}{x - 1}}\mathclose{\text{.}}

(c) For ln⁡x\ln x at x=1+10−8,x = 1 + 10^{-8}\mathclose{\text{,}} ln⁡x≈10−8\ln x \approx 10^{-8} (the linear approximation ln⁡x≈x−1\ln x \approx x - 1 of Exercise 7.2), so κ≈108,\kappa \approx 10^8\mathclose{\text{,}} and the relative error of ln⁡x\ln x is about 108×10−16=10−8:10^8 \times 10^{-16} = 10^{-8}\mathclose{\text{:}} about half of the 16 digits are lost. Both ln⁡x\ln x and x−1x - 1 are badly conditioned near 1, which is why math.log1p(u) takes the small number uu itself, not 1+u.1 + u\mathclose{\text{.}} In the compute box, (1+1/n)n=un(1 + 1/n)^n = u^n with u=1+1/n,u = 1 + 1/n\mathclose{\text{,}} and unu^n has condition number n:n\mathclose{\text{:}} the relative error of about 10−1610^{-16} in storing uu grows to about n×10−16,n \times 10^{-16}\mathclose{\text{,}} which is about 10−410^{-4} for n=1012n = 10^{12} (the computed value was off by about 9×10−59 \times 10^{-5} relative to e)e\mathclose{\text{)}} and about 0.10.1 for n=1015n = 10^{15} (off by about 12%).

10

Check yourself

1
The radius of a circle grows at 2 cm/s. How fast does its area grow when the radius is 5 cm?
2
Using the linearisation of x\sqrt x at 9, 9.6\sqrt{9.6} is approximately
3
The radius of a sphere is measured with a relative error of at most 1%. The relative error of its computed surface area 4πr24\pi r^2 is about
4
One step of Newton’s method for f(x)=x2−5f(x) = x^2 - 5 from x0=2x_0 = 2 gives
5
Newton’s method for f(x)=x3f(x) = \sqrt[3]{x} from x0=1x_0 = 1 produces
6
lim⁡x→0x+1x+2\displaystyle\lim_{x\to0}\frac{x + 1}{x + 2} equals
7
lim⁡x→∞(1+3x)x\displaystyle\lim_{x\to\infty}\Big(1 + \frac{3}{x}\Big)^x equals
8
Which function grows fastest as x→∞?x \to \infty\mathclose{\text{?}}
Finished this module?