Exercise

Unit 2, questions to solve on paper: nonlinear equations

Ten questions in three groups (concepts, short hand calculations, transfer to a new situation) on bisection, Newton, fixed-point iteration, inverse quadratic interpolation and the cost of root-finding methods, written to be solved on paper without the simulators.

Last updated:


These questions are meant to be solved on paper. Solve each one without the simulators and without running code, then open the solution and compare.
The questions cover Bisection and Regula Falsi, Newton–Raphson and the Secant Method and Fixed-Point Iteration.

Three groups: three questions on concepts, four on hand calculations and three on transfer:

  • Concepts: explain in your own words, in two or three sentences.
  • Short calculations by hand: a few lines of arithmetic.
  • Transfer: the same ideas in a situation you have not seen.

For bisection use the conventions of the course: nn counts the iterations performed, starting from [a0,b0]=[a,b][a_0,b_0]=[a,b]⁠‏; iteration nn takes [an−1,bn−1][a_{n-1},b_{n-1}]⁠, computes the midpoint cnc_n and keeps the half where the sign changes, which is the new bracket [an,bn][a_n,b_n]⁠‏; εn=∣cn−an−1∣=bn−an\varepsilon_n=|c_n-a_{n-1}|=b_n-a_n⁠‏; and the method stops at the first nn with εn≤εtol\varepsilon_n\le\varepsilon_{\text{tol}} (at most the tolerance, not strictly below it).
A calculator is allowed for the arithmetic.

Group A: concepts

A1. Why does bisection always find a root once it has a bracket, while Newton’s method can fail on the same function?
Answer in two or three sentences.

Solution to A1

Bisection keeps an interval where ff changes sign, and by the intermediate value theorem a continuous function that changes sign inside an interval has a root there.
Every step halves the interval and keeps a sign change, so the root can never be lost.
Newton’s method keeps no interval: each step depends on the slope at one point, and when the slope is nearly zero, or the start is far from the root, the next point can be thrown far away or can cycle.

A2. True or false, with a reason: “If f(a) f(b)>0f(a)\,f(b)>0⁠, there is no root of ff in [a,b][a,b]⁠.”

Solution to A2

False. The condition f(a) f(b)<0f(a)\,f(b)<0 guarantees a root, but its failure guarantees nothing.
For f(x)=x2−1f(x)=x^2-1 on [−2,2][-2,2] both ends give 33⁠‏, so the product is positive, yet −1-1 and 11 are roots.
Two roots inside the interval change the sign twice, and the ends then agree.
Bisection needs a different interval.

A3. Regula falsi often needs fewer steps than bisection, yet on x10−1x^{10}-1 in [0,1.3][0,1.3] it needs more.
Explain what goes wrong.

Solution to A3

The curve is flat near 0 and very steep near the root, so the chord through the two ends keeps landing on the same side of the root.
One end of the bracket then never moves, the bracket width does not tend to 0, and each step improves the estimate only slightly.
Bisection halves the interval whatever the shape of the curve, so on such a curve it is faster.

Group B: short calculations by hand

B1. Apply bisection to f(x)=x2−3f(x)=x^2-3 on [1,2][1,2] with tolerance 0.10.1⁠‏.
Write cnc_n⁠‏, f(cn)f(c_n)⁠‏, the new bracket [an,bn][a_n,b_n] and εn\varepsilon_n for every iteration until the stop, and give the final estimate with its true error (3=1.7320508…\sqrt3=1.7320508\ldots⁠).

Hint for B1

At each step compute f(cn)f(c_n) and keep the half where the sign still changes:
if f(an−1)f(a_{n-1}) and f(cn)f(c_n) have opposite signs the root is in [an−1,cn][a_{n-1},c_n]⁠‏, otherwise in [cn,bn−1][c_n,b_{n-1}]⁠‏.

Solution to B1
nncnc_nf(cn)f(c_n)new bracket [an,bn][a_n,b_n]εn\varepsilon_n
11.5−0.75-0.75[1.5,2][1.5,2]0.5
21.750.06250.0625[1.5,1.75][1.5,1.75]0.25
31.625−0.359-0.359[1.625,1.75][1.625,1.75]0.125
41.6875−0.152-0.152[1.6875,1.75][1.6875,1.75]0.0625

