Solving nonlinear equations · Lecture 8

Fixed-Point Iteration

Rewrite f(x) = 0 as x = g(x), then just repeat x ← g(x). It works beautifully, or explodes, depending on one number: the slope of g at the root.

Md Mahbub E Noor · Assistant Professor
CSE-3107 Numerical Methods · B.Sc. 3rd Year 1st Semester
Department of CSE, University of Barishal

Why this lecture

The problem: why does the cos button settle?

Set your calculator to radians, type 1, and press cos again and again.

  • 1 → 0.5403 → 0.8576 → 0.6543 → 0.7935 → 0.7014 → … → 0.739085, then it stops changing
  • That number solves x=cos⁡xx = \cos x, an equation with no formula
  • Now try the tan button from 1: 1.557, 74.69, −0.84, … it never settles
  • Why does one repeated function find an answer and the other does not? Today's theorem answers it
pressxx
01.000000
10.540302
20.857553
30.654290
……
360.739085
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
2 / 21

Today's goals

  • Rewrite f(x)=0f(x) = 0 in the form x=g(x)x = g(x), in several ways
  • Carry out the method of iteration by hand
  • State and use the convergence condition ∣g′(x)∣<1|g'(x)| < 1 near the root
  • Read cobweb diagrams: staircase vs spiral, convergence vs divergence
  • Explain linear convergence and estimate the number of iterations
  • Know its best and worst cases, and which methods remove its limitations
Last time

Bracketing methods (bisection, false position) trap the root and never lose it.


Today

The first open method: one starting point, no bracket, very simple; it may converge or diverge.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
3 / 21
Start here

The idea in one picture

xy0.739y = xy = cos xstart x₀x = cos x here
We want the x where the curve y = cos x meets the line y = x.Pick a starting value x₀.Go up to the curve: that height is cos x₀.Go across to the line y = x: this turns the height into the next x.Up (or down) to the curve again …… and across to the line again.The path winds inwards like a spiral.Every loop lands closer.Up to the curve …… across to the line.It settles at 0.739: the fixed point, where x = cos x.
In plain words
  • Rewrite the equation as x = g(x)
  • Put a guess into g; the result is the next guess
  • If g is "flat enough" near the answer, the guesses settle down
New words today
fixed point
a value that g leaves unchanged: r = g(r)
iterate
one of the successive guesses x₀, x₁, x₂, …
cobweb diagram
the up-and-across picture on the left
converges if
|g′(x)| < 1 near the root
contraction
a g that pulls any two points closer together
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
4 / 21

The idea: a fixed point of gg

Rewritef(x)=0  ⟺  x=g(x)f(x) = 0 \;\Longleftrightarrow\; x = g(x)
Iteratexn+1=g(xn),n=0,1,2,…x_{n+1} = g(x_n), \qquad n = 0, 1, 2, \dots
  • A fixed point rr satisfies r=g(r)r = g(r): gg leaves it unchanged
  • Geometrically: where y=g(x)y = g(x) meets the line y=xy = x
  • If the iterates converge to some rr and gg is continuous, then r=g(r)r = g(r), so f(r)=0f(r) = 0
  • Example: x=cos⁡xx = \cos x is already in this form; g(x)=cos⁡xg(x) = \cos x
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
5 / 21

One equation, many rearrangements: x2−4x−10=0x^2 - 4x - 10 = 0

Rearrangement x=g(x)x = g(x)howg′(x)g'(x)∣g′(r)∣|g'(r)| at r=5.7417r = 5.7417verdict
x=4x+10x = \sqrt{4x + 10}move x2x^2, take root24x+10\dfrac{2}{\sqrt{4x+10}}0.348converges
x=x2−104x = \dfrac{x^2 - 10}{4}solve for the 4x4x termx2\dfrac{x}{2}2.871diverges
x=10x−4x = \dfrac{10}{x - 4}factor x(x−4)=10x(x-4) = 10−10(x−4)2\dfrac{-10}{(x-4)^2}3.297diverges (goes to the other root)
x=4+10xx = 4 + \dfrac{10}{x}divide by xx−10x2\dfrac{-10}{x^2}0.303converges (spirals)

Roots: x=2±14x = 2 \pm \sqrt{14}, i.e. 5.7416575.741657 and −1.741657-1.741657. Every rearrangement has the same fixed points, but only some lead there.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
6 / 21

When does it converge?

