Ch1-3.doc
-
Upload
thasarathan-ravichandran -
Category
Documents
-
view
215 -
download
0
Transcript of Ch1-3.doc
-
8/10/2019 Ch1-3.doc
1/5
1 Chapter 1
1.3 The Secant Method
The bisection method is generally inefficient, it requires more function evaluations in
comparison with the secant method which is linear interpolation using the latest two points.Figure 1.4 shows graphically the root x3obtained from the intersection of the line BA with
thex-ais.
x 1x 2
x 3 x 4x 5
f ( x )
f ( x )1
f ( x )2
A
B
Figure 1.4 !raphical depiction of the secant method.
The intersection of the straight line with the x-ais can be obtained by using similar triangles
x3x1Aandx3x"Aor by using linear interpolation with the following points.
x x1 x3 x"f#x$ f#x1$ 0 f#x"$
1"
"3
xx
xx
=$#$#
$#%
1"
"
xfxf
xf
x3 =x"f#x"$$#$# 1"
1"
xfxf
xx
The net guess is then obtained from the straight line through two points &x", f#x"$' and &x3,f#x3$'. (n general, the guessed valued is calculated from the two previous points &xn-1, f#xn-1$'
and &xn,f#xn$' as
xn)1 =xnf#xn$$#$# 1
1
nn
nn
xfxf
xx
*
-
8/10/2019 Ch1-3.doc
2/5
-
8/10/2019 Ch1-3.doc
3/5
x 1x 2
x 3 x 4 x 5
f ( x )
f ( x )1
f ( x )2
A
B
Figure 1.5 !raphical depiction of the false-position method.
Table 1.3 __________________________________
% al#e o#ition methodf=inpt(!f(x)=!"!#!)$tol=inpt(!eo toleance =1e&5" ne' toleance=!)$if lenth(tol)==0"tol=1e&5$endx1=inpt(! i#t e##=!)$x=x1$f1=eval(f)$x2=inpt(! Second e##=!)$
x=x2$f2=eval(f)$x#ave=x2$if f1+f2.0 di#p(! al#e o#ition !) fo i=2*21 x=x2&f2+(x2&x1),(f2&f1)$ fx=eval(f)$ if fx+f10
x1=x$f1=fx$ el#e x2=x$f2=fx$
end fpintf(!i = %" x = %" fx = %-n!"i"x"fx) if ab#(x#ave&x).tol" bea/"end x#ave=x$ endel#e di#p(!eed to bac/et the oot#!)end
/
-
8/10/2019 Ch1-3.doc
4/5
1.5 The Newton-a!hson Method
TheNewton-Raphsonmethod and its modification is probably the most widely used of all
root-finding methods. 0tarting with an initial guess x1 at the root, the net guess x" is the
intersection of the tangent from the point &x1, f#x1$' to thex-ais. The net guess x3 is the
intersection of the tangent from the point &x",f#x"$' to thex-ais as shown in Figure 1.. The
process can be repeated until the desired tolerance is attained.
x 1
f ( x )f ( x )1 B
x 2x 3
Figure 1." !raphical depiction of theNewton-Raphsonmethod.
TheNewton-Raphsonmethod can be derived from the definition of a slope
f#x1$ "1
1 %$#
xx
xf
x"x1$#2
$#
1
1
xf
xf
(n general, from the point &xn,f#xn$', the net guess is calculated as
xn)1xn$#2
$#
n
n
xf
xf
The derivative or slopef#xn$ can be approimated numerically as
f#xn$ x
xfxxf nn
+ $#$#
#$a%!le 1.2
0olvef#x$ x3+ 4x"1% using the theNewton-Raphsonmethod for a root in &1, "'.
Solution
-
8/10/2019 Ch1-3.doc
5/5
From the formula xn)1xn$#2
$#
n
n
xf
xf
f#xn$ 3
nx ) 4
"
nx 1% f#xn$ 3
"
nx ) xn
xn)1xnnn
nn
xxxx3
1%4"
"3
+
+
sing the initial guess,xn 1.*,xn)1is estimated as
xn)1 1.* *.1*.13
1%*.14*.1"
"3
+
+ 1.3/33
Matlabprogram for theNewton-Raphsonmethod is listed in Table 1.4 where the functionf#x$ is an input to the program. The statement eval(f) is used to evaluate the function at a
given value ofx. The derivative is evaluated numerically usingf#xn$ x
xfxxf nn
+ $#$#
with x %.%1. sample result is given at the end of the program.
Table 1.4 __________________________________
% e'ton method 'ith nmeical deivativef=inpt(!f(x)=!"!#!)$tol=inpt(!eo toleance =1e&5" ne' toleance=!)$if lenth(tol)==0"tol=1e&5$end
x1=inpt(! i#t e##=!)$x=x1$ fx=eval(f)$fo i=1*100 if ab#(fx).tol" bea/"end x=x01$ ff=eval(f)$ fdx=(ff&fx),01$ x1=x1&fx,fdx$ x=x1$ fx=eval(f)$ fpintf(!i = %" x = %" fx = %-n!"i"x"fx)
end
f(x)=x34+x2&10eo toleance =1e&5" ne' toleance=i#t e##=15i = 1" x = 136371" fx = 0143864i = 2" x = 139531" fx = 000127861i = 3" x = 139523" fx = 937271e&009
5