The method stops at n=4n=4 (4 iterations, as N=⌈log⁡210.1⌉=⌈3.32⌉=4N=\left\lceil\log_2\frac{1}{0.1}\right\rceil=\lceil3.32\rceil=4⁠) because ε4=0.0625≤0.1\varepsilon_4=0.0625\le0.1 for the first time.
The estimate is c4=1.6875c_4=1.6875 with true error ∣1.6875−1.7320508∣=0.0446|1.6875-1.7320508|=0.0446⁠‏. The residual is ∣f(c4)∣=0.152|f(c_4)|=0.152⁠‏.

B2. Two Newton steps for the same f(x)=x2−3f(x)=x^2-3 starting at x0=2x_0=2⁠‏.
Give x1x_1 and x2x_2 with their errors, and the number of correct digits (−log⁡10-\log_{10} of the error) after each step.

Solution to B2

Here f′(x)=2xf'(x)=2x⁠‏. First step: x1=2−14=1.75x_1=2-\dfrac{1}{4}=1.75 with error 0.01790.0179⁠‏, about 1.751.75 correct digits.
Second step: x2=1.75−0.06253.5=1.7321429x_2=1.75-\dfrac{0.0625}{3.5}=1.7321429 with error 9.2×10−59.2\times10^{-5}⁠‏, about 4.044.04 correct digits.
The number of digits more than doubles in this step, as quadratic convergence predicts; compare bisection, which needed 4 steps just to reach an error of 0.040.04⁠‏.

B3. The rule g(x)=1+1xg(x)=1+\dfrac{1}{x} has the fixed point φ=1+52=1.618034…\varphi=\dfrac{1+\sqrt5}{2}=1.618034\ldots⁠‏. Start at x0=1x_0=1 and compute x1,…,x4x_1,\ldots,x_4⁠‏.
Then compute g′(φ)g'(\varphi) and say what it predicts.

Hint for B3

g′(x)=−1x2g'(x)=-\dfrac{1}{x^2}⁠‏, and φ2=φ+1\varphi^2=\varphi+1⁠‏.

Solution to B3

x1=2x_1=2⁠‏, x2=1.5x_2=1.5⁠‏, x3=1.6667x_3=1.6667⁠‏, x4=1.6x_4=1.6⁠‏. The iterates alternate around φ\varphi and the errors are 0.3820.382⁠‏, 0.1180.118⁠‏, 0.04860.0486⁠‏, 0.01800.0180⁠‏.
The derivative is g′(φ)=−1φ2=−0.382g'(\varphi)=-\dfrac{1}{\varphi^2}=-0.382⁠‏: its absolute value is below 1, so the iteration converges, linearly.
The error is multiplied by 0.3820.382 at each step (the ratios above, 0.310.31⁠‏, 0.410.41⁠‏, 0.370.37⁠‏, approach it).
The minus sign explains why the iterates alternate sides.

B4. For f(x)=x2−3f(x)=x^2-3 take the three points a=1a=1⁠‏, b=1.5b=1.5 and c=2c=2⁠‏.
Carry out one step of inverse quadratic interpolation by hand, with the formula from the formula sheet.
Give xn+1x_{n+1} as a fraction, its error with respect to 3=1.7320508…\sqrt3=1.7320508\ldots and its number of correct digits (−log⁡10-\log_{10} of the error).
Compare with the first Newton step of B2.

Hint for B4

Compute faf_a⁠‏, fbf_b and fcf_c first. The formula is a sum of three terms; in each, the point is multiplied by the product of the other two values of ff and divided by their differences.

Solution to B4

fa=−2f_a=-2⁠‏, fb=−0.75f_b=-0.75⁠‏, fc=1f_c=1⁠‏. Substitute:

