Professional Documents
Culture Documents
Bisection Method
Newton Method
Secant Method
Fixed Point and Functional Iteration
A System of Nonlinear Equations
Other Topics with Applications
1. x3 + 3x 1 = 0
2. ex sin(x) = 0,
3. 3 + 12 sin(x) x = 0,
4 + 13 sin(2x) x = 0
4. x3 sinh(x) + 4x2 + 6x + 9 = 0
y=x3+3x1
y=exsin(x)
1
10
0.5
5
0
0
x
y=e sin(x)
x=3.1831
0.5
3
y=x +3x1
x=0.3222
10
2
1
4
y=ex1.5tan1x
3.5
y=3+0.5*sin(x)x
1
x
y=e 1.5tan x
x=0.7677
4
2
2.5
y=3+0.5sin(x)x
x=3.0472
2
Bisection Algorithm
Let f be a continuous function on [a, b] and f (a)f (b) < 0. This algorithm is to nd a
c [r, s] [a, b] such that|f (c)| < and |s r| < , where are user-specied small
numbers.
input a, b, M, ,
u f (a)
v f (b)
e ba
k0
print k, a, b, u , v
if sgn(u )=sgn(v) return
for k=1, 2 . . .,M
e e/2
e a+e
w f (c)
print k, a, b, c, f (c)
if |e| < or |w| < return
if sgn(w )=sgn(u) then
bc
vw
else
ac
uw
endif
endfor
y=e sin(x)
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
y=exsin(x)
x=3.1831
0.8
1
4
3.5
2.5
<stdio.h>
<math.h>
max_num=51;
x, y,dx=0.02;
x=-4.0; y=exp(x)-sin(x);
for(i=0; i<max_num; i++)
{
printf("%11.6f, %11.6f ",x,y);
x+=dx; y=exp(x)-sin(x);
}
}
Newtons Method
0 = f (x + h) = f (x) + hf (x) + O(h2)
xn+1 = xn
f (xn )
for n 0
f (xn )
Algorithm
input x, M
k0
y f (x)
print k, x, y
for k =1, 2,. . .,M
x x
y
f (x)
y f (x)
print k, x, y
endfor
Example
f (x) = ex 1.5 tan1 x = f (x) = ex
0
1
-7.0000000, -0.070189
-10.677096, -0.022567
-13.279167, -0.004366
-14.053656, -0.000239
-14.101110, -0.000001
-14.101270, -0.000000
-14.101270, -0.000000
1
1 + x2
Secant Method
f (x) = lim
h0
f (x + h) f (x)
h
xn+1
xn xn1
= xn f (xn )
f (xn ) f (xn1 )
Algorithm
input x, y, M,
k0
zx f (x)
zy f (y)
print k, x, zx
for k=1, 2 . . .,M
print k, y, zy,
ty-zy*(y-x) / (zy-zx)
xy
zx zy
yt
zy f (y)
endfor
f or n 1
Example
where
sinh(x) =
ex ex
2
7.000000, 41.683877
8.000000, -665.478826
7.058945, 20.798251
7.087465, 10.037673
7.114068, -0.401497
7.113045, 0.007307
7.113063, -0.000005
7.113063, 0.000000
7.113063, -0.000000
10
f (xn )
f (xn )
F (x) = x
n0
(Newton)
f (x)
f (x)
N
||x1 x0 ||
1
Example 1. F (x) = 3 + 12 sinx
Example 2. F (x) = 4 + 13 sin(2x)
11
(pn+1 pn )2
(pn )2
or qn = pn
,
pn+2 2pn+1 + pn
2 pn
n
1
2
3
4
5
6
7
pn = cos( n1 )
0.54030
0.87758
0.94496
0.96891
0.98007
0.98614
0.98981
qn
0.96178
0.98213
0.98979
0.99342
0.99541
12
(pn+1 pn )2
pn+2 2pn+1 +pn
= p+
hn hn+1 h2n+1
hn+2 2hn+1 +hn
Since |pn+1 p| M|pn p| with 0 < M < 1 for large n, then n 0 with
limitn n = 0 such that
hn+1 = (M + n )hn , hn+2 = (M + n+1 )(M + n )hn .
Then
qn p =
= hn
= (pn p)
Thus
M(n+1 n ) + n+1 n n2
qn p
=
0 as n 0
pn p
(M 1)2 + M(n+1 + n ) + n+1 n 2n
13
M uller sM ethod
It attempts to overcome two problems, in particular, occurred in Newtons method,
(a) f (xn ) 0 and f (xn ) 0 for some steps.
(b) unable to nd a complex root if starting with a real initial number.
Given 3 initial approximations p0 , p1 , p2 for a solution of f (x) = 0. Consider a
quadratic polynomial passing through [p0 , f (p0 )], [p1 , f (p1)], [p2 , f (p2)]
f (x) = a(x p2 )2 + b(x p2 ) + c
where a, b, c are to be determined, the next approximation p3 is dened to be one of the
roots of f (x) = 0 computed by
p3 = p2
2c
b + sgn(b) b2 4ac
(the p3 closest to p2 )
where c = f (p2 )
b=
a=
14
f1 (x1 , x2 , . . . , xn ) = f1 (x) = 0
f2 (x1 , x2 , . . . , xn ) = f2 (x) = 0
(1)
fn (x1 , x2 , . . . , xn ) = fn (x) = 0
or
f(x)=0
fi (x + x) = fi (x) +
n
fi (x)
xj + O(||x||2)
x
j
j=1
(2)
or
fi (x + x) fi (x) +
n
fi (x)
xj
j=1 xj
15
(3)
ij (j ) = i
f or 1 i n
(4)
j=1
where
ij
fi (x)
and i fi (x)
xj
(5)
Once the x is solved by using(4), the next approximated solution can be updated
by
(new)
x(new) = x(old) + x or xi
(old)
= xi
+ xi , 1 i n
(6)
16
Algorithm
Given an initial guess x for a zero of f, take ntrial Newton-Raphson iterations to improve
the root. Stops if ||x||1 tolx or ||f(x)||1 tolf
17
ey
z = 3
%
% The solution is [1.1659, 1.4493, 1.4625]
%
xy - z^2 = 1
% xyz - x^2 + y^2 = 2
% e^x - e^y - z
= 3
% Newton-Raphsons method for Nrun iterations
% X=[x y z]
n=3; Nrun=50;
X=[2.0 1.0 1.0];
% initial guess
for k=1:Nrun,
F=[X(1)*X(2)-X(3)*X(3)-1;
X(1)*X(2)*X(3)-X(1)*X(1)+X(2)*X(2)-2.0;
exp(X(1))-exp(X(2))-X(3)-3.0];
A=[X(2), X(1), -2.0*X(3);
X(2)*X(3)-2.0*X(1), X(1)*X(3)+2.0*X(2), X(1)*X(2);
exp(X(1)), -exp(X(2)), -1.0];
dX=(A+0.005*eye(n))\F;
X=X-dX;
end
format short
X,F
18
x2 = C1
x1 x3
x2 x5 = C2
x1 x23
x2 x25 = C3
x1 x4
x2 x6 = C4
x1 x24
x2 x26 = C5
x1 x3 x4 x2 x5 x6 = C6
% Newton-Raphsons method with Nrun iterations to solve
% A Nonlinear System of Equations from Professor Cheng-Yan Kao at NTU
% [C1,C2,C3,C4,C5,C6]=[2 2 2 2 2 2]
% [X1,X2,X3,X4,X5,X6]=[144.6946, 142.6946, 1.0000, 1.0001, 1.0000, 1.0001];
% n=6;
% fin=fopen(dataC.txt);
% header=fgetL(fin);
% read off the header line
% C=fscanf(fin,%d,n);
% read in coefficients C1 ~ C6
% X=[5.3; 3.8; 2.2; 1.2; 1.2; 1.3];
% initial guess
%
X=[4.8; 3.3; 1.5; 1.3; 0.8; 1.2];
% initial guess
C=[2 2 2 2 2 2];
Nrun=50; format long
for k=1:Nrun,
F=[X(1)-X(2)-C(1); X(1)*X(3)-X(2)*X(5)-C(2); ...
X(1)*X(3)*X(3)-X(2)*X(5)*X(5)-C(3); X(1)*X(4)-X(2)*X(6)-C(4); ...
X(1)*X(4)*X(4)-X(2)*X(6)*X(6)-C(5); X(1)*X(3)*X(4)-X(2)*X(5)*X(6)-C(6)];
A=[1, -1, eps, eps, eps, eps; ...
X(3), -X(5), X(1), 0, -X(2), 0; ...
X(3)*X(3), -X(5)*X(5), 2*X(1)*X(3), 0, -2*X(2)*X(5), 0; ...
X(4), -X(6), 0, X(1)+eps, 0, -X(2); ...
X(4)*X(4), -X(6)*X(6), 0, 2*X(1)*X(4), 0, -2*X(2)*X(6); ...
X(3)*X(4), -X(5)*X(6), X(1)*X(4), X(1)*X(3), -X(2)*X(6), -X(2)*X(5)];
dX=(A+0.005*eye(n))\F;
X=X-dX;
end
format short
X,F
19