Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Fixed point iteration

Example: Fixed point iteration

Solve

ex2x=0e^{-x^2} - x = 0

First rearrange

x=ex2=g(x)\begin{align} x = e^{-x^2} = g(x) \end{align}

Then, guess x0=0x_0 = 0 and set up a table:

nnxnx_ng(xn)g(x_n)
001.000
11.0000.368
20.3680.873
.........
510.6530.6528

At each iteration, g(xn)g(x_n) is used as the new xnx_n until at n=5n = 5, where xn=0.65300.6528=g(xn)x_n = 0.6530 \approx 0.6528 = g(x_n).

Note that the choice of rearranging f(x)f(x) is not unique, and some choices may be better than others. For example, convergence is only guaranteed when g(x)k<1|g'(x)| \le k < 1 for all xx in an interval around the solution. Experience will guide your choice of rearrangement.

For example, to solve

exx3=0e^x - x^3 = 0

One possible (but not obviously better) rearrangement is

ex=x3x=ln(x3)=3lnx=g(x)\begin{align} e^x &= x^3 \\ x &= \ln(x^3) = 3 \ln x = g(x) \end{align}

We can apply this concept to find roots using the following procedure, called bisection search:

Solve

ex2x=f(x)=0e^{-x^2} - x = f(x) = 0

Start with a0=0a_0 = 0 and b0=1b_0 = 1, then make a table to implement the procedure:

nnana_nbnb_nxnx_nf(an)f(a_n)f(bn)f(b_n)f(xn)f(x_n)
0010.51.0-0.6320.279
10.510.750.275-0.632-0.180
20.50.750.6250.275-0.11800.052
.....................
90.6250.6540.6530.001-0.002-0.0007

When n=0n=0, f(x0)f(x_0) > 0 so a1a_1 = x0x_0. Then, when n=1n=1, f(x1)f(x_1) < 0 so b2b_2 = x1x_1. We continue this procedure until convergence.

Newton-Raphson method

Although we cannot immediately solve the nonlinear equation f(x)=0f(x) = 0, we can first linearize it, then solve the linear problem.

f(x)f(x0)+f(x0)(xx0)=0xx0f(x0)f(x0)\begin{align} f(x) &\approx f(x_0) + f'(x_0)(x - x_0) = 0 \\ x &\approx x_0 - \frac{f(x_0)}{f'(x_0)} \end{align}

Iterating this process gives the Newton-Raphson method of root finding

Newton-Raphson method

Note that this method can converge much more rapidly than the fixed-point or bisection methods. However, it will fail if f(xn)=0f'(x_n) = 0.

Example 1: Newton-Raphson method

Solve x2=2x^2 = 2.


We can rewrite this as f(x)=x22=0f(x) = x^2-2 = 0. We will also evaluate the derivative f(x)=2xf'(x) = 2x. Let the initial guess be x0=1x_0 = 1.

nnxnx_nf(xn)f(x_n)f(xn)f'(x_n)
01.0-1.02.0
11.50.253.0
21.4176.94×1036.94 \times 10^{-3}2.833
31.414

This is close to the known value of 2\sqrt{2}!

Example 2: Newton-Raphson method

Solve ex2x=0e^{-x^2} - x = 0.


We define f(x)=ex2xf(x) = e^{-x^2} - x and calculate f(x)=2xex21f'(x) = -2x e^{-x^2} - 1. We choose an initial guess x0=0x_0 = 0.

nnxnx_nf(xn)f(x_n)f(xn)f'(x_n)
001.0-1.0
11.0-0.6321-1.736
20.63580.03164-1.849
30.6529

Note the rapid convergence compared to the methods above!

Skill builder problems

Solve

cosxx=0\cos x - x = 0

to 3 significant figures by:

Solution to Exercise 1

Rearrange as

x=cos(x)=g(x)x = \cos(x) = g(x)
nnxnx_n
00.500
10.878
20.639
30.803
40.695
50.768
60.719
70.752
80.730
90.745
100.735
110.742
120.737
130.740
140.738
150.740
160.739
170.739

Hence, x0.739x \approx 0.739.

Solution to Exercise 2
nnana_nbnb_nxnx_nf(an)f(a_n)f(bn)f(b_n)f(xn)f(x_n)
001.000.5001.00-0.4600.378
10.50010.7500.378-0.460-0.0183
20.5000.7500.6250.378-0.01830.186
30.6250.7500.6880.186-0.01830.0853
40.6880.7500.7190.0853-0.01830.0339
50.7190.7500.7340.0839-0.01830.0079
60.7340.7500. 7420.0079-0.0183-0.0052
70.7340.7420.7380.0079-0.00520.0013
80.7380.7420.7400.0013-0.0052-0.0019
90.7380.7400.7390.0013-0.0019-0.0003
100.7380.7390.7390.0013-0.00030.0005

Hence, x0.739x \approx 0.739.

Solution to Exercise 3

For

f(x)=cosxxf(x)=sinx1\begin{align} f(x) &= \cos x - x \\ f'(x) &= -\sin x - 1 \end{align}

The Newton-Raphson update is:

xn+1=xnf(xn)f(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}
nnxnx_nf(xn)f(x_n)f(xn)f'(x_n)
01.571-1.571-2.0
10.78547.829×102-7.829 \times 10^{-2}-1.7071
20.73957.549×104-7.549 \times 10^{-4}-1.674
30.73917.513×108-7.513 \times 10^{-8}-1.674
40.7391

Hence, x0.739x \approx 0.739.