Solutions of equations in one variable
October 21, 2012
Problem: Solve the following nonlinear equation f (x) ≡ π +1
2sinx 2
− x = 0, x ∈ [0, 2π]. (1)
• Fixed-point iteration or functional iteration: Given a continuous function g, choose an initial point x0and generate {xk}∞k=0 by
xk+1= g(xk), k ≥ 0.
Take g(x) = π +12sin x2.
Given x0, tolerance T OL, maximum number of iteration M . Set i = 1 and x = g(x0).
While i ≤ M and |x−x|x|0| ≥ T OL Set i = i + 1, x0= x and x = g(x0).
End While
Algorithm 1: Fixed point iteration
• Newton’s method: Starts with an initial approximation x0and generates the sequence {xn}∞n=0 defined by
xn+1= xn− f (xn) f0(xn).
Given x0, tolerance T OL, maximum number of iteration M . Set i = 1 and x = x0− f (x0)/f0(x0).
While i ≤ M and |x−x|x|0| ≥ T OL
Set i = i + 1, x0= x and x = x0− f (x0)/f0(x0).
End While
Algorithm 2: Newton’s method
1
Figure 1: Newton’s method
• Secant method: Using the approximation
f0(xn−1) ≈ f (xn−1) − f (xn−2) xn−1− xn−2
.
for f0(xn−1) in Newton’s formula gives
xn = xn−1−f (xn−1)(xn−1− xn−2) f (xn−1) − f (xn−2) .
Given x0, x1, tolerance T OL, maximum number of iteration M . Set i = 2; y0= f (x0); y1= f (x1); x = x1− y1(x1− x0)/(y1− y0).
While i ≤ M and |x−x|x|1|≥ T OL
Set i = i + 1; x0= x1; y0= y1; x1= x; y1= f (x);
x = x1− y1(x1− x0)/(y1− y0).
End While
Algorithm 3: Secant method
Home works
1. Plot the figure of the function f (x) on [0, 2π].
2. Use fixed point iteration, Newton’s method and Secant method to solve (1). In each iteration, please output the approximation x1and the relative error |x1|x−x0|
1| .
(a) Fixed point iteration: 40040112S, 498711079, 40040126S
2
Figure 2: Secant method
(b) Newton’s method: 40040114S, 498402331, 40040316S, 40140229S (c) Secant method: 40040118S, 498401052, 40040326S
3