Numerical Methods

A2 · P3 · 5 min

Most equations cannot be solved exactly. Numerical methods find a root to any required accuracy: first locate it between two values by a sign change, then home in with an iteration xn+1=F(xn)x_{n + 1} = F(x_n) built from a rearrangement of the equation.

Locating a root

Key result

If ff is continuous and f(a)f(a) and f(b)f(b) have opposite signs, then f(x)=0f(x) = 0 has a root between aa and bb.

To show a root lies between 11 and 22, evaluate f(1)f(1) and f(2)f(2), state their signs, and say "change of sign, so a root lies in (1,2)(1, 2)". Graphically, a root of g(x)=h(x)g(x) = h(x) is where the two graphs cross; sketching them shows how many roots there are and roughly where.

Sign change

Show that the equation x3=5−xx^3 = 5 - x has a root between 11 and 22.

Solution

Let f(x)=x3+x−5f(x) = x^3 + x - 5. f(1)=−3<0f(1) = -3 < 0 and f(2)=5>0f(2) = 5 > 0. There is a change of sign, and ff is continuous, so a root lies between 11 and 22.

Counting roots from a sketch

By sketching y=e−xy = e^{-x} and y=x−1y = x - 1 on the same axes, show that e−x=x−1e^{-x} = x - 1 has exactly one real root, and find two consecutive integers between which it lies.

Solution

e−xe^{-x} decreases from +∞+\infty toward 00; x−1x - 1 increases without bound. They cross exactly once. With f(x)=e−x−x+1f(x) = e^{-x} - x + 1: f(1)=e−1>0f(1) = e^{-1} > 0, f(2)=e−2−1<0f(2) = e^{-2} - 1 < 0. The root lies between 11 and 22.

Iteration

Key result

Rearrange f(x)=0f(x) = 0 into the form x=F(x)x = F(x). Starting from x1x_1 near the root, compute

xn+1=F(xn).x_{n + 1} = F(x_n).

If the sequence settles to a fixed value α\alpha, then α=F(α)\alpha = F(\alpha), so α\alpha is a root of the original equation.

Method
  1. Show that the given iterative formula is a rearrangement of the equation (or derive it from the given rearrangement).
  2. Substitute x1x_1 and compute x2,x3,…x_2, x_3, \ldots using the calculator's ANS key, writing each to at least one more decimal place than required.
  3. Stop when two successive values agree to the required accuracy, and state the root to that accuracy.
Using a given iteration

Use the iterative formula xn+1=5−xn3x_{n + 1} = \sqrt[3]{5 - x_n} with x1=1.5x_1 = 1.5 to find the root of x3=5−xx^3 = 5 - x correct to 3 decimal places.

Solution

x2=3.53=1.5183x_2 = \sqrt[3]{3.5} = 1.5183, x3=3.48173=1.5156x_3 = \sqrt[3]{3.4817} = 1.5156, x4=1.5160x_4 = 1.5160, x5=1.5160x_5 = 1.5160.

The root is 1.5161.516 (3 d.p.).

Showing a formula is a rearrangement

Show that the equation ln⁡x=4−x\ln x = 4 - x can be written in the form x=4−ln⁡xx = 4 - \ln x, and use xn+1=4−ln⁡xnx_{n + 1} = 4 - \ln x_n with x1=3x_1 = 3 to find the root correct to 2 decimal places.

Solution

ln⁡x=4−x  ⟺  x=4−ln⁡x\ln x = 4 - x \iff x = 4 - \ln x directly. Iterating from x1=3x_1 = 3: x2=4−ln⁡3=2.9014x_2 = 4 - \ln 3 = 2.9014, x3=2.9348x_3 = 2.9348, x4=2.9234x_4 = 2.9234, x5=2.9273x_5 = 2.9273, x6=2.9259x_6 = 2.9259, x7=2.9264x_7 = 2.9264, x8=2.9262x_8 = 2.9262, x9=2.9263x_9 = 2.9263.

The values settle at 2.932.93 (2 d.p.).

Iteration that fails