Error recursion (mean value theorem)xn+1−r=g(xn)−g(r)=g′(ξn)(xn−r)x_{n+1} - r = g(x_n) - g(r) = g'(\xi_n)(x_n - r)
Convergence condition∣g′(x)∣≤L<1 near r  ⟹  ∣xn−r∣≤Ln ∣x0−r∣→0|g'(x)| \le L < 1 \text{ near } r \;\Longrightarrow\; |x_n - r| \le L^{n}\,|x_0 - r| \to 0
  • Each step multiplies the error by about g′(r)g'(r): linear convergence, rate ∣g′(r)∣|g'(r)|
  • ∣g′(r)∣>1|g'(r)| > 1: errors grow, the iteration moves away from rr
  • Smaller ∣g′(r)∣|g'(r)| = faster; g′(r)=0g'(r) = 0 is very fast (that is Newton, next lecture)
  • Sign of g′g': positive → staircase (one-sided); negative → spiral (alternating sides)
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
7 / 21
The method, step by step

The fixed-point iteration algorithm

  1. Rewrite f(x)=0f(x) = 0 as x=g(x)x = g(x) (there are many ways)
  2. Pick a gg with ∣g′(x)∣<1|g'(x)| < 1 near the root; choose a starting value x0x_0
  3. Compute xn+1=g(xn)x_{n+1} = g(x_n)
  4. Repeat until ∣xn+1−xn∣<ε|x_{n+1} - x_n| < \varepsilon; the answer is the last xx
  5. If the values grow or jump about, stop and choose a different gg

The loop is the shortest in the course. All the skill is in step 2: choosing a gg that contracts.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
8 / 21

Explore: cobweb diagrams

  • From xnx_n go up to the curve y=g(x)y = g(x), then across to y=xy = x: that is xn+1x_{n+1}
  • Try the four rearrangements of x2−4x−10=0x^2 - 4x - 10 = 0 (chips)
  • ∣g′∣<1|g'| < 1: the web closes in; ∣g′∣>1|g'| > 1: it opens out
  • Watch 4+10/x4 + 10/x spiral, 4x+10\sqrt{4x+10} climb a staircase
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
9 / 21

Problem 1: x2−4x−10=0x^2 - 4x - 10 = 0 by the iteration method

Problem 1"Find out the root of the following equation using the iteration method: x2−4x−10=0x^2 - 4x - 10 = 0."
1
Locate: f(5)=−5f(5) = -5, f(6)=2f(6) = 2: a root lies in (5,6)(5, 6). Take x0=5x_0 = 5
2
Choose g(x)=4x+10g(x) = \sqrt{4x + 10}; check ∣g′(x)∣=24x+10≤230=0.365<1|g'(x)| = \dfrac{2}{\sqrt{4x+10}} \le \dfrac{2}{\sqrt{30}} = 0.365 < 1 on [5,6][5, 6] ✓
3
Iterate: x1=30=5.477226x_1 = \sqrt{30} = 5.477226, x2=31.908904=5.648797x_2 = \sqrt{31.908904} = 5.648797, x3=5.709219x_3 = 5.709219, …
4
Continue until ∣xn+1−xn∣<0.00005|x_{n+1} - x_n| < 0.00005: x10=5.741637x_{10} = 5.741637
x≈5.7416x \approx 5.7416 (true 2+14=5.74165742 + \sqrt{14} = 5.7416574). Ten iterations: convergence is linear with rate 0.348.
nnxnx_n∣xn−xn−1∣|x_n - x_{n-1}|
05.000000—
15.4772260.477
25.6487970.172
35.7092190.0604
45.7303470.0211
55.7377160.00737
65.7402840.00257
75.7411790.000895
85.7414910.000312
95.7415990.000109
105.7416370.0000378
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
10 / 21
Classical vs numerical

Same problem, two approaches: x2−4x−10=0x^2 - 4x - 10 = 0

Algebra

Classical (exact formula)

  • Quadratic formula: x=4±16+402=2±14x = \dfrac{4 \pm \sqrt{16 + 40}}{2} = 2 \pm \sqrt{14}
  • Both roots at once: 5.7416575.741657 and −1.741657-1.741657
  • Exists for degree 2 (and, with effort, degrees 3 and 4)
vs
Algorithm

Numerical (fixed point)

  • x=4x+10x = \sqrt{4x+10} from x0=5x_0 = 5
  • 14 iterations for 10−610^{-6}: 5.7416575.741657
  • One root per run; the other root needs a different gg (10/(x−4)10/(x-4))
When the classical approach cannot work

x=cos⁡xx = \cos x and Kepler’s equation E=M+esin⁡EE = M + e\sin E

No formula gives xx or EE in closed form. Fixed-point iteration: x=0.739085x = 0.739085 (36 iterations for 6 decimals); Kepler with M=1M = 1, e=0.1e = 0.1: E=1.088598E = 1.088598 in 5.