xn+1=1⋅(−0.75)(1)(−1.25)(−3)+1.5⋅(−2)(1)(1.25)(−1.75)+2⋅(−2)(−0.75)(3)(1.75)=−15+4835+47=6135x_{n+1}=\frac{1\cdot(-0.75)(1)}{(-1.25)(-3)}+\frac{1.5\cdot(-2)(1)}{(1.25)(-1.75)}+\frac{2\cdot(-2)(-0.75)}{(3)(1.75)}=-\frac15+\frac{48}{35}+\frac47=\frac{61}{35}

That is 1.742857…1.742857\ldots⁠‏, and the error is 1.742857−1.732051≈1.08×10−21.742857-1.732051\approx1.08\times10^{-2}⁠‏, so −log⁡10(1.08×10−2)≈1.97-\log_{10}(1.08\times10^{-2})\approx1.97 correct digits.
The first Newton step of B2 gave 1.751.75 correct digits. This method uses only values of ff and needs no derivative:
three evaluations of ff in the first step, then one new evaluation per step, because two of the three points stay.
Newton needs ff and f′f' at every step.

Group C: transfer

C1. A trading system computes implied volatility (the volatility σ\sigma at which the model price of the option equals the market price) with Newton’s method.
For one deep out-of-the-money option the starting point σ0=0.005\sigma_0=0.005 gives a first step of about σ1=1.5\sigma_1=1.5 million.
Explain what happened and what the program should do.

Solution to C1

At σ0=0.005\sigma_0=0.005 the price hardly reacts to volatility, so the slope f′(σ)f'(\sigma) (vega: how much the price changes when the volatility changes) is tiny and the Newton step, which divides by it, is enormous.
A robust program should check that every new σ\sigma is in a sensible range (for example between 0.010.01 and 55⁠) and that ∣f∣|f| decreases from step to step.
When a check fails, it should fall back on bisection on a bracket of sensible volatilities, or use a safeguarded method such as Brent’s, and limit the number of steps.

C2. For a function where the derivative f′f' costs as much to evaluate as ff⁠, which is cheaper to reach a given accuracy, Newton’s method (order 2) or the secant method (order 1.6181.618⁠)?
Compare the growth of the number of correct digits per evaluation of ff or f′f'.

Solution to C2

Newton uses two evaluations per step and multiplies the number of correct digits by 22 per step, which is a factor of 21/2=1.4142^{1/2}=1.414 per evaluation.
The secant method uses one new evaluation per step and multiplies the digits by 1.6181.618 per step, so 1.6181.618 per evaluation.
The secant method wins when f′f' is as expensive as ff⁠.
If f′f' is almost free, for example because it reuses work done for ff⁠, Newton’s cost per step is nearly one evaluation.
Then its factor 22 per step wins.

C3. To solve x2−2=0x^2-2=0 near 2\sqrt2 you freeze the slope: xn+1=xn−f(xn)mx_{n+1}=x_n-\dfrac{f(x_n)}{m} with a constant mm⁠‏.
Find the factor by which the error is multiplied at each step for m=2.8m=2.8⁠‏, and for m=1m=1⁠‏.
What happens in each case?

Hint for C3

This is a fixed-point iteration with g(x)=x−f(x)mg(x)=x-\dfrac{f(x)}{m}⁠‏, so the factor is g′(2)=1−f′(2)mg'(\sqrt2)=1-\dfrac{f'(\sqrt2)}{m} with f′(2)=22=2.828f'(\sqrt2)=2\sqrt2=2.828⁠‏.

Solution to C3

For m=2.8m=2.8 the factor is 1−2.8282.8=−0.01021-\dfrac{2.828}{2.8}=-0.0102⁠‏: its absolute value is tiny, so the error shrinks about a hundredfold at each step.
Two correct digits are gained per step (from x0=1.5x_0=1.5 the errors are 3.5×10−33.5\times10^{-3}⁠‏, 3.1×10−53.1\times10^{-5}⁠‏, 3.2×10−73.2\times10^{-7}⁠‏).
For m=1m=1 the factor is 1−2.828=−1.831-2.828=-1.83⁠‏: its absolute value is above 1, so the error grows and the iteration runs away from the root.
The frozen slope must be close to the true slope at the root, which is why the method worked for the option in the lesson:
vega hardly changed between the start and the root.

Continue learning

Go back to Repeating a Rule or to Using the Slope for any question you could not solve.