Week 4: Numerical Analysis Solutions of Equations in One Variable
Week 4: Numerical Analysis Solutions of Equations in One Variable
p = (a + b)/2
MATLAB Code
function p=bisection(f,a,b,tol)
while 1
p=(a+b)/2;
if p-a<tol, break; end
if f(a)*f(p)>0
a=p;
else
b=p;
end
end
Bisection Method
Termination Criteria
Many ways to decide when to stop:
|pN − pN −1 | < ε
|pN − pN −1 |
<ε
|pN |
|f (pN )| < ε
Theorem
Suppose that f ∈ C[a, b] and f (a) · f (b) < 0. The Bisection
method generates a sequence {pn }∞n=1 approximating a zero p of f
with
b−a
|pn − p| ≤ , when n ≥ 1.
2n
Convergence Rate
The sequence {pn }∞
n=1 converges to p with rate of
convergence O(1/2n ):
1
pn = p + O .
2n
Fixed Points
g(x) = x − f (x)
g(x) = x + 3f (x)
...
Theorem
a. If g ∈ C[a, b] and g(x) ∈ [a, b] for all x ∈ [a, b], then g has a
fixed point in [a, b]
b. If, in addition, g 0 (x) exists on (a, b) and a positive constant
k < 1 exists with
Fixed-Point Iteration
For initial p0 , generate sequence {pn }∞
n=0 by pn = g(pn−1 ).
If the sequence converges to p, then
p = lim pn = lim g(pn−1 ) = g lim pn−1 = g(p).
n→∞ n→∞ n→∞
MATLAB Implementation
function p=fixedpoint(g,p0,tol)
while 1
p=g(p0);
if abs(p-p0)<tol, break; end
p0=p;
end
Convergence of Fixed-Point Iteration
Theorem Fixed-Point Theorem
Let g ∈ C[a, b] be such that g(x) ∈ [a, b], for all x in [a, b].
Suppose, in addition, that g 0 exists on (a, b) and that a constant
0 < k < 1 exists with
Corollary
If g satisfies the hypotheses above, then bounds for the error are
given by
|pn − p| ≤ k n max{p0 − a, b − p0 }
kn
|pn − p| ≤ |p1 − p0 |
1−k
Newton’s Method
(p − p0 )2 00
f (p) = f (p0 ) + (p − p0 )f 0 (p0 ) + f (ξ(p))
2
Set f (p) = 0, assume (p − p0 )2 neglibible:
f (p0 )
p ≈ p1 = p0 −
f 0 (p0 )
f (pn−1 )
pn = pn−1 −
f 0 (pn−1 )
Newton’s Method
MATLAB Implementation
function p=newton(f,df,p0,tol)
while 1
p=p0-f(p0)/df(p0);
if abs(p-p0)<tol, break; end
p0=p;
end
Newton’s Method – Convergence
f (x)
g(x) = x −
f 0 (x)
Theorem
Let f ∈ C 2 [a, b]. If p ∈ [a, b] is such that f (p) = 0 and f 0 (p) 6= 0,
then there exists a δ > 0 such that Newton’s method generates a
sequence {pn }∞ n=1 converging to p for any initial approximation
p0 ∈ [p − δ, p + δ].
Variations without Derivatives
f (pn−2 ) − f (pn−1 )
f 0 (pn−1 ) ≈
pn−2 − pn−1
to get
Definition
Suppose {pn }∞ n=0 is a sequence that converges to p, with pn 6= p
for all n. If positive constants λ and α exist with
|pn+1 − p|
lim = λ,
n→∞ |pn − p|α
then {pn }∞
n=0 converges to p of order α, with asymptotic error
constant λ.
An iterative technique pn = g(pn−1 ) is said to be of order α if the
sequence {pn }∞n=0 converges to the solution p = g(p) of order α.
Special cases
If α = 1 (and λ < 1), the sequence is linearly convergent
If α = 2, the sequence is quadratically convergent
Fixed Point Convergence
Theorem
Let g ∈ C[a, b] be such that g(x) ∈ [a, b], for all x ∈ [a, b].
Suppose g 0 is continuous on (a, b) and that 0 < k < 1 exists with
|g 0 (x)| ≤ k for all x ∈ (a, b). If g 0 (p) 6= 0, then for any number p0
in [a, b], the sequence pn = g(pn−1 ) converges only linearly to the
unique fixed point p in [a, b].
Theorem
Let p be solution of x = g(x). Suppose g 0 (p) = 0 and g 00
continuous with |g 00 (x)| < M on open interval I containing p.
Then there exists δ > 0 s.t. for p0 ∈ [p − δ, p + δ], the sequence
defined by pn = g(pn−1 ) converges at least quadratically to p, and
M
|pn+1 − p| < |pn − p|2 .
2
Newton’s Method as Fixed-Point Problem
Derivation
Seek g of the form
and g 0 (p) = 0 if and only if φ(p) = 1/f 0 (p). This gives Newton’s
method
f (pn−1 )
pn = g(pn−1 ) = pn−1 −
f 0 (pn−1 )
Multiplicity of Zeros
Definition
A solution p of f (x) = 0 is a zero of multiplicity m of f if for
x 6= p, we can write f (x) = (x − p)m q(x), where limx→p q(x) 6= 0.
Theorem
f ∈ C 1 [a, b] has a simple zero at p in (a, b) if and only if f (p) = 0,
but f 0 (p) 6= 0.
Theorem
The function f ∈ C m [a, b] has a zero of multiplicity m at point p
in (a, b) if and only if
q(x)
µ(x) = (x − p)
mq(x) + (x − p)q 0 (x)
q(p) 1
0
= 6= 0,
mq(p) + (p − p)q (p) m
f (x)f 0 (x)
g(x) = x −
[f 0 (x)]2− f (x)f 00 (x)
Aitken’s ∆2 Method
(pn+1 − p)2
p̂n = pn −
pn+2 − 2pn+1 + pn
Delta Notation
Definition
For a given sequence {pn }∞
n=0 , the forward difference ∆pn is
defined by
∆k pn = ∆(∆k−1 pn ), for k ≥ 2
(∆pn )2
p̂n = pn − , for n ≥ 0
∆2 p n
Convergence of Aitken’s ∆2 Method
Theorem
Suppose that {pn }∞
n=0 converges linearly to p and that
pn+1 − p
lim <1
n→∞ pn − p
Then {p̂n }∞ ∞
n=0 converges to p faster than {pn }n=0 in the sense that
p̂n − p
lim =0
n→∞ pn − p
Steffensen’s Method
Theorem
Suppose x = g(x) has solution p with g 0 (p) 6= 1. If exists δ > 0
s.t. g ∈ C 3 [p − δ, p + δ], then Steffensen’s method gives quadratic
convergence for p0 ∈ [p − δ, p + δ].
Steffensen’s Method
MATLAB Implementation
function p=steffensen(g,p0,tol)
while 1
p1=g(p0);
p2=g(p1);
p=p0-(p1-p0)^2/(p2-2*p1+p0);
if abs(p-p0)<tol, break; end
p0=p;
end
Zeros of Polynomials
Polynomial
A polynomial of degree n has the form P (x) = an xn + an−1 xn−1 +
· · · + a1 x + a0 with coefficients ai and an 6= 0.
Corollary
Pk
Exists unique x1 , . . . , xk and m1 , . . . , mk , with i=1 mi = n and
Corollary
P (x), Q(x) polynomials of degree at most n. If P (xi ) = Q(xi ) for
i = 1, 2, . . . , k, with k > n, then P (x) = Q(x).
Horner’s Method
bk = ak + bk+1 x0 , for k = n − 1, n − 2, . . . , 1, 0,
Computing Derivatives
Differentiation gives
MATLAB Implementation
function [y,z]=horner(a,x)
n=length(a)-1;
y=a(1);
z=a(1);
for j=2:n
y=x*y+a(j);
z=x*z+y;
end
y=x*y+a(n+1);
Deflation
Deflation
Compute approximate root x̂1 using Newton. Then
Müller’s Method
Similar to the Secant method, but parabola instead of line
Fit quadratic polynomial P (x) = a(x − p2 )2 + b(x − p2 ) + c
that passes through (p0 , f (p0 )),(p1 , f (p1 )),(p2 , f (p2 )).
Solve P (x) = 0 for p3 , choose root closest to p2 :
2c
p3 = p2 − √ .
b + sgn(b) b2 − 4ac