The equation x3−3x+1=0x^3 - 3x + 1 = 0 has a root near 1.51.5. Show that the iteration xn+1=xn3−2xn+1x_{n + 1} = x_n^3 - 2x_n + 1 starting from x1=1.5x_1 = 1.5 does not converge to it.

Solution

x2=3.375−3+1=1.375x_2 = 3.375 - 3 + 1 = 1.375, x3=2.600−2.750+1=0.850x_3 = 2.600 - 2.750 + 1 = 0.850, x4=0.614−1.700+1=−0.086x_4 = 0.614 - 1.700 + 1 = -0.086, x5=−0.001+0.172+1=1.171x_5 = -0.001 + 0.172 + 1 = 1.171, x6=0.264x_6 = 0.264. The values jump around and do not settle near 1.51.5.

A different rearrangement, xn+1=3xn−13x_{n + 1} = \sqrt[3]{3x_n - 1}, gives 1.5→1.5183→1.5262→1.5296→1.5310→…→1.53211.5 \to 1.5183 \to 1.5262 \to 1.5296 \to 1.5310 \to \ldots \to 1.5321, which converges.

Why some rearrangements work

An iteration x=F(x)x = F(x) converges near a root when ∣F′(x)∣<1|F'(x)| < 1 there; the closer to 00, the faster. You are not required to know this condition, but you are expected to understand that a rearrangement can fail, and to use the one the question provides.

Watch out

Do not round intermediate values. Keep the full calculator value in ANS and only round when you report the answer. Rounding each step can make the sequence appear to converge to the wrong digits.

Exam tip

"Correct to 3 decimal places" is checked by seeing that consecutive iterates agree when rounded to 3 d.p.; write at least xnx_n to 4 d.p. so the examiner can see the agreement. When asked to "verify" the root to a given accuracy, show a sign change on ff at the two ends of the rounding interval, e.g. f(1.5155)f(1.5155) and f(1.5165)f(1.5165).

Practice

Question
  1. Show that x3−x−4=0x^3 - x - 4 = 0 has a root between 11 and 22.
  2. Show that this equation can be written as x=x+43x = \sqrt[3]{x + 4} and use the iteration with x1=1.5x_1 = 1.5 to find the root to 3 d.p.
  3. Show that 2cos⁡x=x2\cos x = x has a root in (1,1.5)(1, 1.5) and find it to 2 d.p. using xn+1=cos⁡−1(xn2)x_{n + 1} = \cos^{-1}\left(\tfrac{x_n}{2}\right) with x1=1x_1 = 1.
  4. Verify that 1.7961.796 is a root of x3−x−4=0x^3 - x - 4 = 0 correct to 3 d.p. by considering f(1.7955)f(1.7955) and f(1.7965)f(1.7965).
Answers
  1. f(1)=−4f(1) = -4, f(2)=2f(2) = 2: sign change.
  2. x2=5.53=1.7652x_2 = \sqrt[3]{5.5} = 1.7652, x3=1.7931x_3 = 1.7931, x4=1.7960x_4 = 1.7960, x5=1.7963x_5 = 1.7963, x6=1.7963x_6 = 1.7963: root 1.7961.796.
  3. f(x)=2cos⁡x−xf(x) = 2\cos x - x: f(1)=0.081>0f(1) = 0.081 > 0, f(1.5)=−1.36<0f(1.5) = -1.36 < 0. Iteration: 1→1.0472→1.0197→1.0358→1.0264→1.0319→1.0287→1.0306→1.0295→1.03011 \to 1.0472 \to 1.0197 \to 1.0358 \to 1.0264 \to 1.0319 \to 1.0287 \to 1.0306 \to 1.0295 \to 1.0301; root 1.031.03.
  4. f(1.7955)=−0.0071<0f(1.7955) = -0.0071 < 0, f(1.7965)=0.0015>0f(1.7965) = 0.0015 > 0: sign change, so the root is 1.7961.796 to 3 d.p.

How well do you know this?

Console

Search notes, courses and tools, or run an action