Week3a Handout
Week3a Handout
Spring 2025
Chapter 3. Root-finding methods
3.1 Roots of a function
Given a function f (x), a number r that satisfies
f (r ) = 0
is called a root of f (x).
• Example of finding a root:
Find a steady state solution of a differential equation describing
the activity of a population of neurons:
dx
= −x + ϕ(x + I )
dt
ϕ(x) = 1/(e x + 1)
We want to find the steady state solution, i.e., x that satisfies
dx/dt = 0 or 0 = −x + ϕ(x + I ).
Then, the problem boils down to finding the root of
f (x) = −x + ϕ(x + I ).
Condition number of finding a root
How sensitively does r (i.e., a root of f (x)) change in response to
a change in the function f (x)?
To answer this question, let’s formulate the problem of finding a
root as a map F from a function f to its root r :
F :f →r where f (r ) = 0.
Next, consider a perturbation of f (x):
f˜(x) = f (x) + ϵh(x).
Then, find a root r˜ of f˜(x):
F : f˜ → r˜ where f˜(˜
r ) = 0.
How much does the root r˜ of f˜(x) deviate from the root r of f (x)?
In other words, how large is δr in
r˜ = r + δr ?
Estimate δr by finding an approximation of its value.
0 = f˜(˜
r ) = f (r + δr ) + ϵh(r + δr )
f ′′ (r )
= f (r ) + f ′ (r )δr + (δr )2 + ...
2
+ ϵ[h(r ) + h′ (r )δr + ...]
≈ 0 + f ′ (r )δr + ϵh(r )
ϵh(r )
δr = − .
f ′ (r )
r˜ − r δr 1
Ka (r ) = = = ′ .
˜
f −f ϵh(r ) |f (r )|
Example: condition number of finding a root
Consider a function
The root of f is
f (r ) = e kr − e k = 0 → r = 1.
error ≤ |a − b|/2k
Python example of Bisection Method
3.4 Newton’s method
f (x0 )
x = x0 − (2)
f ′ (x0 )
f (xn )
lim xn+1 = lim xn − lim
n→∞ n→∞ n→∞ f ′ (xn )
f (r )
r =r−
f ′ (r )
0 = f (r )
f (xn )
xn+1 − r = xn − r −
f ′ (xn )
f (xn )
en+1 = en − ′
f (xn )
f ′′ (s)
f (xn ) = f (r + xn − r ) ≈ f (r ) + f ′ (r )(xn − r ) + (xn − r )2
2
f ′′ (s) 2 f (xn ) f ′′ (s)
f (xn ) ≈ f ′ (r )en + e → en − ′ ≈ − ′ en2
2 n f (r ) 2f (r )
Then convergence rate of the error is exponential:
f ′′ (s) 2
en+1 ≈ − e
2f ′ (r ) n
en+1 = O(en2 )
n+1
en+1 = O(e02 )
Problems with Newton’s Method I
xn2 − 2 x2 + 2
xn+1 = xn − = n (7)
2xn 2xn
√
If x0 < 0, then xn < 0 for all n, so xn converges to −
√ 2.
If x0 > 0, then xn > 0 for all n, so xn converges to 2.
Problems with Newton’s Method II
If the derivative near the root becomes infinite, then the sequence
does not converge.
p
Example; f (x) = sign(x) |x|p
Its derivative is f ′ (x) = 1/(2 |x|)
Its Newton’s algorithm is
p
sign(xn ) |xn |
xn+1 = xn − p = −xn
1/(2 |xn |)
Then, the sequence alternates between x0 and −x0 and does not
converge.
3.5 Secant Method (Modified Newton’s Method)
The derivative in f ′ in Newton’s Method can be replaced by the
forward difference approximation:
f (xn ) − f (xn−1 )
(8)
xn − xn−1
Then we get the Secant Method;
f (xn )
xn+1 = xn − f (x )−f (x ) (9)
n n−1
xn −xn−1
Python example of Secant Method