When a closed form exists and is cheap, use it. Numerical methods are for the (much larger) set of problems without one.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
11 / 21

Linear convergence: how many iterations?

  • Errors shrink by the factor L=∣g′(r)∣L = |g'(r)| each step: en≈Lne0e_n \approx L^n e_0
  • For 4x+10\sqrt{4x+10}: measured ratios en+1/ene_{n+1}/e_n = 0.351, 0.349, 0.349, 0.348, … → g′(r)=0.3483g'(r) = 0.3483 ✓
  • Steps for tolerance ε\varepsilon: n≈ln⁡(ε/e0)ln⁡Ln \approx \dfrac{\ln(\varepsilon / e_0)}{\ln L}; here ln⁡(0.00005/0.742)ln⁡0.348≈9.1\dfrac{\ln(0.00005/0.742)}{\ln 0.348} \approx 9.1 → 10 ✓
  • Compare: x=cos⁡xx = \cos x has L=sin⁡(0.739)=0.674L = \sin(0.739) = 0.674: 36 iterations for 6 decimals
  • LL close to 1 means painfully slow; L>1L > 1 means divergence
Rule of thumb

Digits per iteration

Each iteration gains about −log⁡10L-\log_{10} L correct decimal digits.
L=0.348L = 0.348: 0.46 digits per step.
L=0.1L = 0.1: one digit per step.
Bisection (L=12L = \tfrac12): 0.3 digits per step.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
12 / 21

Fixed-point iteration in Python and C

  • A guard on ∣x∣|x| stops runaway (divergent) iterations
  • Change g to the other three rearrangements
  • Print the ratio of successive differences: it approaches g′(r)g'(r)
  • Try g(x)=cos⁡xg(x) = \cos x and g(x)=e−xg(x) = e^{-x}
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
13 / 21

Choosing gg for x3+x−1=0x^3 + x - 1 = 0 (root 0.6823)

g(x)g(x)∣g′(r)∣|g'(r)|result from x0=0.5x_0 = 0.5
1−x31 - x^31.397diverges (oscillates and grows)
11+x2\dfrac{1}{1 + x^2}0.635converges: 21 iterations to 4 dp
(1−x)1/3(1 - x)^{1/3}0.716converges, slower
Newton: x−x3+x−13x2+1x - \dfrac{x^3 + x - 1}{3x^2 + 1}0converges fast: 4 iterations

The last row is a sneak preview: choosing gg cleverly makes g′(r)=0g'(r) = 0. That choice is Newton's method (Lecture 9).

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
14 / 21
When to use it

Fixed-point iteration: method profile

Best case
  • ∣g′(r)∣|g'(r)| small: Kepler's equation E=1+0.1sin⁡EE = 1 + 0.1\sin E converges in 5 steps
  • g′(r)=0g'(r) = 0: much faster than linear (this is Newton's method, L9)
  • The problem is already in the form x=g(x)x = g(x): no derivative, one line of code
Worst case
  • ∣g′(r)∣|g'(r)| close to 1: x=cos⁡xx = \cos x needs 36 steps; Kepler with e=0.9e = 0.9 needs 11
  • ∣g′(r)∣>1|g'(r)| > 1: diverges, e.g. x=(x2−10)/4x = (x^2 - 10)/4 for the root 5.7417
  • The choice of gg is guesswork without the ∣g′∣<1|g'| < 1 test
Best suited for
  • Equilibrium problems: PageRank, Bellman value iteration, EM, Kepler's equation
  • Large linear systems (Jacobi, Gauss–Seidel are fixed-point iterations, L14)
  • Quick prototypes where a contraction gg is obvious
Avoid when
  • No rearrangement with ∣g′∣<1|g'| < 1 is known
  • High accuracy is needed quickly (linear convergence)
  • You need a guarantee from any start (use bracketing)

Rule of thumb: check ∣g′∣|g'| before iterating; the smaller it is, the fewer steps you need (about −1/log⁡10∣g′∣-1/\log_{10}|g'| steps per digit).

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
15 / 21
Comparison

Comparative analysis so far: x2−4x−10=0x^2 - 4x - 10 = 0 (root 5.741657)

MethodStartIterations for 10−610^{-6}NeedsGuaranteed?
Bisection[5,6][5, 6]20sign changeyes
False position[5,6][5, 6]5sign changeyes
Fixed point, g=4x+10g = \sqrt{4x+10}x0=5x_0 = 514a good ggonly if ∣g′∣<1|g'| < 1
Fixed point, g=(x2−10)/4g = (x^2 - 10)/4x0=5x_0 = 5diverges from 5.74a good ggno

