May RL - Hal. 1 - 23
May RL - Hal. 1 - 23
May RL - Hal. 1 - 23
o n t·e
C n ts
Pr efa ce V
iii '
··- - - - - -
J
iv
Co nt eb t, .!i
t
S.6. St&bility
~
3.7. Fi rs t or de r gystems
tio ns 47
Sy ste m s of Linear Eq ua
Ch ap te r 4. Solutio~ (.'f 47
4.1. In tro du cti on
48
ion
4.2. Ga us sia n Elimin:\t 51
on algorithm
4.3. Gaussian eliminati Si
4.4. Pa rti al pivoti11g .5~
vo t:n g
4.5. Scaled pa rti al pi 58
4.6. LU factoriza.tion 60
s
4. 7.Vector an d ma.trix no rm 61
tio n
4.8. Er ro r of ca ku la te d so lu 62
d
~9 . A pr a. ct i~ .error bo un ~
• et ho d
4.10. ·Residua.I coirecti.oa: m 66
. d
4.11. Ja co bi itera.tive m et ho 68
bi m et ho d
4.12. Convergence of th e Ja co 10
ra tiv e m et ho d
4.13. Gauss-Seidel ite 72
th e ite ra tio n
. 4.14. T~~:nination of 73
ho ds
di re ct and ite ra tiv e m et
4. 15 . C om p~ n· ·o r
n
tio ns
-C ha pt er 6. Ap pr o~ ~a .ti on of fu nt 75
S~l. Introduction· . 16
5.2. Lagra.nge form 77
difference formula.
5.3. Ne wt on 's divided 80
no m ia l
6.4. Error of the interpolatf_ng po ly
\
Bi bl io gr ap hy
ent Exercises
Answers to Se lf Assessm
11
ss
Examination Papers
r I
,.
r -
.~, ,..
•'
. ' ....
Cl1.a pte r 1
T_his co'!~e is c~ncerne_d with the use of compu ~ers to "solve~ mat}:le
lems. ~e use, an olgonthm, a. well defined sequ~n ce of opera.t1ons tha.t
matica l pr \ 1
leads to ·:·. .
.!t
· a.pproximate ipliitio n of the ]>roblem. In some cues the algorit hm ma.y give
the
..:; ··-· ·;o11,tion if enct
i.rithmetlc ls used, but· as ~omp~ ters do not use· exact arithm · ·) m
r. ·••
if we a.re only concer ned with the real roots, then we could use the·following algorith1L
· The soluti~ ns giv~n by this algorithm. wh~~ ~oded° in QBasic ~~d Turbo Pascal and the- . .
a
exa.ct &<>l~tio_~s are given in 'Th.ble 1 for number of-quadratic equati ons. In standar
precision, which · was usecr to ,pr_o duce the results , QB'asic has about 7
d ; ~an~ -':..
decima l digll - ; ·~al
accuracy and Turbo Pascal. h~ about 11 decimal digit accur~ y; A box
has been .. ·. ;~
_r-;{ t··
t~ 1 ,._, ;
: . ,·
2 :r 2 +b x. .-, lO 0
O
of nu mo ric ru wl ut io n• of
TABLE 1. A comp a.r ison dr a.r n a.roun d th e dtg t t.8 th
at
h :l.!i be en
wi t~ t.he tx ac t solu tio n. A
bo x
are mcorrcct. -
-
Ex ac t
..,- ''J'u rb o P a..1c.a.l
b QBasic -
·2 _5219 14 77 R11? rf0 0
-
2.6 27 91 4 77 86 BE +o o
78 68 E+ oo
- 1. l 2 . 5279151': ➔ 00 - 1.9779 14 77 87 £+ 00 - L9 77 91 47
- 1.9 779 15 £+ 00 97 E+ O0 6. 2943 61 71 96 9E +O 0
6.2 94 36 l 71
89 E- 01
-1 1 6.294362E+00 - 7.94361 719,6 9E - Ol - 7.9 43 6l 71 96
- 7.943-619£ - 0l - 5. 50 90 7593228E+-0 1
6.5090759323E +0 1
.0759 3 22 64 28 E- 02
- 110 5.5 0907 6E +0 l
- 9.07593 22 6fmE--0 2 - 9
9.0 75 9fm £ 02 5.5 0009 09 0769.E+-02
5.5 00 09 09 01 6E +Cl2
5.500 09 l& t-D2 - 9 .09 0768 83 29 2E -0 3
-1 10 0 9.090 75 8'I 94 4E - 03
9.0~ 03 5.5CM 00 90 90 9 E+ 03
5.5 00 00 09 09 1E +0 3
5.5 00 00 1E + 03 -9 .09 09 07 58 82 8£ - 04
-1 10 00 04 9.0 90 90 fl~ 2l llE -0 4
9.rrn5o2 SE 5.5 00 00 0009 09 E+04
5.500000009 lE +- 04
5.5 00 00 0E +0 4 -9 .09 09 09 07 58 8E - 05
-1 1 00 00 9 .08SiOSS~S2E ~os
itOOOOO~+ oo 5. 50 00 00 00 00 9E +0 5
S, S0 00 00 00 0l E+ os
- 11 00000 5.500000E+05 -9 .0 90 90 90 90 76 E- 06
~gQQQQ53E- 06
O. OOOOaE +OO -9 .()3 6 -5 .50 00 00 00 00 0E +0 6
5.SOOOOOE+06 5.SOOOOOOOOOE+0
-9 .0 90 90 90 90 91 E- 07
-1 10 00 00 0
~.QooQO!JE+OO ~-Q~Oo~onoo@+oo
e lar ge r
in the co mp ut ed so lu tio n~ . In bo th ca se s th
t dig its se co nd
dr aw n aro un d the inc orr ec cis ion , bu t th e nu m be r of co rre ct di gi ts in
pre
ro ot ha.s be en fou nd to ma
ch ine
lin ea r te rm is} nc re as ed . Du e to th e hi gh er
eff ici en t of the di ng
ro o t dim ini sh es as the co
sc al re. su it is m or e a.. ec urate th an 'th e co rre sp on
Tu rb o Pa
pre cis ion ari thm eti c, the ·
QB as ic res ult . · e will
on g wi th th e ca lcu lat ib n of th e se co nd ro ot . W
go ing wr na tes
Ob vio us ly so me th in g is
sim ple mo di fic ati on tc, th e al go rit hm eli mi
see ho w a
see lat er wh at· this is; and
th e pr ob lem .
1. 2 C om pu ta tio na l ef
fic ie nc y
of alg or ith ms ca n be co m pa re d by
co un tin g th e nu m b er
Th e co ~p ut ati on al -effici· ency ad •h
d. . ons an d su bt ra ct io ns re qu ire d for ea<;h al go rit
lt
of mu- • pli ca t· d' · 1t1 m
. ions, 1V1S1onsra 1
t). . : . .
(1.e. hy co mp ar in g their o~ tio n co un
.
fol low ing alg or ith ms fo r ev a.l u t·m g t h e po l yn om 1a l
ex am ple , co ns ide. r the , a
I n X s, n ex po ne nt iat io ns .-
~ ,.,,-> vvwp u t_cr n~1th molt c
3' 3
SUmP'll(O)
x_po1:rer ..11111
Fox- i•1 to n
.x...po we r JI!:} x, xx; ...po~ or J
,um•aurn+-a ( i ) x x...po,:r or _i
End For
Operation count: n +'s , 2n x 's, (0 exponentiat ions).
sum•a (n) · l1
For i,•1 ton
inun•a umxx+ a(n-i)
'End For
Operation count: n +'s, n x's.
The la.st algorit hm is clearly the most efficient, a.nd ·is equiva lent to writin
g p,. (z) in
the ne•ted Iorm
· Pn (x) = (·· · ({an:i: + an-1)z + an-2)x + · · · + ai)x + ao.
1.3 Comp·u ter arith metic
We use a base 10 {decim al) numbe r system, but compu ters use binary numbe
Z) or some system based ort binary (octal (base 8) or hexadecima! (base
rs (base
16)). Just as
J
=
376.21 3 X !°0 2 + 7 X 10 1 + 6 X 10° + 2 X 10-l + 1 X 10- 2
the base b numbe r
n
(d3d2d1do,,cL 1d-2)b = d3 x b3 + d2 x b2 + d 1 x b1 + do x b0
+d-1 X b- 1 + d_2 X b- 2 •
Here do, di, .•• denote a. base b·digit, that is a.ny of 0, 1, 2, ... , b- 1. For
hexad ecima l
numbe rs A, B, C, D, E and Fare used to repres ent the digits 10,11, 12,13,
14 and 15.
JWork ed Exam ple 1_.3.1 Express (A6.D2h~ as a. decimal number.
= .~160+
.
6+
13
+~
. 16 . 256
'= .16'6 + 0.8125 +. 0.0078125
=' '166.8203°125 I
It •18 11 .
• easy convert from decim ~ to b~e ·b. Suppo se x is a. decimal intege r and
l"·•,•;•·.l tt·•,r.~- • ,; .,;"~j, .. ,.,,,;:); dlt\,;:;: 11,(d,.dn ~t ·~·· di.do) • ..,. ,,111: ·,1.~+f>·• '
...,• ., ·''"'~''': ,. ' . ') . . ;1: 1·
.
Then. dividing by· b gives ·.
. : dn x· b" + dn~I X b"~ 1 +·•· +'d1 X b1 +.do·~ b0 •
X .
- = d X bn-1 + d· .. X bn-2
.b ' n . . •. . '.+
d +:
.
do
n-!., 1., +b
integer - < : , •. .
ut ot1()
Er ro rs in Nu mcrlco.J Co mp
4 , C hn pt cr 1
. - --......~
the rem ain de r Wh
t h e . rem ain de r when x is di\(jd _ed by b. Sim ilarly d 1 is en
5
o is
~ cl_
by 6; ind so on . '
l ie integer pa rt of :r /l 1 is div id ed
cim al fra ction (0 < x < 1)
Now :s uppose th a t x is t he de
:t (.d _1d-2 . .. )b
d_l X b- 1 + d_2 X ~-
2 + ·· •
Mu ltip lyi ng by b gives
bx = d_1
........_., + d_2 x b-
1
+. · · ·
. ~n teger fraction
multiplic ati on by b givei!I d- 2
, ~ - 3, • • •
eg er pa rt of bx . Re pea tec:l
so d-1 is the int
Th us 25 = (11001)2.
nverted :
Th e fra cti on al pa rt is now co
0.59375
int eg er pa rt ..- .
x2
1 = ·d:..1 ·
[IJ .18 75 0
x2
@ 37 50 0
X2 ·
O = d-a ··
@].75000
x2
[].soooo 1 = d_ 4
X2
1 = d- s
[Dooooo
es
0.59375 = (.100011)2, an d combining the two res ult s giv
Therefore - .
25.59375 = (11001.10011)2 I
s 1. 3 .-
; _. Se lf As•se ss m en t Ex er ci se .
·riu_mbers: (a) (11 01 0L ll0 1)2 ,
1;
point form
1.4. Float ing
AnY base b numbe r z can be put into the form, with d1 -:/= 0,
. bEf--e xpone nt
x
.
=
s1gn(x ) .d 1 d 2 d3 ... X
-.:...... ..:,..
mantis sa.
se only P
The number of digits .tha.t -:a.n be stored in a. compu ter is limite d. Suppo
_the
digfts can be . used for. the mantis sa. If the numbe r Qf digits .~ larger than P,
If the manti ssa
ma.ntissa. must be ckop~ d (trunc ated) or rounde d back to p d1g1ts.
on of is
h·~ fewer than p digits it is filled with O's. The· floatin g-poin t repres entati
:c
FIGUR E 1.1. The positive bin.a ry numbe rs with three digit mantissas
a.nd ~ne~ ~-·l,O or 1.
ing is used
If r~u~ding is used, fl(z) is the closes t machi ne numbe~ to :c, but if chopp
fl(z) JS t~e next I?achi.n~ n~m_ber in the directi on of O (see ]?igur e
1.2). In both
errors are also
~ the error of convera1oil 1B called the round -off error. Roun d-off
mcurr ed wheaevel'. fl.oa.tjn"g point numbe rs a.re used in a. calcul ation.
JE
1 .1zr .
'
~cCu;rd (the ~_
verl . ou, occurs a.nd"progra.m· .generally "bbmb ,, h a.s itude larger than L
resu t . s w en an attem pt is made to use the .
,.,,
T he va.lues of 6, P~ M.1 , ·u.12, ·
type of conv . ( .
handl ing of
underflow a.n.d overff,ow are all comp ilere:; :n::~n a~o-g -or chopp i_n_g) and
. or exam ple, tlie IEEE stand ard
· '-'Aa.p c.er J.
fo r sin gle precisio n rcl\ls is 32 bit ( 1 byt~) words with b = 2, p er 24, M, = -12G '-l\
=
M2 127 .
1. 5 E rrors
h ,,
\t is ofte n imp ossib le 0 1 impra.c tical to fi nd tli i>1 e~~t solu tion t o a ma l en~a ti,
pro blem . For exa mpl e, it 1s impossi ble to find fo er' . dx exa-ct ly, ao<l improctieat
l,
Usually we will not be able to calcula te the error because the exact value
is not known,
an
b ut wi ll only be able to show that IErrorj .$ A for s ome ·numbe r A which is called
error bot.nd. A relati"ve e.rror bound is defined similarly.
Tl1e approx imate value xA has m signific ant digits with respect to XT if the (m+
l)th
digit of the error xr - xA, countin g rom t e first non-zer o digit of XT, is < 5 and the
previou s digits are aLJ zero (the maxim um value. of m is underst o.o d).
✓ I Worke d Examp le 1.5.1 Calcula.te the error, relati~e error and number
of signific ant digits of 125/46 as an approxidJJtion toe. . ·
Error - xr - x A. ....
o,g -.::>(c:JJ u1 o~ 0).2.
_ 12s·
e (O,fll 010),2.
-
-
·0.00089 ./
46
.. .
; 1·,. l. t 1 + .L
"' 1 i . 32
· Error
Rel. Error -
XT :: 0,906215
o,0° 6ir .
0.00089
' e
error 1,:=/ ' o, 0-
.· ' •,, .. . , •. , , ,. ·~-P .,· ,; 11•r I
, ' ·•, 1": ..°"'
.·'· ···= '. 0.00033 ✓:
·: ~,09 3·
xy - 2.71/8281..
._;' o, 0061 [
E;rror 0.00/089
. . · § f. 7. Lo.s s of si.gniflc.a ncc crro r u 7
. rcis es 1.5
Self Ass essm ent Exe
ifica nt digit s of 1.73 as an
l. Find the error, relative error and number of sign
a.pproximatlon "8. · of digi ts of 9.87 as an
2. Find the error. rela.~ive erro r and num ber
of sign ific~ nt
2
a.pproximation of ,r •
.
a.lgo~lthm
--
S~m'e of tliese erro rs ·a.re una.voida.ble; the a.im
s ·tha. t mln~mlze their effect.
of num erica l anal ysis is to design
almo st equal value a.re subt racte d sign ifica nt digit s are Jost.
Whenever ·two· numbers o(
For example, : ·.
13.13519
.--:-13.13621
-~ z .1i,
lost slgnificant digits
. ', j
-b ± ✓fil - 4ac
~= 2a-
11
Jb 2
-- 4ac ~ /b/
- · C_bap~er 1
8
and so on.e of the roots will suffer from loss of significance. This is overcome by t~~... ·
-b - sign(b)Jb 2 - 4ac
XJ = 2a
(there will be no loss of significance), and using th~ fact that ax1x2 = c to ca1c~11
C
Xz=-.
ax 1
When the programs that were used to generate tl:ie results tabulated on page 2 w\
modified in this way 1 all digits of both solutions were correct for all of the qua.dr~
eq ua.tio ns_
(vx + 1- ✓x - x ,/xTI + ✓x -
1
J(x) - 1)
✓x + 1 + ✓x-1
(x + 1) - (x - 1)
✓x+l+Jx-=-I
2
=
We have seen that a small error, called a round-off error, is usually incurred wbe
ever a number is input into the comp~ter or an arithmetic operation is perforlll,
These errors ca~ not Q,e'· a.voidecl-, .~ut they -can be reduced by us\ng_.higher prea'
arithmetic. · ·
T he effect of round-off error~ can· often be reduced by careful design of the algorit~
As an example, consider the situation where Xi = a+ ih, i = 0, 1, ... , n is used
a calc ulation inside a loop _ The value of xi can be 11calculated in the following wa.J'
11
0
., ,, § 1.9 . E~,r.ror pro pag nti on
..... .
x•a
Fo r 1 • 0 t:o n
Fo r i .. O· to n
x• a+ i•h
x-=x+,h i
Erid for ~
End Fo r ', '
or
rat io ns as, for
of req uir ing fewer ari thm etic ope
!
t me tho d has the adv ant age
The firs sec ond metho<:I.
i, onl y one + is nee ded rat her tha.n the one + and one x for the rou nd-
eac h
sec ond m~ tho d giv es a. mo re acc ura te res ult bec aus e onl y two
However, the nd- off err ors are
erro rs a.re mc utr ed in t·h e calc ula.tion of eac h Xi, while i - 1 rou
off ·
Xi in the firs t me tho d.
accumula..ted in the cal cul atio n of
low . For exa mp le,
etim es a ca.l cula .tio n can be mo difi ed to avo id ove rflo w or und erf
Som z
= v~ ◄ + y◄ ma y cau se ove rflo w for larg e X and y eve n tho ugh
the cal cul atio n of z d by wri ting
ber . Th is ove rflo w can be avo ide
lssmaller tha n the lar ges t pos sib le num
4 lxl ~ IYI
z ={ x {11 + (y/ z) .
C h a p te r 2
I
,.·
ti o n · o f N o n li n e a r E q u a ti o n s
S o lu
1,
2.1 In tro du ct io n 1,
the so lut ion of a no nl in ~ eq ua tio n f(x
) =
0. W h ile
ern ed wi th
Th is ch ap ter is co nc no t.
n be so lve d ex ac tly , mo st can
so me no nli ne ar eq ua tio ns ca. the
f(r ) 0 the n =
we s~ y r is a. root .~r so lut ion of
tha .t =
~ a.nd f '(r ) :f; 0
If r is a. real nW llb er &uch e fuu~ ~~ ff:.~ f(r:_)
equ a.t ion /(z ) = · O. t\Vealso cal l r a zer o of th·
·
the n r is a. aim
_____ ple root (se
_ _ . ; . __ _ e Fig ure 2.1 ).
____
_ _.J'
,_/
7 . r1, odd X
m>
r
1, ev en
m _-;;/
,,
. lti pli cit y m > 1.
FIGURE 2.2 . Ro ot. s r of mu '
I
11
l.
I t l • I ' ,
( ' li n p( ,•r ? ' i n )11f Int i ()f Not1 llnrl) r Er11J n tl, J,, .
11 2
I \ ,\ !nd<..-<l 1: :xt\ltt pl r :· J I J ),, trun1 11r th r AJ>flrr,,-i m at,o v ... Ju r. ~ ofth 11 rr,,,,.
(l[ a' '.l ... , . 4
'f l"\<'t'q U l.l ·l<"I O( k h l)('Wl l ltrn , , e' -1 :- 2 ao Wfl 1kctch th e fun ctfionn
h
v 11: , ,
'
I
r<l 1n1.to ot e pn!1 "4
and v c 4 :1 'o n th tiaft 1J)l'l\XC \ 1tnrl r.-t t lma t 1J th r z;r.oo
n [ in l CNC"< ti nt\
Se Jf A ss e ss me nt Exer cise s 2 .1
ate value of the roots of
1. Using a sketch deter mine the nu1nber and appr oxim
1
cos X - X + l = o. =
of e-~ + cos z
2. Dete rm ine the appr oxim ate value of all of the roots
0.
-
2.2 Bise ctio n met hod
opposite sign (/(a) /(b) < 0)
If J(x) is cont inuo us on {a, b] and /(a) and f(b) have
is 6~ly one root in the interval,
t hen there is at least one root r E (a , b). Supp ose there
'· !. 1 .. inter val is halve d , the subin terva
l whic h conta in~ the root can be determined,
.. ; r. -. is proce ss conti nued until
the root ls know n _to aµfficient a.ccura.cy. In Figure
val by (a 1 , b1 ) and so on,
·1rigioal interval is deno ted by (ao, bo), the next inter
-- . .- . j - -- - -
C 1,
ILJ //
/
f1GU HE t.J .
tion meth od.
An illustration of the bisec':·. ' .
Suppose that we know that the root lies in the interVcµ (a,
b) We calculate c == (a+b)/Z
E (c,b) so a is replaced,.bY I
.(the midpoint of the inter val), and if f(b)J(c) < ·O·th en;r
now have an inter val w hie:_ is hali _a$
,. c; other wise r E (a, ") so b is re place d by c. We
. '- J
11
§ 2 , 2 , B is c c.t fo.n motho<'1
a C b
I
FJ GU.R.E2 .4 . At any stag e of the bisection met hod
tween r a.nd c mus t be $ b - c.
the dist ance be-
I
.j
i
e gives:
Let / (~) = z - l - e-%.· Putt ing the resu lts in a tabl
a b C /(b) J(c~ f(b) f(c) acti on
1 1.4 1.2 · +0.15 -0.1 0 <O a= c
1.2 1.4. 1.3 +0.1 5 +0.0 27 >0 b = c, f(b) = f(c)
1.2 1.3 1.25 ·. +0.0 27 - 0.037 <0 a= c
1.25 1.3 l .27~ +0.027 - 0.0044 <0 a= c
1.275 1.3 1.2875
1 . I NPt..rf a b o od t ol or anco £
2 . Cal c u la~ ~ s fb • f (b)/l f (b) I 1
so clearly
(bo - a 0 )
> f ;t
-~ n
Note tf1n.t t Ilie num b er o f ·iterat iow·;:) is .in d epen d cnt of the functi on .
15
§ z.3 F.~ ep. PP.f Pt it~ rat ion .
log ( / : ;,: , )
- log 2 . - l
~ 12. 29
ure 4 decimal place acc ura cy. I
At least 13 iter ati9 ns are needed to ens
~ er. ~ ~~-o ~ Z
_ n+1 by en+ l = r - Zn+
•.. ., . , ~,e_n ~t~ -~-~ ·· J.t , . • ~ '.' ~"'1 ··.· ·•·ht., ~Y<l ·~ . .,, . -~•-~•1•• •Jfl ,•J•·.=1,•·-,riie: •[1,t _•i ~ ·. J: · ~,<!•~ . .. .•. ·: · •·J . , _..,
1
_
I
1
<' . t "· 1 !• ,
g(r) - g(znr
• • .'
-en+ l -
r and x · ·
- ·g'(~n)(r - ~n.) M-ea.n Val ue The ore m, {n bet wee n "
- g'({n)en.
•
.11
-
Ch'apter· 2
y == g(z )
g(xo) = x1
r Xo X
.. ;
FIGU RE 2.5. An exam ple of a conv ergen t fixed ·poin t iteta tion Xn+i = g_(xn),
y=x
I,
x2 xq r
FIGU RE 2.6 . An exam ple of a diver gent itera tion Xn+l = g(xn)•
17
. § z.s Fi xe d ip oi nt ite ra tio n
if leo/ < o.
➔ r as
1, /(" + /cof -t O as n ➔ oo,
1 so ''"+d ➔ 0 and therefore Xn +I
Now if K <
L
r + o)
ges to r for an y zo E (r - o,
,i.- +O O,
.-
Th us the _~xe<!-·po int ite rat ion .rn +l g(z n) =
con ver
all er, the va lue of K the
< a.JI z E (,. - 6, r -f 6). No te 'th ~t the sm will no t
lf }g '(:) i ~ _[< 1 for
o be sho wn t.h at the fixed po int ite rat ion
ce. It can als
fas ter the ~onverge.~ ·
converge i(f g'( r)/ > 1. •
eq ua tio n
Ex am pl e 2.3 .1 Tw o rea rra ng em en ts of the l
I W or ke d a.resin e- 1:. De ter mi ne if the
= fixed I
es 2.3 •k
Se lf As se ss me nt Ex er cis ' ..,.,.,. . " . ' •' •" ', · " .. J
. ' ' '' .. , ' :•,. ,,.,..
I • •, , ,.
. .
so s1mp le. it e ra ti o n c o n v e r ges li n e a rl y 'if O < lg' (r ) I < 1 . ( lf g
'( ) O th e o rd e r
c o n v e rg e n c e ·u b e 2 o r g re a r - 0
1
w1 te r. ) •
The . . th d
b is e c ti o n m O
.
'o r m o re p it s e rr o r b o u . )
J( == ½·
e ' re c 1 se \y n d c o n v e rg. e s li n e a rl y witb
T e rr n 1. n a t'io o
n f th e it e r a ti o n
W e w o u ld li • ·.
ke to st t' w .
\r - :&n l -< E (O r so mo ep pthreese1tt\ebrad1otnO\ haennc ex : 1s0 -ns u ffic·1·' e n t\ y d o s e to r , th a t . hen ·
is to s to p w < e er e c ri te ri o n l.S w
h e n \!(x b t th is d · th a t is u s e •
se e n fr o m th nd )~ o e s n d so m e tt m
e e a rh e r ia - l, . u A n o th e r c ri teo t e n s u re th a t \r - \ < ~
a.s c a n 111. •
jX n +1 - X n < · g;rarns. ri o n th a t is :r n -
I - €. T h 15 a.. 5 0 d o e s n o t always e
. 1 . o ft e n u s e d £
n s u re t h a.t . \ is to s to p w
F o r si m p le it r - X
\ < ~ het
e ra ti o n :
n _ -·
·,
g '( r) .•
' .
_ g'(r) (: tn + l
- :Z:n)
s o if g '( r) is
close to 1 th
·e v e r, g '( r ) e n Ir - X n +
m a y be· a p p l \ w il l b e
ro x im a te d b y K I m u c h la rg
te rm in a te d
w h e n jK '( x
n + l ~_.xn)/(1
= (x n'+ l - X n )/ ' e r th q .n \x n + l - x~\-
(x n - X n -l ) n~~o'
T h e s e p o in
ts a re il lu s
-:- K ') I < L a n d th e 1• te t\ '
tr a ~ e d b y th ra.
re s u lt s s h o w e it e ra ti o n
n in. T a b le
T h e slow c o
n v e rg e n c e is
1. T h e it e
ra te s a re c
Xn+l
0.4 + 0.6x~ 5
· w
= hl" ·.
o n v e rg in g slow h ic h
very,mµ.ch _sD?, to b e e x p e c
te d since g '( ly t o t h e r g a v e t \
·a p p ro a c h e s _a Uer th a n th
th is v a lu e th ~. e rr o r ~n ~ n •· N o te .t h
l) 0 .9 . T h e v a lu
e o f
= o o t r ~ '¢
e e r r o r e s ti m at Z n - :r" ...
No m a tt e r w a te (l a s t c o lu K ' -is _tending to g '{ l) i 11
h a t c ri te ri o n m n )- a p p ro a , ~d ~ -
c h e s th e a c
.i o u s s h o u ld
ue limiLed. in cais..sue sed to te r m in a te a n ·i te r a ti o n tu a l er t 0 ~
,
tc . o f p ro g ra m , th e to ta l n u m b
e r r o r s lo w e r o f itet ,
I d iv e rg e n c e J fli~
to o s m a U a
to lera.
,· 12 _4 · ·-Ne wt on ~• 'm eth od ·
K'
n ,s:" Er ror X-n - a::,. _ l I<' l _ K' ,{~n - -Zn_ i)
0 1.100000
1 1.09.2214 - 0.092214 - 0.0 077 86
0.9 422 56 - 0 . 119716
2 1.0 848 77 -0 .0~-4877 - 0.0 073 37
0.9 390 00 - 0 .106046
s 1.0 779 88 -0. 07 79 88 - 0.0 068 89
-0. 04 14 06 - 0 .00 408 7 0 .92 122 0 - 0 .04 779 3
10 1.0 414 06
0.9 080 72
-o; 0l6 46 7 - 0 .00 164 6 - 0 :016255
20 1.015467
0·0 505 0.9 029 08 - 0 .00 562 8
-SO 1.0 055 82 - 0 .005582 - o.0
02 15 0.9 010 26 . -0. 00 19 58
40 1.0 019 46 -0. 00 19 46 -0. 00
00 76 0.9 003 59 -0. 00 06 82
50 l.0 006 81 -0. '00 06 81 -0. 00
00 26 0.9 001 25 -0. 00 02 38
60 1.000238 -0. 00 02 38 -0. 00 i _=
'11 ~ , \I
Ta ng ent ,
slope = /'(~o)
v x0 X
··
.t111..Jt,, ·,,,. ·· ·. •,, •'"'·11!•1;,••tr -1;:•, -i· '" . •_:. ·
.._.,,, ., ~.,. 1 . ,,·.\ ·;_:···· •fli'• ',1 .,..,,, 10• .•1• • · .
· · .'• I· _•,~\11 : ·. ,1'
wt on '~ me tho d the fun cti on is ap pro xim ate d by its tan ge nt.
FIG UR E .2. 7. In · ~e
1 .2777703 _ f (1.2777703)
- I f'(l.2777703)
- 1.2777703 - -0.0008877
1.2786579
- 1.2784645
T hus · r ~ 1.278465 I '
Rate of convergence
Taylor 1s theorem gives
(For a tnU
; roo t J' (rj == 0 and .the convergence is linear.) .,.
/
If so) s:1 ' s-, , .. . an d01Jo to.-,
r - « ., ➔ a ,\,. K( r - rr," ),
2
K (r - l' n-t-1) ~ ~ !K (r - :,;" )]
2
~ { /( fJ(( ,. - It n - t)] 2 ) {/(( r
~ (K (r - :: o)]l" 'i • .
hen ce z" ➔ r . Thu s New ton 's
If K (r - : 0 ) < 1 t hen a.s n ➔ oo K( r - x"+J ) -+ 0 a nd
meth od converges If ~o is ~ osen ao th at
prov ided Zn is clooe to r a.nd f'(r) #- 0. But , rearr angi ng the form ula for New ton' s
meth od,
'' f(xn )
- f'(xn )
- .:tn+ l - Xn
~ r - :Z:n
- Xn+ l -
New
I
ton's meth od algo rithm
of
1 . IIPU T xO, tole ranc e ~S, . maximum .nwn ber
iter atio ns MAX
2. For i•1 t~ MAX do,_3_. to l·
3. x1cxO~f( ~O) /fda sh xO)
4. If abs x1-x Ot< ~S OUTPUT "Soluti"on·-1s -:tl" a
-..._. "1'~ et()t' ~ LO.ttt" t / · .
~
stop .
.1
6••• . xO•x 1 • · ' · - • ·• • -t• -'ttJ~•· , .. •. ••u · ,·· · · 1·
1 · •} : ' ,: ,_. .. , ,t • "• J / •\,
..
6 . OUTPµT ''Method hasu ' t :c:;.onver ged - curr ent
.· es~i !'l~t e is x1"; stop ·
- 0.272
- 1. 2 - 4.32
_ 1.2629630
.
Since Ix 1 - xo -
I _ o·0629630 > 10- 4 we calculate
.
the -n ext iterate:
J(x1)
X2 - X1 - f'(xi)
~ /(1.2629630)
- 1.2029630 - /'(1.2629630)
0.0145212 ,,
629630
l.'.2 - 4.7852263 ·
= 1.2599284 ;~
ft Now !x 2 - x 11 = 0.0030346 > 10-4 so vie again calculate the next iterate:
.
i X3 - X2 -
f(x2)
f'(x_2)
L -
. , /(1.2599284)
1.2599284 - /'{1.2599284)
1.2599284 _ 0.0000349 ·
- 4.7622585
- 1.2599211
Now fx3 - x2/ = 0.0000073 < 10-4 so we stop and accept· the approximation
r ~ 1.2599211 .
=
We know the·solution .is ~ 1.25~92104989 .. , so the error in our approxi-
mation is about -5 x 10-s which is much SJ;Jlaller than the given tolerance.
This error is essentially due to the number of digits used in the calculation;
using more digits-shows thit .the error in -~s .is appr~ma.tely 4~3 x .10~-~.t
The error in x 2 is, to the accuracy of the calculated results, equal to x 3 - x2
a.s predicted. I
d.
nc ti on is p
a_ pr ox im a. te d by a ch or
th e fu
FI G U RE 2. 8. 1n
th e se b. ri t m et ho d .
. .
e ch or d gi ve s
tw o ex pr ~i on s_ f<;>r_th e sl op e of th
Eq ua .ti ng - /( z i)
l( zo ) - /(~1) _ o - ,
Z2 - Z1
Zo - Z1
e ob ta in
an d solving for z2 w
·. · /( z1 )( z1 - zo)
) •
Z2 ~, %1 - .( zo
/ (z1 ) - ./
..
an d Z2 an d so on ,
is ca le ul a. te d in th e aa m_e wa.y fr om :CJ f
T he ~ext
& pp r6 ~ at io n- ~3
et ho d e& :n be w rit te n as .. ·
·
so th at the secant m ----·-nznITzn'- Z n -1) r
-~ ·: - l' . - -- · - n 1, 2, ~ .• =
=
-. . .
-- - - - . · ·--- . ) /(; ,.· ..•
Zn ~- /( o( ,n -1
Z n+ l , Zn -
· . ·
d. .
C on ve rg en ce
.
t,:~ n v ~ g e fo r so me choices of ~o an
ma,y.. no e ro ot
r ao~e., proble,ID$, .th ~ se ca nt m et ho d an d ·xi ar e su fficiently do se to th
,;.,i . Fo ua ra nt ee d if
erge.nee js'•g
Zo
z1 ,"•Howevert conv
~ 62. C on se qu en tl y
• • •
r. 2 1.
~ { l+ V S )/
.m et ho d is p th e -b is ec tio n m et
ho d
ge n~ of th e se ca nt
#
or de r of co nv er uc h fa st er th an ·
T he converge m ew km ~s m et ho d .
th -~ n. .b e expectecl to
_e ..~ n t ~e t~ od .t1 on .. bu t no t qu it e as fa .s t as
_-N
or-•fixed po m t.1 te ra