Differential Calculus 201-SN2-RE • CEGEP, Montreal
Corrected exercises: bisection, Newton's method and fixed-point iteration (201-SN2-RE)
This is the corrected exercise set on solving equations numerically for Differential Calculus, 201-SN2-RE (formerly 201-NYA): the bisection method, Newton's method, the secant method and fixed-point iteration. It is the chapter where the derivative stops being an object of study and becomes a computing tool.
Exercise 0.1 opens the set with ten iterations to compute directly, as in textbook drill lists: three bisection steps on x3+x2−3=0 and on ex=2−x, then two steps of Newton's method on x2−7=0 and x3−10=0, on two polynomial equations, on sinx=2x, lnx=2−x and ex=4x, and finally on the derivative to locate a minimum, each with a value to find to three decimals and checked as you type it.
The thread of the set fits in one sentence: a numerical method never delivers the root, it delivers a SEQUENCE that approaches it, and the only two real questions are whether it converges and how fast. Everything else, guarantee versus speed, cost per iteration, stopping criterion, follows from those two questions.
Part A builds the two basic methods (exercises 1 and 2), measures quadratic convergence (exercise 3), lists the four ways Newton's method fails (exercise 4) and compares the two methods (exercise 5). Part B adds the secant method (exercise 6) and fixed-point iteration (exercise 7), corrects five false statements (exercise 8), then looks for two applications outside mathematics: the way a processor computes a division and a cube root (exercise 9), and the internal rate of return of an investment (exercise 10). Part C goes through five classics: Newton's method against fixed-point iteration on x=e−x (exercise 11), a minimum located by Newton's method applied to f′ (exercise 12), scanning for sign changes and then bisecting (exercise 13), the sag of a power line (exercise 14) and Kepler's equation (exercise 15). Every solution is on the page.
Self-checking setType your answers and check them question by question: the page tells you right or wrong before you open the solution. With an account, every answer right on the first try earns points, and your right answers stay filled in when you come back.
•BISECTION: if f is continuous on [a,b] with f(a)f(b)<0, cut the interval in half and keep the half where the sign changes. Width after n steps: 2nb−a. LINEAR convergence with ratio 21, about 3.32 iterations per decimal place, but GUARANTEED.
•NEWTON'S METHOD: xn+1=xn−f′(xn)f(xn), obtained by solving the equation of the tangent line for its x-intercept. QUADRATIC convergence near a simple root: the number of correct decimals doubles at every step, with en+1≈2f′(r)f′′(r)en2.
•THE FOUR FAILURES OF NEWTON'S METHOD: f′(xn)=0 and the division is impossible; a cycle between two values, as on x3−2x+2 starting from 0; divergence, as on x1/3 where xn+1=−2xn; convergence that is only linear at a multiple root, where f and f′ vanish together.
•SECANT METHOD: xn+1=xn−f(xn)f(xn)−f(xn−1)xn−xn−1, the tangent line replaced by the secant line through the last two points. Order φ≈1.618, but only ONE function evaluation per step: often more efficient than Newton's method at equal cost, since φ2≈2.618>2.
•FIXED-POINT ITERATION: rewrite f(x)=0 as x=g(x) and iterate xn+1=g(xn). The sequence converges if ∣g′(r)∣<1 near the fixed point, as a STAIRCASE if g′>0, as a SPIRAL if g′<0. Newton's method is the special case where g′(r)=0, which explains its speed.
•USEFUL CASES: a by xn+1=21(xn+xna); a1 without division by xn+1=xn(2−axn); 3a by xn+1=31(2xn+xn2a).
Calculations: the iterations to compute
Exercise 0.1: Iterate Newton's method and bisect: ten direct calculations
For lines a) and b), perform three bisection steps starting from the given interval and give the midpoint of the last interval obtained. For lines c) to j), write the Newton iteration, perform two steps from the given x0 and give x2 to three decimals.
Only one setup before computing: write the equation in the form f(x)=0. For bisection, evaluate f at the midpoint and keep the half where f changes sign. For Newton's method, compute f′, then xn+1=xn−f′(xn)f(xn), carrying every decimal the calculator gives from one step to the next, in radian mode as soon as a sine appears.
a) Bisection: x3+x2−3=0 on [1,2].
b) Bisection: ex=2−x on [0,1].
c) Newton: x2−7=0, from x0=3.
d) Newton: x3−10=0, from x0=2.
e) Newton: x3−2x−5=0, from x0=2.
f) Newton: x4+x−3=0, from x0=1.
g) Newton: sinx=2x, from x0=2.
h) Newton: lnx=2−x, from x0=1.5.
i) Newton: ex=4x, from x0=0.
j) Newton's method applied to f′ to locate the minimum of f(x)=x4+3x2−5x, from x0=1.
Show the solution
Answers
a)final interval [1.125,1.25]; midpoint 1.1875
b)final interval [0.375,0.5]; midpoint 0.4375
c)x1=38; x2=48127≈2.646
d)x1=613; x2≈2.155
e)x1=2.1; x2≈2.095
f)x1=1.2; x2≈1.165
g)x1≈1.901; x2≈1.896
h)x1≈1.5567; x2≈1.5571≈1.557
i)x1=31; x2≈0.357
j)x1=1813; x2≈0.654
The move that decides everything comes before the first calculation: set up f(x)=0, with every term on the same side. An equation such as lnx=2−x does not go into Newton's formula as it stands; f(x)=lnx+x−2 does. After that, bisection only needs signs, and Newton's method only two evaluations per step.
a)
f(x)=x3+x2−3, f(1)=−1<0<f(2)=9. Midpoint 1.5: f(1.5)=2.625>0, keep [1,1.5]. Midpoint 1.25: f(1.25)≈0.516>0, keep [1,1.25]. Midpoint 1.125: f(1.125)≈−0.311<0, keep [1.125,1.25]. The midpoint of this last interval is 1.1875. Pitfall: giving the last midpoint TESTED, 1.125, instead of the midpoint of the interval obtained.
b)
f(x)=ex+x−2, f(0)=−1<0<f(1)=e−1. f(0.5)≈0.149>0: [0,0.5]. f(0.25)≈−0.466<0: [0.25,0.5]. f(0.375)≈−0.170<0: [0.375,0.5]. Midpoint: 0.4375. Pitfall: bisecting ex and 2−x separately; only the sign of their DIFFERENCE tells you which side the root is on.
c)
f(x)=x2−7, f′(x)=2x, so xn+1=xn−2xnxn2−7. x1=3−62=38≈2.666667, then x2=38−316964−7=38−481=48127≈2.646.
d)
f(x)=x3−10, f′(x)=3x2. x1=2−128−10=613≈2.166667. f(x1)≈0.171296 and f′(x1)≈14.083333, so x2≈2.166667−0.012163≈2.155.
e)
f(x)=x3−2x−5, f′(x)=3x2−2. x1=2−10−1=2.1. f(2.1)=9.261−4.2−5=0.061 and f′(2.1)=11.23, so x2=2.1−11.230.061≈2.094568≈2.095.
f)
f(x)=x4+x−3, f′(x)=4x3+1. x1=1−5−1=1.2. f(1.2)=2.0736+1.2−3=0.2736 and f′(1.2)=7.912, so x2=1.2−7.9120.2736≈1.165.
g)
f(x)=sinx−2x, f′(x)=cosx−21. f(2)≈−0.090703 and f′(2)≈−0.916147, so x1≈1.900996. Then f(x1)≈−0.004520 and f′(x1)≈−0.824232, so x2≈1.895512≈1.896. Pitfall: a calculator in degree mode gives f(2)≈−0.965 and a sequence that no longer has anything to do with the equation.
h)
f(x)=lnx+x−2, f′(x)=x1+1. f(1.5)≈−0.094535 and f′(1.5)≈1.666667, so x1≈1.556721. Then f(x1)≈−0.000697 and f′(x1)≈1.642376, so x2≈1.557146≈1.557.
i)
f(x)=ex−4x, f′(x)=ex−4. f(0)=1 and f′(0)=−3, so x1=0−−31=31. Then f(31)≈0.062279 and f′(31)≈−2.604388, so x2≈0.333333+0.023913≈0.357. Pitfall: the negative derivative; minus times minus, you MOVE to the right.
j)
The minimum is where f′ vanishes: apply Newton's method to g=f′, that is g(x)=4x3+6x−5 and g′(x)=f′′(x)=12x2+6. x1=1−185=1813≈0.722222. Then g(x1)≈0.840192 and g′(x1)≈12.259259, so x2≈0.722222−0.068535≈0.654. Pitfall: writing x1=x0−f′(x0)f(x0), which looks for a zero of f and not for its minimum.
Check: for Newton's method, f(x2) must be much closer to 0 than f(x1), roughly its square; for bisection, f must have opposite signs at the two endpoints of the last interval, and its width must be one eighth of the starting width.
Tick the exercises you have done or want to review: a free account, no password, keeps your ticks and your right answers from one visit to the next, tells you which chapter to tackle next and lets you ask for the exercise you are missing. Create your space, an email is enough.
Part A: the basics (/50)
Exercise 1: The bisection method: slow, but it never misses
The Intermediate Value Theorem proves that a root exists; it does not say where. The bisection method turns that proof into an algorithm. This is the thread of the whole set: a numerical method does not deliver the root, it delivers a SEQUENCE that approaches it, and the only real questions are whether it converges and how fast.
a) Let f(x)=x3+3x−5. Check that f(1)<0<f(2), then describe the bisection algorithm in three lines.
b) Perform the first three iterations and give the bracket obtained, as in the figure.
c) After n iterations, what is the width of the interval if you start from [1,2]? How many iterations are needed to guarantee an accuracy of 10−6?
d) Bisection is said to converge LINEARLY with ratio 21. How many iterations does it take to gain one decimal place?
e) Name the property that the bisection method has and that Newton's method lacks.
Show the solution
Answers
a)f(1)=−1<0<9=f(2)
b)[1.125,1.25]
c)Width 2−n; 20 iterations
d)ln2ln10≈3.32 iterations per decimal place
e)The guarantee of convergence
a)
f(1)=1+3−5=−1<0 and f(2)=8+6−5=9>0 ✓, and f is continuous since it is a polynomial. Algorithm: compute the midpoint m of the interval, evaluate f(m), then keep the half whose endpoints give opposite signs. Repeat. At every step, the interval still contains a root and its width is halved.
b)
m1=1.5: f(1.5)=3.375+4.5−5=2.875>0, so keep [1,1.5]. m2=1.25: f(1.25)=1.953125+3.75−5=0.703125>0, keep [1,1.25]. m3=1.125: f(1.125)=1.423828+3.375−5=−0.201172<0, this time keep the RIGHT half, [1.125,1.25]. Width reached: 0.125, and the root is inside.
c)
The width after n iterations is 2n2−1=2−n. To guarantee 2−n≤10−6, you need n≥ln26ln10≈19.93, so n=20 iterations. This number is known IN ADVANCE, independently of the function: that is the great strength of the method, you can promise the accuracy before you even start.
d)
Gaining one decimal place means dividing the error by 10. Since each iteration divides it by 2, you need n such that 2n≥10, that is n≥ln2ln10≈3.32: so it takes between 3 and 4 iterations per decimal place. This steady pace is characteristic of linear convergence, and it should be compared with Newton's method, which DOUBLES the number of correct decimals at every step.
e)
The GUARANTEE. If the sign changes at the endpoints and the function is continuous, bisection always converges, whatever the function, and the maximum error is known at every step. Newton's method is much faster but may diverge, cycle, or converge to a root other than the one you were aiming for. That is why serious numerical libraries combine the two: bisection to get close without risk, then Newton's method to finish fast.
Exercise 2: Newton's method: replacing the curve by its tangent line
The idea fits in one sentence: where the curve is hard, its tangent line is not. So you solve the equation on the tangent line, start again, and you get the most widely used method in all of numerical computing.
a) Write the equation of the tangent line to y=f(x) at the point with x-coordinate xn, then find where it crosses the x-axis. Deduce Newton's formula.
b) The figure applies the method to f(x)=x2−2 starting from x0=2. Check the values x1 and x2 shown.
c) Show that for f(x)=x2−a, Newton's formula becomes xn+1=21(xn+xna). Interpret this expression as an average.
d) Apply Newton's method to f(x)=x3+3x−5 with x0=1, and give x1, x2 and x3.
e) Compare with the result of the bisection in exercise 1 after the same number of iterations.
Show the solution
Answers
a)xn+1=xn−f′(xn)f(xn)
b)1.5, then 1.4166667
c)Average of xn and xna
d)1.1666667; 1.1542484; 1.1541715
e)Error 10−7 versus 0.125
a)
The tangent line at xn is y=f(xn)+f′(xn)(x−xn). It crosses the axis when y=0, that is x=xn−f′(xn)f(xn), provided f′(xn)=0. So set xn+1=xn−f′(xn)f(xn): this is Newton's formula. There is nothing mysterious about it, it is the equation of a line, solved.
b)
f(2)=2 and f′(2)=4, so x1=2−42=1.5 ✓. Then f(1.5)=0.25 and f′(1.5)=3, so x2=1.5−30.25=1.4166667 ✓. One more iteration gives x3=1.4142157, to compare with 2=1.4142136: three iterations from a mediocre starting point are enough for five correct decimals.
c)
f′(x)=2x, so xn+1=xn−2xnxn2−a=2xn2xn2−xn2+a=2xnxn2+a=21(xn+xna). It is the AVERAGE of xn and xna. The interpretation is a nice one: if xn is too small to be a, then xna is too large, and the true root lies between the two. This formula was already known to the Babylonians, long before Newton gave the general justification.
d)
f′(x)=3x2+3. f(1)=−1 and f′(1)=6, so x1=1+61=1.1666667. Then f(x1)=0.0879630 and f′(x1)=7.0833333, so x2=1.1666667−0.0124183=1.1542484. Finally f(x2)=0.0005378 and f′(x2)=6.9969, so x3=1.1541715. The exact root is 1.1541715: seven decimals in three steps.
e)
After three iterations, bisection had given the bracket [1.125,1.25], an error that could be as large as 0.125. After three iterations, Newton's method gives an error below 10−7. The ratio is about one million, and it stays enormous even though each Newton step costs two evaluations, of the function and of its derivative, against one for bisection. What changes is the price to pay: Newton's method requires knowing f′ and a reasonable starting point, bisection only needs a sign change.
Exercise 3: Quadratic convergence: the number of decimals doubles
Saying that Newton's method is “fast” means nothing until it has been measured. The right measure is the ratio between the error at one step and the SQUARE of the error at the previous step.
a) For f(x)=x2−2 starting from x0=2, compute the errors en=xn−2 for n from 0 to 3.
b) Compute the ratios en2en+1 and comment on how stable they are.
c) Prove that for xn+1=21(xn+xna) you have exactly en+1=2xnen2, setting en=xn−a.
d) How many correct decimals are gained per iteration? Compare with bisection.
e) What practical consequence does this have on the stopping criterion of a program?
Show the solution
Answers
a)0.5858; 0.0858; 0.00245; 2.12×10−6
b)Ratios tend to 221≈0.3536
c)en+1=2xnen2
d)Decimals doubled at every step
e)The gap between iterates estimates the error well
a)
With 2=1.41421356: e0=∣2−1.41421356∣=0.58578644; e1=∣1.5−1.41421356∣=0.08578644; e2=∣1.41666667−1.41421356∣=0.00245310; e3=∣1.41421569−1.41421356∣=2.1239×10−6.
b)
e02e1=0.343140.08578644=0.25000; e12e2=0.00735930.00245310=0.33333; e22e3=6.0177×10−62.1239×10−6=0.35294. The ratios SETTLE around 0.3536≈221. This is the signature of quadratic convergence: the new error is proportional to the square of the old one, with a constant that tends to 2f′(r)f′′(r)=2×222=221.
c)
xn+1−a=2xnxn2+a−a=2xnxn2+a−2axn=2xn(xn−a)2=2xnen2. The numerator is a perfect square, which gives TWO pieces of information at once: the convergence is quadratic, and en+1 is always positive, so the sequence approaches the root from above as of the first step, whatever the positive starting point.
d)
If the error goes from 10−k to about C×10−2k, the number of correct decimals DOUBLES at every iteration: 1, 2, 4, 8, 16. Bisection, for its part, gains one every 3.32 iterations. To reach 16 decimals starting from one decimal, Newton's method needs 4 steps, bisection about fifty.
e)
It makes the stopping criterion easy and safe. As soon as two consecutive iterates agree to k decimals, the next one would give about 2k: the gap ∣xn+1−xn∣ is therefore an excellent estimate of the remaining error, which is not true of linear methods. In practice you stop as soon as this gap falls below the required accuracy, knowing that you actually have much better. This is also why a program that has not converged within about ten iterations will not converge at all: the failure must be detected, not insisted upon.
Exercise 4: The four ways Newton's method fails
A method this fast necessarily has a price, and it is paid in reliability. Being able to recognize the four failure modes is worth more than being able to recite the formula.
a) What happens if f′(xn)=0 at some step? Give a concrete example.
b) The figure shows f(x)=x3−2x+2 with x0=0. Compute x1 then x2, and conclude.
c) Apply Newton's method to f(x)=x1/3 with x0=1 and show that the sequence diverges.
d) Apply Newton's method to f(x)=(x−1)2 with x0=2. Does the method converge? How fast?
e) Summarize the four failure modes in one sentence each, then say how a serious program protects itself against them.
Show the solution
Answers
a)Horizontal tangent: division by zero
b)x1=1, x2=0: cycle
c)xn+1=−2xn: divergence
d)xn+1=2xn+1: linear convergence
e)Cap the steps, watch ∣f∣, switch to bisection
a)
The formula divides by f′(xn): the computation stops on a division by zero. Geometrically, the tangent line is HORIZONTAL and never crosses the axis. Example: f(x)=x2−1 with x0=0 gives f′(0)=0, the method is stuck at the very first step even though the roots ±1 are very close.
b)
f(0)=2 and f′(x)=3x2−2, so f′(0)=−2 and x1=0−−22=1. Then f(1)=1−2+2=1 and f′(1)=1, so x2=1−11=0. You are back at the starting point: the sequence CYCLES between 0 and 1 forever, without ever approaching the true root, which is about −1.7693. The tangent lines at these two points send each other back and forth. No test on f(xn) detects this; only an iteration counter does.
c)
f(x)=x1/3 gives f′(x)=31x−2/3, so xn+1=xn−31xn−2/3xn1/3=xn−3xn=−2xn. Starting from x0=1: 1, −2, 4, −8, 16, the sequence doubles in absolute value and changes sign at every step. It DIVERGES, even though the root, x=0, is the most natural starting point in the world. The reason is that the tangent line is vertical at 0: the curve rises too steeply for its tangent line to bring you back to the root.
d)
f′(x)=2(x−1), so xn+1=xn−2(xn−1)(xn−1)2=xn−2xn−1=2xn+1. Starting from 2: 1.5, 1.25, 1.125, 1.0625. The method does converge to 1, but the error is only HALVED at each step: the convergence has become linear, exactly like bisection. This is the systematic behaviour at a MULTIPLE root, where f and f′ vanish together.
e)
One, the tangent line is horizontal and the division is impossible. Two, the sequence cycles between two values. Three, the sequence diverges, in particular when the tangent line is vertical near the root. Four, the convergence degenerates into linear convergence at a multiple root. Protection: cap the number of iterations, check that ∣f(xn)∣ really decreases, fall back on bisection when it does not, and detect multiple roots by watching whether f′ tends to zero at the same time as f.
Exercise 5: Newton's method versus bisection: choosing the method for the problem
Neither method dominates the other. The choice depends on three things: is the derivative available, is a good starting point available, and is a guarantee required?
a) Draw up a comparison table on four criteria: guarantee of convergence, speed, information required, cost per iteration.
b) You want the root of f(x)=x3+3x−5 to within 10−10. Estimate the number of iterations of each method starting from [1,2].
c) Explain the HYBRID strategy used by numerical libraries, and why it is better than either method on its own.
d) You want to solve cosx=x. Choose a method, justify your choice, and give the solution to within 10−6.
e) Why is a numerical method still necessary when the roots of a polynomial of degree 3 have an exact formula?
Show the solution
Answers
a)Bisection safe and slow; Newton fast with no guarantee
b)34 iterations versus 5
c)Bisection, then Newton, keeping a bracket
d)0.739085
e)Cardano fragile; no formula beyond degree 4
a)
GUARANTEE: bisection always converges if the sign changes and f is continuous; Newton's method may diverge, cycle or switch roots. SPEED: linear with ratio 21 for bisection, quadratic for Newton's method. INFORMATION: bisection only needs a bracket with opposite signs; Newton's method needs f′ and a nearby starting point. COST PER ITERATION: one evaluation of f for bisection, one evaluation of f AND one of f′ for Newton's method, about twice as much.
b)
Bisection: the initial width is 1, you need 2−n≤10−10, so n≥ln210ln10≈33.2, that is 34 iterations. Newton's method from x0=1: the successive errors are about 1.5×10−1, 1.2×10−2, 8×10−5, then 3×10−9 and finally below 10−16. The fourth iterate is therefore already accurate, and the fifth iteration is the one that confirms it through the stopping criterion, since ∣x5−x4∣<10−10 while ∣x4−x3∣≈3×10−9: five iterations. Even counting two evaluations per step, Newton's method costs about ten evaluations against thirty-four.
c)
Start with a few bisection steps to bring the iterate into a safe neighbourhood of the root, then switch to Newton's method to finish. If a Newton step leaves the bracketing interval, or if ∣f∣ does not decrease, reject that step and do a bisection step instead. The result combines both advantages: you keep a bracket at all times, hence the guarantee of bisection, AND the final speed of Newton's method. This is the principle behind the methods of Brent and Dekker, found in almost every scientific library.
d)
The equation reads f(x)=cosx−x=0. The derivative f′(x)=−sinx−1 is easy to write, and f(0)=1>0 while f(1)=cos1−1≈−0.4597<0: you have both the derivative and a good bracket, so Newton's method is the right choice. From x0=1: x1=0.7503639, x2=0.7391129, x3=0.7390851. The solution is 0.739085 to within 10−6, the famous Dottie number, the only fixed point of the cosine.
e)
Because Cardano's formula, exact as it is, is unusable in practice: it involves cube roots of COMPLEX numbers even when all three roots are real, it loses accuracy through catastrophic cancellation in floating-point arithmetic, and it simply does not exist beyond degree 4, by the Abel-Ruffini theorem. Newton's method needs nothing more than the ability to evaluate f and f′, so it applies just as well to a polynomial of degree 30 as to cosx−x. In numerical computing, a general convergent method is almost always better than a fragile closed formula.
Part B: problems and reasoning (/50)
Exercise 6: The secant method: Newton's method when the derivative is missing
Sometimes you can evaluate f without having any formula for f′: a function produced by a simulation, a table, a sensor. The tangent line is then replaced by the secant line through the last two points.
a) Write the secant formula by replacing f′(xn) with the rate of change between xn−1 and xn.
b) Apply it to f(x)=x2−2 with x0=1 and x1=2, and compute x2, x3 and x4.
c) The secant method converges with order φ=21+5≈1.618 instead of 2. Why is it nonetheless often MORE efficient than Newton's method, at equal cost?
d) What essential difference separates the secant method from the false position method (regula falsi), which also uses a secant line?
e) What is the numerical danger of the secant formula when the iterates get close together?
Show the solution
Answers
a)xn+1=xn−f(xn)f(xn)−f(xn−1)xn−xn−1
b)1.33333; 1.4; 1.41463
c)One evaluation per step: φ2≈2.618>2
d)False position keeps a bracket
e)Catastrophic cancellation in the denominator
a)
Replace f′(xn) with xn−xn−1f(xn)−f(xn−1), which gives xn+1=xn−f(xn)⋅f(xn)−f(xn−1)xn−xn−1. Geometrically, you draw the line through the last two points of the curve and take its intersection with the axis. So TWO starting points are needed, against one for Newton's method.
b)
f(1)=−1 and f(2)=2. x2=2−2×2−(−1)2−1=2−32=1.3333333. Then f(x2)=−0.2222222, so x3=1.3333333−(−0.2222222)×−0.2222222−21.3333333−2=1.3333333+0.0666667=1.4. Finally f(1.4)=−0.04 and x4=1.4+0.04×−0.04+0.22222221.4−1.3333333=1.4146341. You are closing in on 2=1.4142136 without ever having differentiated.
c)
Because it costs only ONE function evaluation per iteration, against two for Newton's method, which must evaluate f and f′. For the same budget of 2n evaluations, the secant method performs 2n steps and gains a factor φ2n in the exponent, while Newton's method performs n steps and gains 2n. Since φ2≈2.618>2, the secant method is faster as soon as evaluating f′ costs about as much as evaluating f, which is the usual case.
d)
False position KEEPS a bracket: it always chooses the two points so that f has opposite signs there, so it is guaranteed, like bisection. The secant method simply keeps the last two iterates, without caring about signs: it is faster but it can diverge. It is the same trade-off between guarantee and speed as in exercise 5, at a higher level of refinement.
e)
When xn and xn−1 get close together, the denominator f(xn)−f(xn−1) is a difference of two nearly equal numbers: this is CATASTROPHIC CANCELLATION, which destroys significant digits in floating-point arithmetic. The quotient becomes noisy just when you want accuracy. In practice, the method is stopped as soon as this gap falls below a threshold, rather than iterating further on numerical noise.
Exercise 7: Fixed-point iteration: the same equation, two rewrites, two fates
Solving f(x)=0 always comes down to writing x=g(x) and iterating xn+1=g(xn). But the rewrite is not unique, and the choice decides everything: the same problem can converge or blow up depending on the form you pick.
a) Show that x3+3x−5=0 is equivalent to x=35−x3 and also to x=(5−3x)1/3.
b) The convergence criterion is ∣g′(r)∣<1 near the fixed point r≈1.15417. Test it on both rewrites.
c) Iterate the first rewrite from x0=1 for four steps and observe what happens.
d) Iterate the second one from x0=1 for four steps, and recover the spiral of the figure.
e) Show that Newton's method is a special case of fixed-point iteration, and compute g′(r) in that case. What does this explain?
Show the solution
Answers
a)x=35−x3 and x=(5−3x)1/3
b)1.332>1 and 0.751<1
c)1.333; 0.877; 1.442; 0.667: divergence
d)1.260; 1.069; 1.215; 1.106: spiral
e)g′(r)=0: quadratic convergence
a)
From x3+3x−5=0 you get 3x=5−x3, so x=35−x3. Or else x3=5−3x, so x=(5−3x)1/3. Both equations have exactly the same solutions as the original one: they are rewrites, not approximations.
b)
First: g1(x)=35−x3 gives g1′(x)=−x2, so ∣g1′(r)∣=r2≈1.3322>1. The criterion FAILS, divergence is expected. Second: g2(x)=(5−3x)1/3 gives g2′(x)=31(5−3x)−2/3×(−3)=−(5−3x)−2/3. At r: 5−3r≈1.53748, whose power 32 is about 1.33211, so ∣g2′(r)∣≈0.75069<1. The criterion is SATISFIED, convergence is expected.
c)
x1=35−1=1.333333; x2=35−2.370370=0.876543; x3=35−0.673473=1.442176; x4=35−2.999539=0.666820. The values move further and further away from the root, oscillating: the sequence DIVERGES, exactly as the criterion predicted. A rewrite that is perfectly correct algebraically can therefore be useless numerically.
d)
x1=21/3=1.259921; x2=(5−3.779763)1/3=1.068599; x3=(5−3.205797)1/3=1.215133; x4=(5−3.645399)1/3=1.106463. The iterates bracket the root and close in on it, each gap being about 0.75 times the previous one: this is the spiral of the figure, the signature of a NEGATIVE g′ with absolute value less than 1. With a positive g′ you would get a staircase instead of a spiral.
e)
Newton's method reads xn+1=g(xn) with g(x)=x−f′(x)f(x). Differentiating: g′(x)=1−f′(x)2f′(x)2−f(x)f′′(x)=f′(x)2f(x)f′′(x). At the fixed point r, f(r)=0, so g′(r)=0. This is the deep explanation of quadratic convergence: Newton's method is the choice of g that cancels not only the gap but also its DERIVATIVE, which removes the linear term of the error and leaves the quadratic term. Ordinary fixed-point methods all have g′(r)=0 and are therefore only linear.
Exercise 8: Five statements to correct
Each of the following five statements is FALSE. Say why and give the correct statement.
1) “Newton's method always converges, since the tangent line approximates the curve.”
2) “Bisection and Newton's method give the exact root after a finite number of steps.”
3) “Since Newton's method doubles the decimals, it is always better than bisection.”
4) “If xn+1 and xn differ by less than 10−8, then the error on the root is less than 10−8.”
5) “Any rewrite x=g(x) of the equation f(x)=0 gives a usable algorithm.”
Show the solution
Answers
1)Local convergence only
2)Iterative methods: a sequence
3)Multiple root: Newton's method is linear
4)Error ≈1−kk∣xn+1−xn∣
5)You need ∣g′(r)∣<1
1)
FALSE. The tangent line approximates the curve NEAR the point of tangency, and nothing guarantees that this neighbourhood contains the root. Four failures are classic: division by zero if f′(xn)=0, a cycle as on x3−2x+2 starting from 0, divergence as on x1/3 where you get xn+1=−2xn, and convergence to a root other than the one you were aiming for. Convergence is only guaranteed locally, for a starting point close enough.
2)
FALSE for both. These are ITERATIVE methods: they produce a sequence that tends to the root, they do not reach it. In exact arithmetic the sequence is infinite; in floating-point arithmetic it eventually stalls on the best representable value, which is not the same thing as being exact. The only case of a finite stop is accidental, when an iterate lands exactly on the root, which only happens with roots that are exactly representable.
3)
FALSE. Newton's method requires the derivative and a reasonable starting point, and it offers no guarantee; bisection only requires a sign change and it never misses. At a MULTIPLE root, Newton's method even degenerates into linear convergence with ratio 21, exactly the speed of bisection, while costing two evaluations per step instead of one: it is then twice as slow. The right answer is the hybrid strategy, not picking a side.
4)
FALSE in general, true only for a fast-converging method. For a LINEAR method with ratio k close to 1, the remaining error is about 1−kk∣xn+1−xn∣, which can be dozens of times larger than the observed gap: with k=0.99 the factor is 99. For Newton's method, whose convergence is quadratic, the gap between iterates is indeed a good estimate of the error, and that is a privilege of the method, not a general rule.
5)
FALSE. The rewrite must satisfy ∣g′(r)∣<1 near the fixed point, otherwise the sequence diverges. On x3+3x−5=0, the form x=35−x3 gives ∣g′(r)∣≈1.33>1 and diverges, while x=(5−3x)1/3 gives ≈0.75<1 and converges. Both rewrites are algebraically flawless: it is the derivative of g, not the algebra, that decides.
Exercise 9: Problem: how a processor computes a root
A processor only knows addition and multiplication. It has no square root key, and not even a fast division: everything else is built from Newton iterations, chosen so that they use only those two operations.
a) You want to compute a1 WITHOUT dividing. Apply Newton's method to f(x)=x1−a and show that the iteration becomes xn+1=xn(2−axn), which uses only multiplications and a subtraction.
b) Compute 31 by this method starting from x0=0.3, for three iterations.
c) Show that the relative error is squared at every step, setting en=1−axn.
d) In the same way, build the Newton iteration for the cube root of a, and compute 37 starting from x0=2, for three iterations.
e) Why does a processor prefer this approach to a table of values stored in memory?
Show the solution
Answers
a)xn+1=xn(2−axn)
b)0.33; 0.3333; 0.33333333
c)en+1=en2
d)1.9166667; 1.9129385; 1.9129312
e)Small table and accuracy doubled at every step
a)
f(x)=x1−a has derivative f′(x)=−x21. So xn+1=xn−−xn21xn1−a=xn+xn2(xn1−a)=xn+xn−axn2=xn(2−axn). The miracle is that the division in Newton's quotient has simplified away: the final formula contains only two multiplications and a subtraction, exactly what a circuit can do fast.
b)
With a=3 and x0=0.3: x1=0.3(2−0.9)=0.33; x2=0.33(2−0.99)=0.3333; x3=0.3333(2−0.9999)=0.33333333. You can literally see the number of correct 3s double on each line: 2, then 4, then 8. Three steps are enough for eight decimals.
c)
Set en=1−axn, the relative error measured against the value sought. Then en+1=1−axn+1=1−axn(2−axn)=1−2axn+a2xn2=(1−axn)2=en2. The identity is EXACT, with no neglected term: it is a perfect square, as in the Babylonian formula of exercise 3. With e0=1−0.9=0.1, you get e1=0.01, e2=10−4, e3=10−8, which the values of question b confirm digit for digit.
d)
Take f(x)=x3−a, so f′(x)=3x2 and xn+1=xn−3xn2xn3−a=3xn22xn3+a=31(2xn+xn2a). It is again a weighted average, with two weights for xn and one for xn2a. With a=7 and x0=2: x1=31(4+1.75)=1.9166667; x2=31(3.8333333+1.9054820)=1.9129385; x3=1.9129312. The exact value is 1.9129312: seven decimals in three steps.
e)
A table would give a fixed accuracy, take up memory proportional to that accuracy, and would not adapt to the different floating-point formats. The Newton iteration starts from a rough estimate read in a VERY SMALL table, often eight bits, then doubles the accuracy at every step: two iterations are enough for single precision, three for double. The memory needed therefore does not depend on the accuracy required, and the same circuit serves every format. It is the best sales pitch ever made for quadratic convergence.
Exercise 10: Problem: the internal rate of return of an investment
A perfectly ordinary financial equation, the one that decides whether an investment is worth making, has no solution by formula as soon as the project lasts more than four years. It is an everyday use of Newton's method, outside the sciences.
a) You invest 1000 dollars and receive 400 dollars a year for three years. The net present value at the rate r is V(r)=−1000+1+r400+(1+r)2400+(1+r)3400. Compute V(0) and V(0.10), and conclude about the existence of an internal rate of return.
b) Compute V′(r), then perform one iteration of Newton's method from r0=0.10.
c) Perform a second iteration and give the internal rate of return to within 10−4.
d) Show that V is strictly decreasing on (−1,+∞), and deduce that the rate is unique.
e) The bank offers a guaranteed investment at 7 percent. What do you decide, and with what reservation?
Show the solution
Answers
a)V(0)=200, V(0.10)≈−5.26
b)V′(0.10)≈−1751.25; r1≈0.096997
c)9.70%
d)V′<0: unique rate
e)NPV at 7% ≈49.7 dollars: accept, with reservations
a)
V(0)=−1000+400+400+400=200 dollars, positive. V(0.10)=−1000+400(0.909091+0.826446+0.751315)=−1000+400×2.486852=−5.26 dollars, negative. The function V is continuous on (−1,+∞) and changes sign between 0 and 0.10: the Intermediate Value Theorem guarantees that some rate makes V zero, and that is the internal rate of return. In the figure, it is the point where the curve crosses the axis.
b)
V′(r)=−400[(1+r)21+(1+r)32+(1+r)43], each term coming from differentiating (1+r)−k, which gives −k(1+r)−k−1. At r=0.10: the three bracketed terms are 0.826446, 1.502630 and 2.049040, with sum 4.378116, so V′(0.10)=−1751.25. Newton's method: r1=0.10−−1751.25−5.26=0.10−0.003003=0.096997.
c)
At r1=0.096997: V(r1)≈0.0236 dollars, already almost zero, and V′(r1)≈−1767.0. So r2=0.096997+0.0000134=0.097010. The internal rate of return is therefore 0.0970, that is 9.70 percent to within 10−4. A single iteration had already given three correct decimals: the function is very smooth, a favourable case for Newton's method.
d)
Each of the three terms (1+r)k400 is strictly decreasing on (−1,+∞), since the denominator is positive and increasing there. So their sum is too, and adding the constant −1000 changes nothing. Formally, V′(r) is a sum of three strictly negative terms, so V′<0 everywhere. A strictly decreasing function takes each value at most once: the internal rate of return is therefore UNIQUE. This is the reasoning of exercise 7 of the set on Rolle's theorem and the mean value theorem, existence then uniqueness, applied here to finance.
e)
You accept the project: its internal rate of return of 9.70 percent exceeds the guaranteed 7 percent, so the net present value at a rate of 7 percent is positive, about 49.7 dollars. An important reservation: the internal rate of return assumes that the cash flows received are REINVESTED at the same rate, an assumption that is rarely true. It also ignores the size of the project and the risk, whereas the bank investment is guaranteed. Good practice is to compare net present values at the actual discount rate rather than internal rates with one another, and Newton's computation remains useful in both cases.
Part C: the classics (/50)
Exercise 11: Newton's method versus fixed-point iteration on the equation x = e⁻ˣ
The equation x=e−x has a unique real solution r, which you want to compute in two ways.
a) Show that f(x)=x−e−x is strictly increasing and that it vanishes exactly once in [0,1].
b) Write the Newton iteration for f and compute x1 and x2 from x0=0.5, to six decimals.
c) Iterate the fixed-point scheme xn+1=e−xn from x0=0.5 for three steps. Does the sequence converge, and how?
d) Compute ∣g′(r)∣ for g(x)=e−x and explain the speed observed in c).
e) About how many fixed-point steps would it take to gain six decimals, against how many for Newton's method?
Show the solution
Answers
a)f′=1+e−x>0; root in (0,1)
b)0.566311, then 0.567143
c)0.606531; 0.545239; 0.579703: slow oscillation
d)∣g′(r)∣=r≈0.567
e)About 24 steps versus 2
a)
f′(x)=1+e−x>0: f is strictly increasing, so it vanishes at most once. f(0)=−1<0 and f(1)=1−e−1≈0.632>0: by the Intermediate Value Theorem, exactly one root in (0,1).
b)
xn+1=xn−1+e−xnxn−e−xn. From 0.5: f(0.5)≈−0.106531, f′(0.5)≈1.606531, so x1≈0.566311. Then x2≈0.567143. The exact value is r≈0.5671433: six decimals in two steps.
c)
x1=e−0.5≈0.606531; x2=e−0.606531≈0.545239; x3≈0.579703. The sequence converges by oscillating around r, the iterates falling alternately above and below, but slowly: after three steps, the error is still 0.013.
d)
g′(x)=−e−x, so ∣g′(r)∣=e−r=r≈0.567<1: linear convergence, each step multiplying the error by about −0.567. The negative sign produces the oscillation.
e)
Six decimals require dividing the error by about 106, that is n steps with 0.567n≈10−6, so n≈−ln0.5676ln10≈24 steps. Newton's method took two. Yet the fixed-point scheme needs only one exponential per step: its simplicity is paid for in time.
Exercise 12: Finding a minimum with Newton's method: solving f′(x) = 0
To locate an extremum without a formula, apply Newton's method not to f but to its derivative. Consider f(x)=x4−3x+1.
a) Show that f has a unique critical number and that it is a minimum.
b) Write the Newton iteration applied to f′, in terms of f′ and f′′.
c) Compute x1, x2 and x3 from x0=1, and compare with the exact value of the critical number.
d) Give the minimum value of f to three decimals.
e) Why would this method fail at a point where f′′ vanishes? Give such a point for f.
Show the solution
Answers
a)x=30.75: minimum
b)xn+1=xn−f′′(xn)f′(xn)
c)0.916667; 0.908632; 0.908560
d)≈−1.044
e)f′′(0)=0: division impossible
a)
f′(x)=4x3−3, zero for x3=43, that is x=30.75, unique since x↦x3 is one-to-one. f′<0 before, f′>0 after: a minimum, and an absolute one since f decreases then increases on R.
b)
You are looking for a zero of f′, whose derivative is f′′: xn+1=xn−f′′(xn)f′(xn)=xn−12xn24xn3−3. Geometrically, f is replaced by its osculating parabola and you jump to its vertex.
c)
x1=1−121≈0.916667; x2≈0.916667−10.0833330.081019≈0.908632; x3≈0.908560. Exact value: 30.75≈0.9085603. Six decimals in three steps.
d)
f(0.908560)≈0.681419−2.725680+1≈−1.044.
e)
The formula divides by f′′(xn)=12xn2, which is zero at x=0: starting from x0=0 blocks the method. At an inflection point, the approximating parabola degenerates into a line and no longer has a vertex. More generally, the method does not distinguish a minimum from a maximum: it finds a zero of f′, and it is the sign of f′′ that tells you which one.
Exercise 13: Scan, then bisect: finding all the roots of a polynomial
Before running a method, you need to know how many roots to look for and where. Consider p(x)=x3−4x+1, whose graph is shown in the figure.
a) Compute p(k) for the integers k from −3 to 3 and locate the sign changes.
b) How many real roots does p have? Justify that there are no others.
c) Perform three bisection steps on [0,1] and give the bracket obtained.
d) How many bisection iterations are needed, starting from an interval of width 1, to get a width less than 10−4?
e) The three roots are approximately −2.1149, 0.2541 and 1.8608. Check that their sum is 0 and explain why.
Show the solution
Answers
a)Sign changes in (−3,−2), (0,1), (1,2)
b)Exactly three roots
c)[0.25,0.375]
d)14 iterations
e)Coefficient of x2 is zero: the sum is zero
a)
p(−3)=−14, p(−2)=1, p(−1)=4, p(0)=1, p(1)=−2, p(2)=1, p(3)=16. Sign changes between −3 and −2, between 0 and 1, between 1 and 2.
b)
Three sign changes give at least three roots, by the Intermediate Value Theorem, and a polynomial of degree 3 has at most three: exactly three. The scan could have missed two roots close together between two integers where the sign is the same; it is the degree argument that guarantees none are left.
2−n<10−4 requires n>ln24ln10≈13.3, that is 14 iterations, whatever the polynomial.
e)
−2.1149+0.2541+1.8608=0. If p(x)=(x−r1)(x−r2)(x−r3), the coefficient of x2 is −(r1+r2+r3); it is zero in p, so the sum of the roots is zero. It is a free check on numerical results.
Exercise 14: Problem: the sag of a power line and the catenary equation
A cable hanging between two towers of the same height, 100 m apart, takes the shape y=a(coshax−1), with the origin at the lowest point. Its sag, the height of the attachment points above the lowest point, is 10 m. You must find the parameter a.
a) Show that a satisfies h(a)=a(cosha50−1)−10=0, and compute h(100) and h(150).
b) Compute h′(a).
c) Perform two iterations of Newton's method from a0=100.
d) Give a to two decimals, then the length of the cable, 2asinha50, to two decimals.
e) Why does no algebraic manipulation make it possible to isolate a?
Show the solution
Answers
a)h(100)≈2.763, h(150)≈−1.589
b)h′(a)=cosha50−1−a50sinha50
c)a1≈120.78, a2≈126.35
d)a≈126.63 m; cable of 102.62 m
e)a in front of and inside the hyperbolic cosine
a)
At the attachment points x=±50, the height is 10: a(cosha50−1)=10. h(100)≈2.763>0 and h(150)≈−1.589<0: a root between 100 and 150.
At a0=100: h′(100)=cosh0.5−1−0.5sinh0.5≈0.12763−0.26055=−0.13292. a1=100−−0.132922.7626≈120.78. Then a2≈126.35.
d)
Two more steps give a≈126.63 m, stable to two decimals. Length: 2×126.63×sinh126.6350≈102.62 m. The cable is only 2.6 percent longer than the span, for a sag of 10 m.
e)
a appears both in front of the hyperbolic cosine and in its argument: the equation mixes an exponential function of a1 with a polynomial in a. As with x=e−x, no combination of the usual functions isolates the unknown: only a numerical method gives the value.
Exercise 15: Problem: Kepler's equation and the position of a planet
On an elliptical orbit with eccentricity e, the position of a planet at time t is obtained from the eccentric anomaly E, the solution of Kepler's equation E−esinE=M, where the mean anomaly M is proportional to time. Take e=0.2 and M=1 radian.
a) Show that F(E)=E−0.2sinE−1 is strictly increasing and has only one root.
b) Write the Newton iteration and compute E1 and E2 from E0=1, to six decimals.
c) Kepler himself iterated En+1=M+esinEn. Compute three steps from E0=1 and compare.
d) Why does Kepler's iteration converge, and all the faster as the orbit is closer to a circle?
e) The distance to the Sun is r=a(1−ecosE). For a=1 astronomical unit, compute r to three decimals.
Show the solution
Answers
a)F′(E)≥0.8: a single root
b)1.188683, then 1.185325
c)1.168294; 1.184017; 1.185226
d)∣g′∣≤e=0.2
e)r≈0.925 AU
a)
F′(E)=1−0.2cosE≥0.8>0: F is strictly increasing, so it vanishes at most once. F(0)=−1<0 and F(π)=π−1>0: exactly one root.
b)
En+1=En−1−0.2cosEnEn−0.2sinEn−1. F(1)=−0.2sin1≈−0.168294 and F′(1)≈0.891939, so E1≈1.188683. Then E2≈1.185325. The next step gives 1.185324: stable.
c)
E1=1+0.2sin1≈1.168294; E2≈1.184017; E3≈1.185226. After three steps, the error is still 10−4: three decimals, against six for Newton's method in two steps.
d)
It is a fixed point of g(E)=M+esinE, with ∣g′(E)∣=e∣cosE∣≤e=0.2<1: convergence is guaranteed, and each step multiplies the error by at most e. The more circular the orbit, the smaller e and the faster the convergence. For the Earth, e≈0.017: each step gains almost two decimals, and Kepler's method was more than enough.
e)
cosE≈cos1.185324≈0.3763, so r≈1−0.2×0.3763≈0.925 astronomical units.
Something missing from this set?A type of exercise your teacher gives, a problem you are stuck on, a mistake you spotted: tell me, I read every request.
Sending goes through your free space: that is how I can answer you and tell you when the exercise is added. An email is enough, no password. Create your space.
Rather not create an account? Write to me directly.
Looking for a differential calculus tutor in Montreal?
Get in touch for a first session. We work on solving equations numerically at the level of real CEGEP tests, from the bisection method all the way to the quadratic convergence of Newton's method.