Fixed-point iteration is not faster here than false position, and it can fail. Its value is the idea: Lecture 9 builds the best possible gg, with g′(r)=0g'(r) = 0.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
16 / 21
Roadmap

Limitations, and where we fix them

Fixed-point iteration introduced open methods and the convergence rate ∣g′(r)∣|g'(r)|. Its weaknesses point to the next lectures:

What it does well (keep this)
  • No bracket: one starting value
  • Very simple: one line per step
  • Convergence test ∣g′(r)∣<1|g'(r)| < 1 predicts the speed
  • The same idea scales to huge systems
LimitationHow it is overcomeWhere
The choice of gg is guesswork; may diverge
→
Build gg systematically from the tangent: g=x−f/f′g = x - f/f'
Lecture 9 →
Only linear convergence
→
Make g′(r)=0g'(r) = 0: quadratic convergence (Newton)
Lecture 9 →
Converges only near the root
→
Start with a few bisection steps, then switch (hybrid)
Lecture 10 →
Large linear systems
→
Jacobi and Gauss–Seidel: fixed-point iteration with matrices
Lecture 14 →
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
17 / 21
Applications

Where this method runs in the real world

Click a card: each one is literally x←g(x)x \leftarrow g(x) repeated until it stops changing.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
18 / 21
Practice

Practice problem

Problem 2"State the condition of convergence of the iteration method xn+1=g(xn)x_{n+1} = g(x_n) and explain why the choice of gg matters. Illustrate with x2−4x−10=0x^2 - 4x - 10 = 0."
How to write a complete answer
  • Condition: ∣g′(x)∣<1|g'(x)| < 1 in an interval around the root containing all iterates (sufficient)
  • Reason in one line: en+1=g′(ξ)ene_{n+1} = g'(\xi)e_n (mean value theorem)
  • Illustrate: 4x+10\sqrt{4x+10} (∣g′∣=0.35|g'| = 0.35, converges) vs (x2−10)/4(x^2-10)/4 (∣g′∣=2.87|g'| = 2.87, diverges)
  • Mention: convergence is linear; the smaller ∣g′(r)∣|g'(r)|, the faster
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
19 / 21

Checkpoint

Checkpoint · think, then discuss with your neighbourFor x=g(x)x = g(x) with g(x)=x2+23g(x) = \dfrac{x^2 + 2}{3}, does iteration converge to the root r=1r = 1?
AYes, ∣g′(1)∣=2/3<1|g'(1)| = 2/3 < 1
BNo, ∣g′(1)∣=2/3|g'(1)| = 2/3
CYes, g(1)=1g(1) = 1
DNo, ∣g′(1)∣>1|g'(1)| > 1
A. g′(x)=2x/3g'(x) = 2x/3, so ∣g′(1)∣=2/3<1|g'(1)| = 2/3 < 1: converges (staircase, since g′>0g' > 0). The other root r=2r = 2 has g′(2)=4/3>1g'(2) = 4/3 > 1: iteration moves away from it.
Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
20 / 21

Summary

Key points
  • Rewrite f(x)=0f(x) = 0 as x=g(x)x = g(x) and iterate xn+1=g(xn)x_{n+1} = g(x_n)
  • Converges if ∣g′(x)∣<1|g'(x)| < 1 near the root; diverges if ∣g′(r)∣>1|g'(r)| > 1
  • Linear convergence: error × ∣g′(r)∣|g'(r)| per step; steps ≈ ln⁡(ε/e0)/ln⁡L\ln(\varepsilon/e_0)/\ln L
  • The rearrangement decides everything; always check ∣g′∣|g'| before iterating
  • Choosing gg with g′(r)=0g'(r) = 0 gives fast convergence: Newton's method
Opening problem: solved

cos settles because near 0.739 its slope is ∣−sin⁡x∣=0.674<1|-\sin x| = 0.674 < 1 (a contraction); tan never settles because its slope sec⁡2x≥1\sec^2 x \ge 1 everywhere.

Homework
  1. Solve x=e−xx = e^{-x} by iteration from x0=0.5x_0 = 0.5 to 4 decimal places. How many iterations?
  2. Find two rearrangements of x3−2x−5=0x^3 - 2x - 5 = 0: one that converges near x=2.09x = 2.09 and one that does not. Justify with g′g'.
  3. Write a C program that reads x0x_0 and prints the iterates of g(x)=cos⁡xg(x) = \cos x until 6 decimals agree.
  4. Lab: in the cobweb tab, find a gg whose iterates oscillate between two values forever.
Next lecture

Newton–Raphson. Use the tangent line: the fastest of the classical methods, with digits doubling each step, and some spectacular failures.

Md Mahbub E Noor
Lecture 8: Fixed-Point Iteration
University of Barishal
21 / 21