Professional Documents
Culture Documents
Matrix Operations On The Computer - LL Bhirud 275x210 PDF
Matrix Operations On The Computer - LL Bhirud 275x210 PDF
Matrix Operations On The Computer - LL Bhirud 275x210 PDF
,
i:',,,,j'.r . . **
r, .:r''. ':,,;'''#i
'-",-,,..'1j,',
.ljirL!"i:+tli::l
...' :. :
i.,.'ii
li:li:1;
.i1rl:!i
,il 11.
,.,,+il,;.a:::i
::ii,:: n:
-n
_/
I
..4
t-,
t4 -7-'86
)orlr.arta
O 1975 L. L. Bhirud
Rs. l3.50
This book has been published witlr u subsidy under the Indo'American Textbook
Programme operated by National Book Trust, India
Published by Mohan Primlani. Oxford& IBH Publishing Co.,66 -ranpath, liew Delhi ll0ml, attd
Printed at Msyur Printers, Bombay
g Koqu/og 'pDo{ oqqotlg tutog
uDtlutrstoN'Y $yDuaqpw puo a?ua!?s DalcnN nr
DrPq lo tu?tuuta^og aqt Io a.twa, lDuolroN
tlctn?s4y puawDpunl to ap14su7 o1o1
'lulod*at^ p)rpDtd puD urapout o uto{ uailtr$ pupt sltlt
to
$looq arcw ,{uotlt ttott Dlpul ut padu aA4 'apnt nuaotar o sD ro $at D sD pasn aq ppoJ puo
|ooq alqDnlD,l D s! sltlJ'st)adso'SututtuntSotd so lpil so'lnrttDutaqiltut Jlaut to ssau1tattoc
ary lo panssn s! luapfl:^ aqt 'nrtdutoJ o uo patsa uaaq e1nnpo alztl 4ooq s!ry u1 pa1otodlocul
swntSotd allt llD nltls 'suollDp4zr xtrtout m sD q)nur sn Smurutotsotd nrudutoc u1 3u1u1o.t7
saptd,otd 4ooq slqJ 'au.ttl aulos allt tD syszt oN paqyldtuocto Qpat soll prurqg .t1,y ,sraotE
'otd 1t17yayol Jb uuol aW u! satnpa:totd puotp1ndtun pnpD Surdolatap [g 'utrc!alqtssar?o
tppnat o tt1 scrdol asary fioqo uorlnuuolur lo tploau D sulntuor yooq s,pnrlLtg 'rW .uoltDzllnt)
-ads lo sDa.tD asatlt u! stuaprus to atto\tadat puotss'aptd atg lo ltod loquassa uo wto!'sac1.t4otu
uad'8 lo stoltatuaSra puo saryntuaSta ary SulugLurapp puD 'suotlonba nauq snoauDilnws 341t7os
'sa?rt\ottt Stulntut 's\uDurtuta|ap Su4ndutoc tot sampacotd puo 'san.Uout lo uot1olndnmut avlt
rc{ sanbruxlJal 'saJuatJs luaua8punut aW puD Suuaatn&ua 'scrs{t1d lo swapn$ ot aJuDtJodw!
r\uawnpunl'lo tttlot o n otqaSlv xutDw ',1arnduro3 aLfl uo suo1ntadg xlltoA[,,uo yooq cltl..
Eultltm {q npul ut tyunutluo) tuapnts aLil ot ar!^tas aqonp^ o pagpuil soq pn4tlg .rI4J
Pro^\3JO{
secrJlBhl luoro 6e XIUIVN
-lgaoJ ! purg culaurultg a8rel y'91 '9 suvnbs v co rNvNrr^ruarfl( 't
xr.Il?trAl lttolo 9t. sarlrador4 xrrtetr [ lnJasn g'€
-gteoJ pueg Jt"H cnleuur[g g'01'9 9t saculsl J xaJdwo3 .;o uorgecr1dr11n141 L't
fer,ry leuorsuaturq-euo sr: perols 9(, uorlecrldrllnry xtJt€W 9'€
Igl"n luarcgaoJ cr.rlauul,(5 z' ol' 9 eT, seoul"W luale,rinbg S'E
I aseJ [BJauaD I'01'9 & uorlutuJoJsuerl,(rclrrarua;g v' E
99 8r3rJl3w clrlauru,{5 roJ por{lel/{ K1sa1oq3 g 1 '9 lz xul"tr\l € Jo oJBJI t'€
s9 poqlaru alllrloo(I 6'9 TZ uorlJBllqns xtJl"trAl z' t.
c9 poqlehJ lnoJJ 8'9 tz uorllppv xrrl8t^[ I '€
xrJt"hl luetcgeoJ a8r:el 7' 2'9 It sNorlvuado xlurvw afdr^tls '€
69
L9 3s"J lsJsueD I'L'9 6t xrJlr?I l asJa^trJ.ro lucordrca11 EZ.Z
LS poqlahl uepJof ssnBc L'9 6l xrrlel{KrcyvJ1 77'7
99 xrJlew lualc 6I xrrt€IAI luuo8oqlr6 16.!
-goo) puee JIBH c1l1auru,(5 9'9'9 6[ sscrJlew
xIJIBIAI lttelcrgooJ u€t1[.ur3l{-^\eIS pup utsrlru.ueH 0z z
pueg .reln8tre]oeg culaunu,{sun g'9 9 5I xuietr l e go ele8nlrroJ 6I'7,
ferry leuorsuerurq-euo s" peJols 8i xr.rlew xalduo3 g1'7
xlJlsl{ luelc$soJ cl.rlauur,(5 7'9'9 LI xr.rll3trAl crriarunr,(5-,rrols z I' u
xuleIAI L',f. xrJletrAl crrlaurur,(g 91'g
lusrJueoJ eJo 3sl?J lereusD I'9'9 9I xlrlrrtrAl ,{1r1uap1 Jo lrun SJ.Z
I9 poqiert rloIl?Ltltlltlg ssneD 9'9 9I xul8l I rPlecs 7l 'z
I9 slrtButrr.relac lo poqleht 9'9 SI xrrle4 leuo8erq 91'g
gI
6' xrrlutrAl luorculaoJ pu?g [']'9 YI xr.rl€tr41 repr8uerll n^\o-I Ct.T
6? xlrlul4tr luercUleoJ esredg 3'p'9 vt xrJll?tN reln8uerrr radd6 11.9
6t xrJlel{ luercrgooJ crrlerutn{5 1 '7'9 EI xrrlery erenbg 61'g
6n saclJlel tr luarogeo3.Jo sad,(a v'9 fl xrrlBw orez Jo llnN 6'(,
rrotlnlos Jo spoqlaW tl x{r}€I relnfiuelro11 u;o esodsuerl g'7,
I
8t t'9
suorlenbg aldurrg zl sacrrl€tr i rep8uelcay lenbg L.Z,
9t z'9
6 xulstr4J reptuelceg g.C
9' uorlcnpoJlul T'9 o secIJl€trAI tlumlo] ro,nog lenbg g'7,
w sNotrvnbg snoaNvJ-.lnl^rls'9 L xuleIAJ utunloJ Jo ir\oy e 3o esodsuerl V'Z
L xlJluw uurnloJ t'c
E9 .rc1ndwo3 eql uo norlerrnrrJeia6l lrrrT5 T,'g
'E L xrrl€w
ET {uBu to uorlrusa( I ^rou c'7,
uorlcnporlrrl
'E
l.c
E' XIUIVW V CO )NVU L saJturvht do sad^I .z
TV slueurur"(ela6l -;o sar1.rodo.r4 lnJasn L'? I {rort\
o, uorlssnspuol IBlo^rd 9'V ralnduro3 InJssatolls JoJ suorlnBcald S' I
6E luBUlr.uJA]3(I Jo tr(!r l€nle^A lcoJr(J 9',t Z a8enSuel NVUIUOd V.l
6E xulst{ e.;o iurotpy n'v I ralndrco3 eql qlra.uorlesJeluoJ, e 'I
6e JoloP.J-oJ t'v I .ra1nduo3 1o lrudurl Z. l
6€ rouIlAI z'v I {pn1g xrrle14i roJ paeN I'I
6g luPururrslJc r- J0 snlEA t't T NOttf,NCIOdINI 'I
stueluo)
viii
5. 1l Matrix Invcrsion Method 7t 7. INVBRSEMATRIX 89
6.12 Conjugate Gradient Method for Sym- 7.1 Introduction 89
nctric Coefficient Matrix 72 7.2 Adjoint Method 89
5.13 Gauss or Jacobi lteration Method t) 7 .3 Gauss Blimination Method 89
1.4 FORTRAN Languague Subscripts more than 3 are not permitted. Subscript
.FORTRAN' stands for FORMULA TRANSLATION. should not have zero or negative value. They have
Its symbols and expressions look very much like those the general lorms : V, C, V- C, V-C, C'tV, C*V-D,
in mathematics and hence the name. Mathematics C*V D, where V stands lor any fixed point variable,
-
C or D any fixed point constants. + addition.
uses a large number of symbols and different types of sub.
traction and -
* multiplication. Examples ol subscripts
letters frorn many languages ; not so with FORTRAN.
are :4,I,I+4,L
FORTRAN uses the following alphanumeric chara- - 2,3'rL, 5*K- lm 6*L - 7. \ote that
small letters in mathematics are replased b1' capitals
cters. in FORTRAN.
TwentysixRomancapilsl A B C D E F G H I J K The symbols used in the operations ar. :
letters: T,MNOPQRSTU
VWXYZ Symbol Operation
Ten digits : 0123456789 + Addition
Special symbols : + - l-.,o
::: Subtraction
Multiplication
Two types of numbers are used. Division
Fixed point constants or integers written without *'k Exponentiation (Note rhat rhe I asterisks
the end decimal point : e.g. together are treated as one s1mboi1
5 - 123456 Computer executes the FORTRAN erpr..ssions liom
Floating point constants : these always contain a left to right, finishing exponentiation in the lsi reading,
decimal point ; e.g. multiplication and/or division in the 2nd. addition and, or
subtraction in the 3rd. Examples of some erlressions
5. 5.0-12.34
are given below.
Use of plus sign is optional.
Mqtltematics FORTRAN
to the above 2 types of numbers,
Corresponding
b+c-cl+t, B+C-D-T(l.l)
FORTRAN uses 2 types of variables, which, unlike drr"
b2cf B:r.::.')::.c/D (2. 4. 3)
mathematics, may have lorrger names. Length of the
name depends upon the computer used. It invariably
b. (- c) B,,.(
- C)
'\/E sQRrF (B)
begins with a letter. Other characters may be alpha-
l6l ABSF (B)
betic or numeric.
i.e. absolute value of b
Fixed point or lN-variables bave names beginning cos t cosF (T)
with I, J, K, L, M, and N only. They take on integer t srNF (T)
-sitt
or fixed point constant values only. They have 'no tan-z t ,{TANF (T)
space' to accommodate fractional values. logeb LOGF (B)
Exa,uplrs : EXPF (2)
I MP N2 JOY Note that the angles should be in radians. Absolute
Floating point variables begin with any letter except- value of (
-4) is 4. Expressions within parentheses
are evaluated first as in ordinarl' mathematic:.
ing I, J, K, L, M, N. They have 'space' enough to
accommodate a fractional value. The-v take floating Arithmetic involving fixed point coJ'lstants or valiables
point constant values. ignores fractional values. Thus 2 3 eires the result
Exelvlplrs :
zero, 512 gives two. Hence, barring some e\L-epiirrns.
fixed and floating point quantities are not mired together
A BOAT DY2 in an expression. Mode of the result ol erpressions
Variables may be subscripted as in mathematics bttt depends obviously on the mode of the qr:antities in
are rvritteu differently as shown. them.
Mathenntics FORTRAN FORTRAN statements may bear nurnbers tor
at A (l) identification or cross reference. The length or limit
. bn" B (4, 3) of the number varies from comptlter to comPuter.
crrr C (3, l,2) Examples of some important FORTR.{N statements
dij D (1, J) are given below.
q())V ispleg I lsrg orltur paluud sr; '[ lueruote]s k'zt I'zD rvhtruoc
MUO{ ur pagrcads su palurrd are (;)y pu€ ') surrel (x) v 'x 't rNlud
'(x) v ot
LgSrEC,l puu 'X ot SVTZI en1e,t Sruu8rss€ ur tlnser plno,^
'LgSVtZlgVtgl Surqcund snql 'pruc oqt uo poqcund sr
lutodleurrcap uaq^\ pepruEorsrp sr 1r ilurod l€urcap erll
puofeq seculd "3o Jeqrunu aql sel€crpur Z'8.:I ul Z JOqrunN
'sutunloc 8 trxau oql u1 lurod Surleop ur peqcund sl ())V
'(E1) suunloc S lsJg eq1 tu lurod l€uuoep lnoql/t\ raSalur
uB sE paqcund sr ) '[ luaua]Bls MIUOC ul peg (z'gg 'st) Jvnuol
-rceds se pJ"r peqcund e ruo.r; puer ar? 1;;y puu ) srurel (x)v 'x 'r cvau
'sluatuelals al?rpsruJelur,(uu 3ut1iluo'lqEre;1s sl lu3ur
-al" lsol uo ssud 01 loJluoc slonrlsur iuoruel"ls OIODSTqI
9I OI OD
sr v Jr e pu' 'oroz sl v Jr L 'orezl ft:itri
"ru:Ki"rlt
lue(uol?ls elnraxe o1 lo.lluoc slcalrp lrroueluls cI slql t 'L's (v) .tr
'uruEordqns ro ruurSord e Jo lueruolals lseJ eqt sr srr1l CINA
1ffi1 r | :)'
| € I r l-l
trc ENNIII{OJ AZ
: Jepun su qilnoJ les eJB suorplnclec oql .1 dool Jelllo eql
:InNIINOJ 0I
Jo xepur oql Jo enls^ r{c"a roJ pe1c,(c sl rlclq.{ dool ;euul )':I:f
erll ruJoJ slueurelEls elpplur € erIJ .pelsau .a.r .Jaqlo orll z't'I:)0loc
uFlll,r\ euo 'sdoo1-oo z elnlusuoc slualuel€ls s oseql
Z'T: I OZ OCI
'ruesq€ sr N es'c ur :ltffrti';"Y;T#Ti?;:ll'1ffi:
sI f 'selcfc Z aql uI 'eJoru ou ueql pu",E - )
JoJ ueql 'I : ) roJ lsJg pelnJaxo sr dooJ oqt uer{} 'Z :
pue'€ :II,I :lasoddng.ara{ .. :y I'o.r,luoruN
-el?ls lxeu eql ol uo sassud pue dool aq1 Burlncexe sdols
IoJluor ralnduoc '141 speacxe ) trueruoru eqa 'N + N + T
seuocoq tr!'o'I'N ,{q.req1rn; pos€e.rcur sr; eJc,(c pJ€ orlt ur
.a.l ,N,{q f,+g:V I
uJeEu !51 * T:) sawocaq ll poseercur s} XJo :InNIINO) 0l
enF^ (elcfo puz eql ul .f :) .alc,(c 1s 1 aqf u1 .dlpoluedar
dooJ slql selncexo ;elnduroc eq; .doo1 gq B ruJoJ
),rI:f
N.I tr "I : >I OI OCI
1I1NIINOJ 01 . . .OE1 uro.rg Suruur8aq sluourolets t oqJ I:t
'flEurprocce pa^Jesal sr stuJol eseql Jo solUEA Burrols
.rog eceds ,{roulaprg .sruJsl nZ : t x Z x V .J pue s{uJal
9 :7 X g 'g ,sruJol t sur€luo3 v .c pu? g ,v s.{?J.r8
3o sozrs eql lnoq" ralnduoc eql sruJoJur truoruslBls slql G. 'z'v)J'(z 'E)g '(t)v NotsNalliICI
'JoqlJnJ IJol\ slr enurluoc ol;elndruoc
eql ol uollcnJlsur ue sr sFIl !;aqurnu luoruelels eql sl 0l
SNNIINOJ OI
'tuerEord eql lnoq" Suqlouros JopBaJ oql s[el lsnl 11 .ra1
-nduroc eql ,{q perouEr sJ .lueuraluls
lI luerutuoc E sr srqJ WNS CINIS J
.saoE, ueqr enr?^ /r'eu ,ru ;il;i JJ:"i];r 3ii::l*;l
gunsxA 'luaruo ?ls cllatuqluuJo elduruxaraqloue sr snII
'fue 3r 'anlerr Surlsrxa s1r .6urse;e, ro BurceldoJ ,V ol
I+I:I
.seot, g'? anp^'o'l,V alq"rJ"^ ol ua,,rr8 sr g.tJo enle^
eql 'luelllol?ls uollntrrlsqns Jo orlaurqlrJB u? sr srql
s't:v
tuoltouoldxE stuauQtDts NYvJvor
NollCncoutNr
4 MATRIX OPERATIONS ON THE @MPUTER
ln addition to the main progranr, it rs sometimes When the CALL statement is conre Across. contpuier
convenient to use subprograms for certain repetitive control rvill go to ttre SUBROUTINE ADD *i:h value
calculations. For example, consider the staten'lents :
of P, rvhich will replace B there. A is replaced b1' S.
The calculated value of S is retunted to the rrain
Main progrant ; CALL ADD (S, P) program. Note th.at the actual parameters S and P
Subprogrant ; SUBROUTINE ADD (A, B) must correspond in mode, number and size to tlre iormal
A:B+3.5 or dummy parameters A and B. Tlte use of various
RETURN statements used above is self-explanatory. ADD. tbe
END name or dummies A, B nray be replaced by other name
se JalndwoJ aql lJnjlsut ,(slu a,r[ tlirt:i
uaql 'V Jo anlu^ elnlosq" eq1 o1 lunba Jo uuql ssol o,rr o rct n,{rrz.r n ccu q * up,,ittfi Jfit3ilil
s! f, Jo arlle^ etnlsoq€ oql ,{q perldrlJrrru 000 0l Jl aql Kq paureldxa ]saq oJp srequnu go Burpunor .ro3 "i?Xlli
'o'l .V .,,{us .jo onl?^ olnlosqu eql Jo 000 0l/l salnr eql 'tsar aql Surplucsrp puu strErp lsoru-Uol
',{es 'ol lunba .ro u"tll ssal sr onlel olnlosql, slt Jo raqunu parrnbat eql Sururula.r suuaru ,(ldurrs go
31 3 lcalSau ot cprcop eiA 'S - V 'B Surpunol 'a8erols slr FurlulrlrceJ JoJ Jo popunoJ
= C 1ol ot
,sluautelpls
;unba ,{1-reau V eurlsss et'r NVUI_dOJ 3q ol '0JoJa.laql 'speau s1l3rp iuetu .;o Surlsrsr.roc
elrsrnba.r eql alu,r oI'uotlceJlqns Jo llltso.r JOgu.nlu v 'ralndr.uoc eql uo Jaqurnu l? alols
eql ur slr8rp luecgru8rsur eqt llE pJ€cstp,sp:o^\ o1 pau8rsse eq louupJ oceds pelturprn .Iu_reua8 uy .(,
.leqlou[ 'ctllp^ oraz u 1r Suru8rssu {q ll lcal8au 'strSrp pep.rucsrp Jo u,roulun
3o aculd aqt dn 11g
uaql 'uJal leql Jo uorlce{ paul.uJelaperd urel;ec o1 {1duls posn lou a.ru Xeql3r .,{;uo luucgruErs atu
E uurll ssal punoJ Jt : uoql3o ouo .(ue qlt^\ suJal o/y\l seculd tsoru-lq3r.r aqt ur soJaz .00f2I.0 alllraqrunu
uanrE eql3o uotlJuJlqns Jo llnsoJ aq1 e;udruoc .stql p u[ 'luecqru8rsur alu slr8rp lsom-Uol aql snql
lua,rard o1 'JoJra Jo uotlulnunoru ol allp slluse.l 's-0[ x tzl su ro a-0[ x tzl'0 se ua]llr/( eq Xuu
alq"tle.lun ol p"al ,(uru suorlcuJlqns qcns 's.raqunu fZl00'0'aydurexa .lo3 .,{llueregrp iaqrunri eql 3ur
uo,rr8 eql Jo sllSlp luecgru8rs g ,(yqrssod lsute8e xssa;dxe ,{g go pu 1oE aq duur pue lurod luulcap aql
se lr8rp luecgru8rs auo ,(1uo Eulululnoo 169. sr aq {ldurrs seculd lsotu-Uel oql ut so.toz 'reg[ur.ru
lfnser oql :Z0O'Vg ruo{ 100't9 Jo uoncelqns oql llorl,r Jo pua 1q8r.r
aql lu sr ro slr8rp 6 tlSnorql
'alduuxa JoJ 'reptsuo3 'syr8rp luucrptr8ts Jo ssol i aqt 3o orrrl ,,{ue uoa,{\lsg paqc}t,rpues sl lt uaq,.\\
ur sllnsal sJaqunu lenba ,(1;uau o,ru Jo uotlJt?.llqns 'e I luo luucuruSrs sr g 'luecgru8rs eru 6 qSno.rql
I sllSfp orlt
llv '0 pu? ,6,g ,L ,g 'S ,l ,t ,Z,I
'sJaqunu Jo EurpurloJ ur suotluJoptsuor luel -srirp 3o uorlct"llquot u se .leqlunu e ssa.rdxa all
-.rodr.ur ere ,(ilrurxo:d pue uorlrluasa;da; uela strr.JI 'uorleluasaldoJ
luutJap JutltrueJ oql oJaq JaptsuoJ
.I 'Jo^e,rorl 'lleqs a,4 .3urpue1s:cpun 3o ,{llclldruts JoJ
,(q posua:rur sr aculd luutJap ',{1uo 1 pr.ts 0'zt^ 'sllSlpo^\lJo dnolS u su 'o't .ru,JoJ
puz eql ur Z ltErp aq1 'a'r ,(.tuurq ur pesseldxa oJB sJaqtuuu .sJolnduoo uO
'€I' ol papunoJ sl lt sJuaq 'lt ut sarn34 luecgru8rs aql uo spuedep suollultlJluJ
izl' ot u€rll €l' ol Jarpau st Jo llnseJ p sB paululqo Jaqunu u.;o ,(celncce aq1 .l
pus szl' spoecxe rsqrunu
aql El
. 109 zl. ',\\o[aQ ua,lt8 ra,ra.totl
'uelBl st Jequnu are,,(oernccu Surnarqce .loJ suoll€.leprsuoc ltrulrodtur
uaAo lsoJ€au oql 'go Eulpunor
ouos 'crdo1 srql Jo luaLuleerl aldurrs ioJ (tg 'T.g.gL- tL)
sacuatatay aas asuald ,(eur srepuer pelseJalul .Iooq
JOJ sngl '{Jo/h ralrrduroc
JOJ Zl' Ol JsJBau PolaptsuoJ
slqlJo edocs eql puo,{eg sr popto^" are ,(aq1 ,\\oq prr€
ur deerc sJorre .alqetler
sr Jeqrunu oql spJo^\ Jer{lo 3o srs,{1eue claldtuoc y
u1 'paEuuqcun 1da1 s! tl ocrreq
pou oq 'sos?r ^Aor[
luuotldecxa ur
,.{etu ,relnduoJ arll uo
aeurBlqo sllnsal oql 'a.rnpecotd ;ecrluuraqluu snoroSu 3o
iualo 'a'l '7 sr aculd lerurcep
puz eql ur il8rp eql 'lrdsur 'lerll punoJ sl :ll 'eJaq ,\\ora ui lou ',(lsnornqol
lng ',{ltcexa
saru sqol Eursseco-rd erel4tr 'olqrssod sp al"JllJJB
SZ,I' slurrbe Jequinu eql Z,l. 00S ZI. -E eg lsnw 'esn ,(uu Jo"]epeq ol 'qJtq,$,suorlelnJluJ Iucu
'l ,iq eunu ol .{1e1urur11n sornpoJ lelnduloc eql Llo IJoA\ IIV
pJsPeJcuI sr ecqd l"rurcep
:1ro11 lalnduoJ InJssoJcns roJ suollnuJald s'r
puz oqt ul 9 llSlp eql eruoH 'S
ueql ralua;E sl slql '9 sr ece;d '(tI 'l[ '01 '8 'L'g'S 'p '7) saua,tatay (
!t)
l"trlrcap pr€ eql ur 13rp aq1 Lg.Zl 1999 99'ZI 'pn norS>1cuq lecrleruoqluru
'pa8ueqc qErg arrnbar lou op asaqt :(21..6,t '1) sacuataJag (r)
-un surBtual eceld lerurJap puor NVUIXOg Jo .{pn1s :eq1rn3 ;og
pu7 orlt ul € tlElp eqt aruaH 'Iooq srql ur sluaruEes
'S uuqt ssel sr srql 'g sr eceld
uerSord .ro surur8ord NVUIUOI eql ..\{olloJ ol }uarogns
Jurrlrcepprg arll ur lr8rp aq1 $'ZI CL'EE E€'ZI eq lll,!\ 'raluJ ue,uB selou Xroluueldxa qlrn paldnoc
ragunN .taqwnN 'c8en8uel . reruurns o^oqe aql
NVUIUOI oql lo
uo11ouo1dx7 Papunov ua^!D 'dya,rrlradser sloqurfs pue
NOIIJN(IOIIINI
MATR,IX OPERATIONS ON THE COMPUTER
Exltrrprr 2.3
Find the biggest element ol the above olle-dimetlsiorlal trrray A.
FORTRAN stcttenrcnts Explattaliort
N:3 Number of elements of I
BIC: O Variable BIG is initially assigned zero valiie. During
execution it is assigned the value ol the a:;'ar ',erm il
the latter is for.rrrd to be bigger thall the rhe:: .tr;'re nt
valtre ol BlG. Thtrs at the end of execution- BIC 'tands
lor the biggest term ol the arraY.
L:0 L is initially itssigned zero valtte. During
assigned valr,re of the serial ltumber of the
the Iatter is found to be bigger than the
value BlG. Thus at the end of exectttion.
the serial nurnber of the biggest term ol the
DO I0 K: I, N Statenrents be-ninuing rvith this. trpto and ;:',cluC irr g
statenrent l0 are execuled N : i tinrcs. ili . i' .-;e.Sir e
valnes of K: l, K:2, arrd K: -1.
tF (BlG A (K) ) I, 10, l0 Control goes to statemellts l, 10, l0 il BIG ,. l:.r liiatr.
- equal to. or nrore than, A(K). respecti\el\'.
I BrG: A(K) BIG assurnes tl.le lte\\, valLre A(K).
L:K L records the serial nttmber K ol the tern.i: .: :elis the
serial urlmber ol the biggest lernr rvhen :he DO loop
is satisfied. In tlris problern. t- : l. arrd BIC : -i0.
IO CONTINUE
2.5 Equal Row or Column N'Iatrices, \lutrices ,,1 and .B are saicl to be eqr,ral. T::;; hare
equal nunrber ol elemerrts and their corresg.riJ::ig ele-
Suppose, there are two lruit baskets containing 30 apples. meuts are eqtral. This fact rna,v be staiei :.
l0 bananas, and 20 oranges, each. Let rnatrix I denole B:A
fruits in one basket and matrix B, frtrits iri the other. of as
Then, we may write Bi: A;
,4:[30 t0 20] where sutrscript i relers to the ith lerln lar :ic:::::: .lf the
B: [ 30 r0 zai array concertred. ln this case. I nlay Lte i. l- --: -:.
Exrvpre 2.4
Given a one-dirnensional alray A having three terrns. fornr array B : A on the colllptlter.
FORTRAN statetnettts ExPlattatiott
Exenrpre 2.7
Exchange row 2 rvith rorv I of matrix r4 of Example 2.6 above, thus giving,
120 4 70]
z: to 2c 4oJ
I3ol
Lso 30
eEueqcxe os .lse88rq 'lalnd
"urtt:,0;:1,)"t.I,tlr:rfr:l -ruoo eq1 ul .{curncce
? PUB t 'Z'I pnba qclq,Lt eql uo suorlelnolec lucrrarunu
'l*y pue .ztv .tzV qzv
sluoruelo
t eql ruor.; (1uo punoJ oq 01 sr tuoruale lse8Elg Jo ssoJ Furpro,re rog suorlenbo sllooueiJrlrui, 3o uo,1
-nlos_ aql ur pelnbel are suotleJado
qcn5 .iueruolo
1o.trd eq] su u,tloul si luuo8erp eql uo peceld
slualuere orsz roprsuo3 trou oc{ .g.z pu? 0l lueul
-uexA go ernpeco.rd eq] Bulmollog ,,{lessoceu
;I."ry:rHH -a1e 1sa33rq aql pue .Burlolrd ,n pr*nu
sr uorlurado
Jr sr.rurnloJ aloqld. SrqI .0!_:ttn .{Ou .r\or.r .e.r ,ttv
1U peczld
pue s.ro-r SurSueqcxe .Z
_
uo leuo8erp oql rro lr se& luouralo slrll ,9.7 alduexg rrr sul'uuloJ pue ,L.Z
aceld uerJl pue .€ puu s.ro-r^\or
Z ur luauele lse88rq eqt purt aldruuxE rrr sndol Eur8ueqcxe fq uoq] | puno; se,r
ta;z lneurale lse88rq eql .9.;
s ol eldurexE- rrr
,lerll eloN
iy I
l(. oi:F
iErt) los or orl
xnleur u u0^rD lot oz or |
:ly
iOz 0t 0!_:
6'Z a'rdrrvxf sr A\ou xrlll?tu Burtprsar aq1
TONII\IOf OT
dt\3I : (]OJI 't) \'
(rort 'f) v : (t't) v
(l'ftV:dl,\3l
'JerllouE Jau? erro .r\ o1 I sA\oJ Ur Slusruala .reptsuoJ
Itrl
'l : t 0t OC
.t/ toj spu€ts
JO S,\\OJ JO -reqturlu trAl
€:I^I
E : TOJI
I:l
tuotlouoTdxT
stuatuarDts NYVJVOI
-sutsJl 'e \oqu p0,\\olJoJ 1?r.[1 01 rellurs sr a:upacord aq1
urontoc o1 saoS dt{ar ,t1ye'g : (I .".,) fuo,?,1,;t"t)r:
sao8 (1931 fq palouap) g uurnloc ur lrrerueJo Burpuod 'l uLunioc qire\ [ urlllloJ eSueqcxe pue
:serroc ueql 'dI{!IJ 01 soo8 (1 {q palouep) e^oqu /'7 alduexg Jo y xrrluru Burllnse: oql oIuI
I olunloc
ur lueuela .lsJrg .auo ,rq orro elrop sr sluauralo Jo JeJ
g 'a 3'rdtrvxg
'r(1err1cadse.r $zV pue 'ziv .rz7. snNIJ_NiOf 07
o1 peu8tsse [reql eJg rlclq,$ sr7 ,z-,V ,rrrt Jo senle^
sournss" ,(le,rrssaccns dIAIAI ,doo1 et1l
Jo rrorlncaxa eql
8ur:nq '(f 'mOUl) y or sao8 anle1 :
^\ou dt\lgl Jo dr^igr (r'moul) v
'doo1 6q orll
Jo uorlncoxe aql furrnp {Je,rricadsas ery.
'YtV "tV ol pau8rsse aJP, tiy' 'i:.V 'rarl Jo senJe1 (t'ttouI) v : (f 'I) v
'dWAI trorl€JoJ rrr pa,nraseld sr .4y 3o en1e,1 (t't)
v: dttgr
'Jerllo
eql JaUe auo 'N ol I Suullloc rrr sJrra111ele raptsrroJ
N'r:f 0zoo
't, Jo suunloc € oq] roJ sp{jets N
E:N
'paSuuqcxe oq ol
Z JoJ spu€ts 1y\OUI z : A\ouI
^\o-r
J
'pa8uuqcxe aq ol I ,{\o.r .roJ spu€ls
I:I
uotlouoldxg sluaruatpts NYVJYOI
ll saclu.t.tdlt co s:rd^I
t2 MATRIX OPERATIONS ON THE COMPUTER
14 2
A:iO 3
3l For computer work, take variable BIG. Assign the
4l value of zero to it. Then compare it with Arr, Ar,
l.o t z) A"z, A"" one after the other, assigning it new value
Then exchange column 3 with column 2, and get of a bigger term, if and when found. Also preserve
la ? ?l the values of the row and column of the bigger term,
z:ld i 3l irl locations IROW and ICOL respectively. Then
l.o2rj exchange rows and columns, if necessary.
This matrix has all its elements below the diagonal l. bbb2. bbb3. bbbr. bbb2. bbb4. bbb
f all the diagonal elements equal 1, the upper triangular equal to zero. In particular An : Att : Azz : 0
matrix is called a unit upper triangular matrix. i.e. rorv nnmber ol the zero elemeni is less tha' its
2.12 l.awer Tringular Matrix colurnn number. This rnay be stated symbolically as
ExaMpLs 2.14 Aij : O for i '- i
Giren a square matrix of order 3 Such a square matrix is knou'n as a lower triangular
n00l matrix.
A:12 3 oi As in Example 2.13 above, only non-zero elemetrts
[+ 5 6)
need to be punched on data cards for computer work.
instruct the computet to read it from suitably prepare d Let them be punched row-wise in F-format, in 5 columns
cards and print it. width each as
This matrix has all its elements above the diagonal 1 . bbb2. bbb3 . bbb4. bbb5. bbb6. bbb
'0 ol
fy sles pu? '9 ol oslo ro '91 o1 saoS lorluoc 'f: I Jl g'0I'g(t-l)gt
N.I:TOIOCI
N.I:IOIOC
OUSZ ]Td3I'IVNODVIC.NON J-gS C
'pBoJ a-r€ ttr, 'zzV'rI7 srutal (N'r : I'(t'I)v)'t cvau
'pegrcads p'3o ed,(i pu€ ozrs (e 's)
v NorsNahrrc
surullloc Jo s,^\oJ Jo JequrnN f:N
tuotTouoldxE tuot8otd 111
yVJyO!
qqq'zqqq'€qqq' i pe.rederd ,{1qe1rns Luo.rJ lr peer ol lelndruoc arll lclu}sur
S€
ic 0 ol
psgcund eq ,(eru surral luuoEelp eql fpo '1:on ;e1nd l0 c
I
-ruoc JoJ 'xrJl€u pttroSolp palpc sr xuletu e LIOnS r0 0 ?):'
"
t: t roJ 0: If xrJleru€ x€suo^rD
se .{11erl1oqrui(s pe1z1s eq ,(uru sq1 'oJaz gI'z a-rdr^rvxg
-uou et€ r:r qclq^\ roJ surel'e'r'sulrol luuoSerp eql
fluo 'oJoz ol pnbe slueurele leuo8erp-go 'e'r luuoSerp xrrlutr l luuo8u;q 91'g
eql Jo e^oq" sluauolo slr JIe suq xrJleu sql 'xrJl?ru nln?uou| Jato! ttun e pallec sr 1r 'leuo8urp
^\oleq
'11 lurrd PUB sPrec uruur aql 8uol" s/I II€ s?q xrrluur ruprSuerrl JelAol aql JI
'9qqq 'sqqq '?qqq
'0qqq'tqqq'zqqq
'0qqq'Oqqq'tqqq
patulttl qnsay
Cl'.iS
(o'sce) rvhruor z
(o'sgs) rYnuot r
(u't : t'(N't : r'(r't) v))'z tNtua
o:(t'I)v oI
N'X:f0lOCI
I+1:Y
J.I:IOIOC
IKOJ etlo lnq 1SB-I I-t{:'I
(Z
€ uoql uaql'I : [ 't : l
Z nor{t'l : | '(,: I
I : [ 'l : I
ueq1\ 'Surxepur ?ql eloN (N'l : I'(t'[ : f 'fu'I) v))'t cvgu
pagrcads xrJluru 3o ed,(1 pue ezrs (e'g) v NoISNaI^rrc
xrJ]€tll Jo ezrs €:N
uogouqdxg ruotSotd lrlyvJyOf
SI SE3IXl,Vfi co sSd^r
16 MATRIX opERATroNs oN THE coMpurgR
6 A(I, J) _0
IO CONTINUE
PRINT 1,((A (r. J), J_l,N), r_l.N)
I FORMAT (3Fs.0)
END
Rewlt printed
bbbl.bbbO.bbbo.
bbbo.bbb4.bbb0.
bbbO.bbb0.b
instrtrct the cornputer to form it arrd print it. Ai:O lbrall iexcept i:
FORTRAN program Explattation
N: 3 Number of rows or columns
DIMENSION A (J,3) of I are specified.
Size and type
DO l0I: l, N
DO l0J: l, N
IF (I J) t,2. I
-
I A (t' J): o Terms whose rorv number differs from their column
number are set to zero.
Go ro l0 control goes to l0 skipping the next stotement.
2 A (t : 2
'l) Diagonal elernents are assigneil their value.
10 CONTINUE
PRINT 3, ((A (t, J), J: l. N),I: I,N)
3 FORMAT (3Fs.0)
END
Result printed
FORTRAN statenrcnt.t
TYPE COMPLEX Z co n.r p rr te r, r,,-, r"..
",,.
o i'Tl",l'.l,1'no{, r ri s c o n r pr er.
READ I. Z
I FORMAT (C (F5.0, F5.0))
PRINT I, Z Note the use of C.
Followiug this example, the elements of the rnatrix
A may be punched row-tvise in F-forrnt as
1.bbbt .bbb2. bbb3.bbb0.bbb-l.bbl . bbb_l . bb
READ 1,ZR,ZI
l. Matrices lR and AI may be punched oue after
ar.rother. AR may be read first. then l/. p'-rrrching
l FORMAT (2Fs.0) mav be done row-r.vise or columrr-rvise.
In the case ol a complex rnatrir, lhe real and imaginary 2. The real and imaginary parts ol any elentent may be
parts of the elements are separated to tbrm 2 matrices punched one alter another, as is done in FORTRAN
indicated by two separate FORTRAN variables. Thus lV above. The corresponding elements ol lR and
for matrix ,4 above, rve may have AI are then lead together as given belorv.
'poEusl{cJelur eq 01 poeu r_r ',(teut3utur
JO Slt\OJ agl 'peEu€qcJelur eJ? r Jo sulunlor Jl Jo oJez Joqlre e.le sluarualo leuoEerp slr lle leql oloN
TJON 'xr.rleru uDu!uuaq
,_!t ls E 1narys E poll"c eJoJeJerll sr Y 'Y- : {,,,Y\ sJoH
:rY -- v (tt)
i;- clt -)I bz l' o r-r-l _ i o r+r-l _-
'l-r*
lz ol :rY lzlt o :v f)
i,-t o ):"Y r oi-vJr
i.o rj loI 'lEeJ eJB sluauelo leuoEerp slr Il€ luql JloN 'xrJletu
: S3'IdIAIVXA uotlrtLtraq e pellec oJoJoJeql s! v 'y: r(,,.y) e:e11
ry :8r Se uolllJ,t\ SI
puv V Jo aslarur aqi pelluc sg g 'xtrluru ,t41uap1 eqt
I t. ,+zl_ *Y [ e !-z) Jl
'rt r):
-z +z ri:v 'rt
'I : yg : gV laLlt qons er? g pue V seclJl?lu erenbs .;r
,,7'3o esodsuery : {,,Y)
xlrlutrAl osroaul ro lucordpag g7'7
y jo ele8nluoc : ,:,Y
Lt\ S/\ xlrlslu xeldruoc erenbs : la-I
I - I-I :V ''
sarlrlBtr^l uBlllruraH-^{a{s puB u8llluraH 0z'z
L/\ € /\
l+t I ...y ',(reur8urur a.l€ p'Jo slueuelo orl] lle J! puu
sr elduexe eldutrs y 'leuoEoqlro eq lll,K sluaruolo luoJ :v
: ,ry 'luer eJ? p, Jo stueluelo oql llB 3r '.{lsnornqg
qlr.{ xu}Bru ,(relun e flsnor,\qg 't : {!rV\: {,:.y)'V r+zl
fr-s !'
l'r+€ t-z)i: TJ/
xeldruoc erenbs y I
11 ttolyn pell€c sr v xrJleu i , !_ t]l-*Y I -L rf -ll)
xlrlEIAI trrc11lu5177'7
Jr snql
lg so" g rrys
" 'o ',rV Kg polouop sr lI 'xlrtout aloBtrlirot B pallec
-l Y sr a;durexa
i-n sr luqn la8 e,tr'selu8nluoc Jreql ,(q V xrJlelu
eldurs y 'xrrleru
'" .{1r1uepr*,):uB 'I : ytY : fV xalduroo ? o sluotuelo otll 11e eculder o^\ JI
JI l-/\:/PuB
1euo8oqilo palluc sr Z sluetuele l€er q1r,4 xrJl€ru erunbs y flrtuenb leet e'"b + zd : (tb - d) (1b + d) t€ql etoN
xlrtutr tr luuoSoqlrg 17'3 raqto eql Jo eleBnluoc eql Sureq t4cea 'salo8n!fuol
'g reldeqc ur petrteldxe sI qctql\ 'tloll d puu tb a d se qcns sJeqrunll xeldruo3
poll€J orz lb
-
-ecl1dr1lnur xr-rluru r.ro pesuq eJB sr.rorlrugop 3urmo11og xlrrutrAl u ;o elu8n[uoJ 6I'Z
) 'rqqq'0qqq
'sourl o/hl osoql uo palurrd s! UZ) 'zqqq'rqqq
(,t'1uo saurl T, ts.ty:) pa1u1.rd tlt:nayl
',r\o.r euo uo paluud eJe slaqunu Z (o'scz) rvwuoi z
'pelurrd sr // lxaN (y,r 'r : I'(N'I : f '(f 't) tv)) 'z rNtdd
'1s-rg peluud sl UZ (N't : I '(N'r : f '(f'r) uv)) 'z JNtud
(o'Ess) J.vr\luol r
'r|1y ptre ,,UU Jo sarrle,r sE psoJ
oJe€'l que0'I slepunu Z'l: f 'l : I roJ 'a'l ''teqla8
-o1 pseJ erc I1V pue ttyy slrrJr.uele oqt ,roq oloN (w't :I '(N't :f '(t'l) tv '(r't) uv)) ' I ctvgl{
- 'Iy pue VV Jo sJzts aq] lnoqe peurJoJur sr rglnduo3 Q'd tv'(z'z) uv NorsNsrrurcr
IV ro vv Jo sulunloJ z:N
IY ro vv Jo s,rou Z:W
uorpunldxT stuaualots NYYJYOI
sacIuISI^[ JO SsdrJ
20 MATRTx oPERATToNS ON THE COTIPUTER
: t4 2l
tj 'a' : |]r- s'12
3t2 -ll A-,:[\nn
n -ltp -tP|
' [t zJ 3l2j
For orthogonal matrix A, At : a-r
Ifrows of A are interchanged the corresponding
columns of A-r need to be intercharrged. (iv) I : t2 ol ,_, _ttl2 0l
A-':lro'
[o a) tFJ
A :13
;] *' : tt-i - l!:l A is a diagonal matrix. l-r is also diagonal.
i.2 of A-r are reciprocals of l.
Elements
"
: Jepun su slluJ
Jo sarlsu€A5lq puB IIBrus ureluoJ 8r pu€ t' slelsug
3-rdr^[vxg
''t
gr ocgrl * y amg: (S + y) ecert lurll oloN
sI:6+9
9:S+I
I:I+O (t't) v + E3vur: gJvur ol
N.I:IOIO(I
'surJel
IeuoS"rp Jo suolllppe eArsseccns Eurlelnuncru .lo3
lr erederd ol enle^ orez pou8tssu sl gf,VUI elq€r.le1 O: SJVUI
r Jo ezls €:N
(e 'e) v NoISNghtIo
uolpuoldxg stualuatqs
NYVJYo.I
: Japr.rn sa 'E ur u€tll gr lo{ssq ut aru seSueJo pu€ 'seusueq
slucurolpls eql Sulllrr'r .,(q relnduoc oql uo ouop sI stql 'seldde erou ,(uuru ,4'\oq pug 'aldtuexs oloqe arlt uI
'91 spnbe f xrJlBIu aql Jo aceJl eql oS 'SI sI tutls z'€ :Ildhlvxg
JIagI '6 pue S '[ eJB sluotuele luuo8etp eql eraH uollr8rlqns xlrl8l i z'€
le 8 r.l (r)s+(l)v:0)c or
ie s vl:v
LT Z T) €.I:IOIO(I
xuletu orenbs € x € eql Jo aJ€Jl ot{l purl stuawatots NVYJVof
't :r'rdr{vxg 'trctttppp xulpLu polluc sr srql
e
'saJulEru t 'Z 'l:.1 roJ $ | lV : 12 ro
Jeqlo JoJ peugep lou sI lI 'sluetuelo leuoBelp s1r lsq s, 9zl : )
Jo runs aql sB peugep sI xrJlutrr atonbs e Jo eJeJl eql
tss sz srl :s
xJJlEru 3 Jo aJErI €'€
loe oT, orl :Y
sB ruJoJ
(l)v-(r)s: (r)o or xrJluu ur rrellrJ,r aq .(uru slolsuq et[1 ur slnr eql
e'I:l0lo(I 'NVUIIIOJ uD prrB
stualualDts NYYJVo-I gr 'Il uea,rloq uorl€ler eq1 sserdxg 'se8ttu-to S9 pue
's€uuu€q Ey'seldde SZ uleluoc ,(lsnotlqo IIIII\ 1l'3r la)seq
'uott)p[qns x!rltlut pallEc sr slt{I
trr parldure oJB gr puu f slols€q JI 'so8uu;o S€ pus
E'Z'l: ! roJ lY lg : lQ Jo 'seneueq 97 'selddu EI sut€luoc g leISEg 'so8uero
ts 9- 9l:o 0t pu€ 's€u?u€q g3 'seldde 0l srtleluos f/ ]a)sug
sEo I'E :rldNVXf
xrJFIu,{q palouep eq feur stql 'Y uerg aloru seEuuto
S puu 'seueueq g 'salddu g surutuoJ g leIII J€elJ sI tI uoltlppv xlrlBl I I'€
suoltBrado xl4Btr tr eldqs
€ urrilvHS
22 MATRIX OPERATIOI.LS ON THE COMPUTER
s 20s
I
2. Multiply this row by Art: 4 and subtract the result 6. The mathematical formulae or algorithms involved
fromrow 2to get row 2 (keepingrow I unchanged) as are :
22
rF (J - I) 22. 50,22
B (Jl =. B (J) B (r)*A (J.r)
-
A-!
f10 20
i.rs 10
301
sj
i
' i3 ti c-
rt2oo
6) i.8o
260l
l loJ
DO 30 K: II. N
l-+
rO s-vmbolically.
30 A(J,K): A(J.K) - A (.1,11',:'A (l,K)
DO 40 K =. 1, N k ='J
40 c(i,K) : c (J.K) -- A (J.r)':'C (r,K) Cii: 2Air Br
k .:1
50 CONTINUE
60 CONTINUE n'here
10
DOIOK:I,J
c (r, J):c (t,J)+A (t, K)''B (K. J)
l'l'l'l'l'
DO 20I: 2, N
K:I-I
DO20J==l.K
c(r J):o Elemetrts of C belolv the diasonal are now set to zero.
Note that the value ofX4 depends on that of Uii. Once Special Case
the off-diagonal element Xy, wheie lli, is determined, If Uis a unit upper triangular matrix, i.e. if all (lii:1,
the corresponding element Uy is not required in further the formulae for X get further simplified to
calculations. This enables overwriting of Xii on Ui;.
Thus for computer work separate matrix X is not abso- Xii:l
lutely necestary, unless a problem requires both Uand Xij:-2X*Uri
k
X for further rvork. . for i-j, and i', as specified above.
The expressions for. X arc :
Exluprr 3. 17
Xii: llUii for ltori Given 2 lower triangular matrices
:
Xii - (2 Xir, Up1)1U11 for I to n-l lt 0 0l 16 0 0l
k j-i fltol A: lz 3 ol r:ls 4 ol
:
- Xii (lXii Uik) k:i to j-1 l+ 56J l.: 2 t)
Verify that vector X does not change if we solve UX-I
obtain C: AB.
on the lines of Example 3.15. Necessary FORTRAN Note that both A and ,B are louer triangular. For com-
statements are given belory. work (i) zero elements of,4 and B need not be
pr.rter
punched and read, and (ii; muliplication by zero ele-
FORTRAN statements ments either in A or I needs to be avoided. The
N:3 non-zero elemer.rts of matrix C are clearly giver, by
NI:N-I C1: AtB'
DOIOI:I,N Czt: Arr By * Azz Bzt
+ ABr BBt' :,rZi \2 lj
t0 x(r,I): 1./u (I,I) C2,: A"o 8,2
C,tr: At:tBrt -1- Ar,rB",
DO 20I: 1. Nl C"z': A,tz 822 * A,1t, B.tz
II:I+I C3s : As B;;",
DO20J:II,N Note that matrix C is also lower triangular.
SUM:O The general forrnula for n'rultiplication, therefore,
JI:J_I becomes. for matrices ol size n
DO15K:I.JI Cii :2 Ait' Bt,j for i:l ton
15 suM : suM - x (r, K) "u (K, J) k ,r:1 to i
20 x (I, J) =- SUM ', X (J, J) k:j toi
FORTRAN stqtements Retnarks
N:3 Rows or columns of .4 or B or C
DOl0t:t.N
DOI0J:l.I
c (I, J):0
DOIOK:J, I
'l,i z lrl,z
l0 c (t. J) :. c (r, J) -i- A (t, K)"8 (K, J)
12.,, L."
L dr
L,,,,) l-
y' Y,,, Y [oooJ FORTRAN statenlents
Or N--'3
Iii : I : Lrr Yr, : Lzz l'lz: L"t )'tt DOlOI:I,N
.Ir1 : 0 - Lz, l'n i- Llt Ytr
l0 Y(l,I): l.iA(t,l)
/,tt : 0 : Ll Yrt * L32 Y21 -l L3't Y,t, DO20t:2'N
1rr:0:L'.t"Y.'l-+Lg*Yez IN:I-I
Or
DO20J:I,IN
SUM:O
Y:|-- liLlt: 1 2 DO15K:J,IN
Y22: llL22: 217 : SUM - A (1, K) '' Y (K. J)
15 SUM
Yss:llLs":'7126
20 Y (1, J): suM'r'Y (l.l)
)'zr: - L2r Y7tfL22: -- ll7
Special Case
I,,r )',, + Lrz l':.l :
rgr: - ---L;-- If Z is a unit lorver triangular matrix' i'e' if all Lii l'
the algorithm for Y gets firrther simplified to
: tl26
(r6tlszz-si t
'fr1auu.,(s ,{q paurulqo eg ueql ,(uu
'spro,,\ raqlo u[ 'sluo.,'elo orez {q uor]prrdrlrn* ii:l""$
iftussoceu Je^a {oq sl 1I .o^\tr 5ql lo Jeqttau sr leuoEerp eql .,lroleg sluaruelg .uotlrrydtllnur lenpe
J oltq^r dq tno polJo,r\ eq .(uru e13ueu1 raddn eql ut sluoluelo
ru;n8ueul Je,trol sr g ,reln8uurrl .raddn sr f l€gl oloN
atll ,{1u6 Jlsq ol pecnpoJ oq uec >1ron rslnduoo oql
.gY :, urelqo aouoH '1ecr;1atuu,{s sr J l"tlt pacqou eq osle ,{uur lI
le srl ls ool :' 'Pl Jo s1r\OJ aq1 SuOure slcup
-ord rauur eq1 3ur1u1 ,(q paurulqo eq osle u"c J snql
t3 3',J:r l: !,0,1
saJtJl€tu reln8ueul Z uolrD ()'f) y,, ()'D v + (f 'I) J : (r't) o oI
zz'€ 3'rdr,\rvxg e1t:,t ,{eur 3,4A pu€ '1{y : tlg ',y : g
',(1enl1eure11y '€r Jo suunloc aqt Suorue slcnpord reuur
(r't)J:(I't)c oz aq1 3rrr1q.{q peurelqo aq ol ptes \g 'fl : , as€c srq} uI
(r')) g,,, (['))s + (f 'l)) : (r,t)c ol (f '>) a ,* (t';) B + (f 't) ): (t't) c ol
I'I:)0IOO
o : (t'I) J
s8 ugllrJ,\\ eq
uac lueualals NVuIuog lsul aql uaql lce.I sn{} Jo
N.I:fOZOCI epBI'I'r sI esn Jl '!49: -Ylt, 'spJo,{ Jaqlo ur ifl :y
N.I:IOZO(I 'o'l 'g Jo asodsuerl eql sr y ftql pocrlou eq uec lr
stuawdlDts NYtrJvon 'g pu€ Fz saculelu Jo sluotuole aql Jo sent€A orll ruoJj
(r.y) s * (x,r)o * OI
f .i:;Ji ;: c
f:'r a
eoro9
I:T
z'z'r (r gr
c : -(r'r)r) J
N.I:fOIO(I
N.I:IOIOCI
J JO g Jo r Jo su(unlor Jo s,rou €:N
uoltouoldxT stuarualus NYYJVO-{
Jell€tus srJ0^erlcnl1l\'/to o1 1: 4 ,(q ue,rrE snrll eJB J Jo slueu
Lt ol | : f -ale oql .popro^a oq 01 speau g $ y ur Jorlllo slualu
,t
,/ ot I: 1 rc1 [lg
]t!y {D -ale oJoz fq uorleclldtllnu pue pper pu€ paqcund eq
=: l:l peoug Jo V Jo sluotuels o;az 'ero3eq sy
'secrJl?tu Jo ozrs t: a Jo-l 'seuroJ "ru;n8
-ag 'erogereql 'uor1ecr1dr11n* ,o3 -uetr1 raddn sI 8r pue ;e1uEueu1 Ja',rlol sl F lBI{1 aloN
".n*iog 1"r"i'.a
rq1
.gY irr€lqo
'oJaz-uou eq ,,{uury Jo slustuole eql Il" l"ql eloN
: J
,it.g ttr:y,
-r_ |?.g aty + ttg tty : ltt:)
lg qql
ez.g i.{:Y
e Ol-s ls tsrlzi:Y
l0
+ .rg r{tv, :7tt) t; zt) io0rj
t1g r!:Y :111)
soJrJl?ru telniueul Z ualrg
t'79 tTY
tz tl + tttg li'Y :'<:i'J
tl Zl: C |ig 77Y i'tg tiv : ciJ
+ IZ'€ 3]dr{vxa
vi Z l) ig tay : ft.J 'e^oqu pagrceds se rJ pue './'.1 ro3
t:rg try, _ tr
4
ztg trv : drc {ttr ary {t,r.
7
ttg tty : tr,. - :: !!,tr
r
€€ SNOIIVUIIdO XIUIVW !I'IdI^US
34 MATRIX OPERATKDIS ON THB COMPI,.TTER
Note that the expressiotr for term Arrcan also be rvritten as which may be verifled easily and expressed in symbols as
FoRTRAN statetttettts
The real and imaginary parts of these nray
'ratrices CR DIMENSION AR (2'2), BR (2'2)' CR (2'2)
also convenier-rtly be ,tlo*n by 6 rnatrices, AR, BR,
and AI, BI, CI respedively as DIMENSION AI (2.2). Bi (2,2). CI (2.1)
:t ll BR=lr.j
i2 rl i3 3l : 2
I\'{
AR=i, .l
r) J)
cR=
io 6) N:2
lL lL
t.-)
DOI0K:l,N
Note that AR, BR, etc. are treatecl as sirlgle symbols cR(J,K):0
or names of matrices. ct (J.K) - 0
Hence we may also rvrite expression like DOIOL-I,NK
A : AR +iAI or Ay : ARi* + iAIir< CR(J,K) : CR(J'K) + AR(J,L)'I'BR(L'K)
where istands for l-;,7 for row, and k lbr colnmn
I - AI (J,L)':'BI(L, K)
number respectively. l0 cl (J.K) : cI (J,K) + AR (J,L)',rB](L,K)
Further, using now C to denotc the multiplicatiorr of
I +AI (J, L)':'BR (L, K)
matrices A and B, we get 3.8 Useful Matrix ProPerties
C:
6+3i 7+3il Some of the useful properties of matrices are given
l2+ i 13+ it) belorv for ready reference.
I : tI: lTr-Y)
t"tt"" o -
I - yr-n
l'''r- ;-] i) : " , ii
JopIsuoc o
": l!!l- ztrr-),J lz
lztr ly zt') : n,
il'-Y) - '-(f)'tr oldruexo ro.{ 'J : g loqt dyduu 1ou soop 3l v : g y .L
I:YrY:rYY'Zl
lvtr T,tt - rl
sz'e 3'Idwvxa o : -) lz
uli onJl aq 01 u/(oqs st/h sttlJ 'llllso.I eql ocueq "izltrJttz)
l:q l:4 'eldtuexa "rog
{tP (trtg t11Y
3) 3 '0: S ro '0 : l?rl1 ,(1dwr 1ou seop 0 : g y 'g
ud 'z16r ''
;enbs 1ou ,(eu arp 1nW snollgo sr tl
,(q rto,tr8
JepJc cql ul dn poruurns eq osJr rmc sur-rel eql ing
Ezy,ztg+zrvlrg:zrQ
dzgT,ry
+ atg lty, : 7r)
l-rl l:tl
nc ttua| uly uorlelorr lunsn Jno Sursn ueq;
f vg: o sY:3
,(q uc,ttE st
lel pLIE 'soorJlpru Z x Z Japrsrro:r oelduruxa rog
bg) V xlJl€tu.;o /uunJoc pue , oJ ur luaruolo oq.L
^ 'ypJ pnbe 1ou ,(em gy ';nraus8 u1 'g
t:t
fiS ttrtg
d
= -raqro 'crqrssod sr y g lcnpo.rd 'r u
- Jr ;1l, trt.l
[q ue,tl8 st ,€r xrJ]utlt .]o
Jo Joqunu pnbe lsnru f ur sumnloe Jo JoqunN
ulunlos pLtE tt ,ro.r [rr l{tcurole troql .,(1e,lr1ceciso.r tu o't l:7 roJ tlgtttyS: ttC
b yd pue'tI xu otl x w sozrs Jo oq ,3 puu ,g,V p1
pur 'ezls a X/ e^tq lll/t\ U y -, llcql
c@fi: bs)v'tt ',(1c,u1csdse: u x ur ptrtl ttl x / sazrs Jo eq g pLtv y ]e'l'l
)S + 3Y: C@ + Y) e.told ,{ptputrg tt@ + y): @ + y)I ,(1.repurg
tlon< + I(sv)7 'Junlsuoo,(ttn sr -y 3.rcrl1y\'ry V : y 1'1 lty : tty 4 sy 'g
ht7:ttVl + {tgttty!
(t'tc + I'tgl tty 7 J+@ +p'):C acu€H
ttrq tty ! : t!(o V) ;apro ,(nu ut
cln pcruuns cq u?c snrrol su lt7 + (!tg + tty):
rraql J+g:Qts-l gJ + ttg) a fiy : {to + tty: ttg
Jy + trv: (c+s) r .ot ,(q uo,rrE sf
g Jo lucruclc ,(uu uarJ.1
'xrJluru {1r1uopr eql Suraq
J 'ezrc otu?s orll Jo €Ju / pup p/ eJorl,r\ ,y I - I y .6 )+s:olcT
ztC : tz(I
D:)+(s-tY): o+s)+v 'Z
: zry."{ + tty"tn - trlrV flf : ,rI 'sr rlErll 'e^rl?rrossn sr uorllppu XTJIEI J
l^'v t'vl v \'''g "'g' :
: tY Y+O-:O-Y:S+Y:3
i'i, ';j i"; int 't ruoql ,O _: SJI
A\ON 0: ,/ -y .to,g - [ty - {ty : {t3
LteLll'y-: S Jl
,
uo,u,,i'uo'n:n *.Tf r1,,, ,{' lu,,,]r",3
,0:
Jlosttr:Y+0-0+p'
.llnsoJ oql .ccrroH
Z xZ go cJdnrrxc cyclurs u 8urry1 ,{q srrll ,t;1.rc,1 g JI /roN
tt(,g): lttg pu1? Pt(,V) -- t11y sr.l lty 1 ttg - ltg + tty: tt7
tlE : t>t,y {93: !{O : ltg t/JyS: ttC Iuatrrela Kun leqt ees o1 Fsue sr 1y
ttoql 'tY fl: x 't) - ([ 'gY - J loT c:Y+g:s+Y
'esodsuurl solouop
/ oJorl,{r ty fl : t@ V),g 'sr l?ql 'oAJl€lnutuoc sr uortlpp" xlJlEhl'l
LE SNOIIVU:IdO XIUIVW A'IiITIIS
MATRIX OPERATIONS ON THE COMPUTER
2xll 2 I I t2x2
4 l: Il:x:2xal-l:*3
12x2 lt
t: 4l
8. Divide all the elements of row I by the largest ele-
ment placed on the diagonal, called the piiot ele-
: t)
|: i:',1 :2li 1l-'o
nrent. and get a new matrix
lt 0.5 0.1251
A: l+ 1 2
J. lf k times the elements of any row or column are
added to the corresponding elements of another
l.z84i i
DO 50I : l, Nl 50 CONTINUE
II:I + DTERM : DTERM*A (N, N)
FIND PIVOTELEMENT PRINT 93, DTERM
BIG:O STOP
IROW : I 9t FORMAT (9F5.1)
ICOL : I 92 FORMAT (3F 12.4)
DOlOJ:I,N 93 FORMAT (10X. I2HDETERMINANT
DOIOK:I,N l :. F20.4)
AB : ABSF (A ( J, K)) 96 PRINT 97
IF (BIG - AB) 2. 10. l0 97 FORMAT (10X. I3HDETERMTNANT:0)
2 BIG:AB END
IROW : J Data Card
ICOL : K
2.0 1.0 4.0 1.0 4.0 8.0 4.0 8.0 2.0
10 CONTINUE
IF (IROW - I) 2t,21. tt 4.7 Useful properties of determinants
C EXCHANGE ROW IROW WITH I, l.lf 2 rows or columns of a matrix are interchanged,
c MULTIPLY DTERM BY - I the value of the determinant changes in sign only.
1I DTERM .:-DTERM 2. Multiplication of a row or column of a determinant
DO20J:I,N by a constant k, increases the value ofthe determinant
by a factor k.
TEMP: A(t, J)
A (r. J) : A (rROW, J) 3. The value of the determinant remains unchanged
20 A(IROW,J) :TEMP if k times the elements of a row or column are added
2r rF (ICOL I) 31, 3r. 22
to the corresponding elements of another row or
- column.
c EXCHANGE COLUMN ICOL WITH I,
4. The determinant of a matrix is the same as that of
c MULTIPLY DTERM BY - 1
its transpose.
22 DTERM:-DTERM
DO30J:I,N 5. The deterrninant of a rnatrix is zero if
i. it has a row or column ol zero elements
TEMP : A (J,I)l
A (J r) : A (J, rCOL)
ii. a row (or column) is a simple multiple of any
other row (or column)
30 A (J, ICOL) == TEMP iii. 2 or more rows (or columns) are linearly depen-
31 DTERM : DTERM':A O, I) dent satisfying the relations
IF (A (r, t)) 32,96, 32 c{r+c,r"*c.rr,r*.. :0
32 RArIO : l./A (r. D krlL+k,1"+k.Jlj+ -. :0
DO40K:II,N lvhere symbols r and / stand for rows and cohlmns
DIVTDE ROW ELEMENTS BY PIVOT respectively and c and k are any constants.
A (r.K) : A (I,K)':. RATIO 6. The determinant of ttie proJuct of metrices equals
ELIMTNATE COLUMN ELEMENTS the product of the d:terminants of those matrices,
DO40J:II,N i.e.
TERM:A (J.l)',A (r,K) lABi lAl lBl
A(J.K):A(J,K)-rERM 7. The determinant of the sum ol 2 matrices does no t
DIF :
10000.',ABSF (A (J.K)
- equal the sum of the determinants of those 2 m:.trices.
1 ABSF (TERM) i.e.
IF (DIF) 33,33,40 lA+Bl # lAl + lBl
33 A(J,K):0 Choose simple 2 x 2 matrices and verify the above
40 CONTINUE properties for yourself.
'so.Iaz ctll 'sr ll?ql 'T / oJ satup € sr € aoJ prr? I A\o.r sortrrl
e^"q [rA\ xr.r]r?ru J"ln8u"u] Jaddn oql Jo s^ oJ .re,rol z sr z 'xrJl?r.u E o^ogn crll .Jo srrurnloc
xt
ttr uuql ssol sr prre s,\\oJ^\ou
Iut?J .II 'oJoz-rrou eq IIIA\ sluenrclo oql Jo rrorlnleJ etll plrll o1 8ur1so.ro1ur s1 lf
,urro.; ;u1n8uul.t1
leuoSerp 11e 'u o1 lenbe 4uer Sulluq 'JplnSuts-trorr pclpo sr xr.rll?t-rr
Joddn ol peu.roJsu€Jl 'xl;1eru o.renbs-r tl? Jol .nr.roJ cql uctfl
reln8uur.rl oql ol pocnpeJ puu ,lueJ s1r Jou lueuru.lclop 'oroz lorr sr lrr€rrru.rJolep oql '.rcAc,lroq JI ..reln8rrrs
pellpc sr Jr 'oJez sr xlJl€r.u errnbs r Jo lr.reuttuJolep eLJl Jl
s1r oEuuqc J3r{ltorr qotq^,l, 'suorl?ruJoJsu?Jl .{relueruela o1
pelcelqns sr xuler.u eql 'luzurruJolop er{l Jo cnlu^ eql
'.(pro 1 sr {ur?J otll 'oroz-uou Jo^o1(oq eJB s}ttoulclc
orJl sV 'Z lou st IueJ aq] ocueH 'oJoz o.ru oo1 ,(er11
Surpug .rog sdols eql ,tlsnorlqo 8ur1lrruo '1uer aq1 pu1;
'slrre[rrrrr.relep ;re{l el?nlu^e puE el'Ull ? 11? ,ror etro Jllo
ol pasn oq Jleslr uzc xrJl"ru eql 3ur
" Jo lueuturalep ffurssorc fq scol.rlur-u o.rrnbsZ>(Z u.r.roJ .,{1.ru1rurrs urc c/A
-l"nplo JoJ posn uotlesuepuoc 1u1o.rrd Jo poqlau er;l
ra;nduo3 cql uo uotfuururolaq {uug Z'S ,: o:
'(gL) ttotBurutad peeg
l3 2l 13 ?l '- l? :l
'{u3J .=l? il 2l
., li :l
A\oJ aql slenbc s,{r:n1u IuuJ Lrunlloc ct[] 'lu?uluJelcp
cru {cq1
'-l?
's}uur.uur.lolop Jroql purJ prrr orrnl ? iE uttrlrlot
s1r Surloogn lnorJlrl\ pc8unqo.rolur cq u?o xtrluu-l 1?
orro lno Sursso.ro .{q soor.l1r,lr"u o;nbs 6 x Z ut.loJ ltrou
Jo suruuloo pu? s,roJ crll sV 's,roJ luol.luoclcpur ,(r:tu o16 '[ ]ou sr IrrEJ slr ootreH .o.roz s1l pautJe^ oq
fJreeull Jo Joqrunu rulturrxnur elccrprrr ol Irrl?J Flrsr-lounr luutlt-u.rclop sU 'xrJlnur olnnbs n st strll
^\o-l
pue surunloc luapuedopur ,{peeury Jo .reqrr.rnu ulnur
-rx?ru ol€ctpur 01 )ul?J ulunloc a{il?u eql esn oIA .}J ut 6 s €l
s.rolcal, ,l.roJ Jo srolool urunloc luepuodepur ,,(1.rt:eur1 9 7. 1
Jo Joqurnu runurxuru aq1 slenbe xtJleur e Jo {uBJ ctll
t z' tj
13ql oas o1 ,(see sr 1r 'suorluroprsrroJ o^oqB orll uroJC xr.lllrut I x e E.roprsrroJ
'luapuedep ,,{l.reetrry eJE s;olcol I'k\oJ Jo 'a sl
s.rolcal uu.nlloo s1r 3r 'rrynSurs st xrJlt?ur erlJ 's.rorJlo xrilnur ur,u8 or11 Jo ll.n?.r crJl oorrcH .luniutrrJolop o.roz
-r.ror.r snq sool;lnul o.tnnlts Z X Z cqlJo crro lsncl ltl snrll
Jo uorl€urquoc Jeoull u se pcsse.rdxe eq u€o (uurnloc ro
nor) rolce,l euo .{uu 1urJl serldur ecuepuedep reer.rrJ
'oJez-uou eq lsnur
r-: l? 1l ,-: l: il 0-: lz ;l
t/ aql Jo euo lsual 1e 'e'r (ar '" " '7, 'l : J) o.razlou 's,rolloj sB slul?liluu0l0p
arvry llu cJaq,{\ 0-:tuywl + ....+rU,/+tytl Sur,tcq seculpur 7 X 7 e.rnnbs lueJe.gtp g 1eB em .1no
g1 luapucdop ,(1.reeur1 aq ol pn?s o.n? s.lolcel ,roJ orJf .Z pcsso.lo sr lrunlloc r; '.rc,tc,troq J1 .Jr.n?trrnrJclop sll putl
'o_tcz-trorr oq lsnur /7 lourrllJ ertr 'olonbs lolt st xtJlllnr ue,tr8 oql sv 'peurJcp
0IIl euo 1or.rsr lrrrrrLlrJelcp crJt 'xulnnl Jeqlo ,(rrc JoJ .xr_tltlnr
Jo lseel t? 'c'l '(u '" "'Z'I : .r) o.rez lorr
o,rerrbs n lol polruop sl?,r :lu?rl[u.rc1cp crJl p taldwl2 tr1
cJ" /-Y ll" c.Ieq.{\ 0: u2utl * " " + ")"1 + rct,l
g1luapuedap dJrnsull eq 01 pll?s o.r1? sJolcel rnrrnloc oql 'l
[snz]
's,4Aollol Lezt)
se ecuapnedop Je3tul Jo trorltpuoc otll elt.rt\ u?c e,rr xlr:lnrr.r t x z E "reprslroJ
' ' '?') '1 ) s.lolccn urullloo Jo str{.ullloo ,/ p[n] .saJr.IJtur elclulls eulos
t,["" 'ay 'ry s'Io]ce^ /Y\o-t ro s^'\o'' r// t",^":l'1-]-it::ll
orrl purJ sr rcl .uorlrgr.]p srql pu']siaprrr oJ
'
e rog 'luraue8 rr1 'luepuedcpur ,(1.rr:curl totr oslt.' JJn ''.r. rr"rEr
sJolcal uwnlo3 arll lurll r(3r;en o1 ,(see sr 11 'lueprraclep 'lJ Ulqlr/( lueultu"lelap Stttqstttua,-tlotr 1se3.le;
-ut ,{peauq lou eJB sJolcol ,\\oJ -ro s,ro-l aq} spJo,\\ etJ'l Jo JcpJo erJ} st pcuqap sl xl.llutu 1? Jo llluJ al{J,
€
Jotllo uI 'I ,toJ Jo sr"rorlculu ,tsourl el? [ pu" z s,roJ JtsBUJo uoll]uuao J.s
xlrlulAl B Jo {uBu
s ulrrdvHc
44 MATRIX OPERATIONS ON THE COMPUTER
matrix. 22 DO30J:I.M
NRANK: ll1, whon, at the cnd of elitninatiott, A,I th TEMP:A(J,t)
row is noll-zero, A (J,l) : A (J,l COL)
CINE o.t '€[ '€E (cic) gt
(otr) rvr{xos t6 (nuar) sssv r
@'ztsil rvruuoi z6 -( (x'r) v) gsav,,,'oooot : gIC
(r'sszr) rvwuos I6 lniusr-()'r) v: (x,r) v
)NVUN'e6lNtdd €s (x't) v,,(i't) v: wdar
I - I: )NV}IN z9 W.II: f O'OCI
I\I:I IS SINEhI:ITE NI^IO]O] IIYNIhII'IE 3
€s oI oc orrvx,,()'l)v: (x'r)v
)NVUN IT JOAId AS ldod ACIIAICI c
rt'19'r, '\I:
((w'w) v) gt N.II: X O' OCI
ANNIINOf, 09 (r'r) v/ 'r : orJVU zt
(I,II'I : ) '(N v) ) 'zo JNIUd
'r: f '(f'll) zt'zg'zE ( (t'l) v) gt I€
ANNIINOJ 0n (Irri 'I : ) '(N'I : f '(f')) v)) 'za rNlud
o: (x'r) v gg dhtar : (ror t,f) v 0€
9' XIUM V CO )NYU
Cneprsn 6
Simultaneous Equations
6.1 Introduction Here we have exchanged the colurnns on the left hand
A large number of scientific and engineering problems side. The result is, ,B matrix remains unchanged,
involve the solution of linear sinultaneous equations. while all other elements of matrices A and X change
So rve shall now study important methods that can be their locations.
used on the computer. The above 2 equations are also written in short as
Consider a simple equation. AX:B
2Xr+3Xz:5 where A is a square matrix of coefficients of size 2
X is a column matrix ol 2 rows
This can be written very conveniently in matrix forn as B is a column rnatrix of 2 rows
12 3l i'x,l t5l X is also called the solution vector, as the equations
lx,l are to be solved for the unknowns X, and Xr, rvhich
Multiplication of equation (l) by a factor 2 gives may be looked upon as the components ol the vector
4Xl+6X2:lO X in 2 different directions. Similarly B is called the
constant vector. To save space and labour of lvriting
This in turn can be written in nratrix form as the equations, sometimes. only matrices A and B are
14 6l ix,l ttol u'ritten. Thus for a system of 3 equatiolts we may
write
'rxr)
Note how the X matrix remains unchanged ll,hile the 4,, Ar" Ar"l B'l
4,, A,, A-"1 Brl o[ as
changes in constants are convetriently rcorded in matrix Ar., Ar" A;;l Brl
orm.
Att Arz AB Arn
Consider now 2 simnltaneous equations. Ar,, Ar" A.r, A"o
A,,X,, + 4,, X, B\
A", An Ar,, Aro
Art X, + Arz X, 82 In the second arrangement, the last column of ,4 stands
These equations can be rvritten in matrix forrn as for the constant vector -8, i.e. Ay -- By Azt : Bz,
r,sl ix,i -_ [B,l
fA,' A*J A"n - Bn. The size of .4 here is 3 x 4. Such an
exparrded rnatrix A. that includes the constant vector
lA,, [x.j Lr,J is called an augmented coefficient matrix.
We may now change the order of writing the equations.
The equations are called homogeneous if all the terms
If the second equation is written first, i.e. if the rows of B are zcro. and non-hamogeneous il not.
of equations are exchanged, we get
In this Chapter excepting Art 6.17 we nse the svmbol
Azzl x,)
lA,, A.,) I lB,), rr for number ol urrkno\\'ns ot' equatiorts.
1A.,, l.x,j |r, I
6.2 Simple Equations
Note again horv the X matrix remains unchan_eecl.
while all other elements change their locatious. Exeupr-s 6.1
x3 : B,i[As| Xn - BnlAnn
Substituting this value in equation (2), we get xi :(Bi-Z AiiX;\lAii for i :n - I to I
x, : (8, - A$ Xr\ lAn i:i+lton
DOlOJ:II,N
l0 : suM-A (I,J)*X(J)
suM J 3 2 J
20 x(I) : suM/A(I,D
Note that DO 20 I : NI, 1 could not be used. The
index like I of a DO loop always increases. Hence L
is chosen. As L increases, I decreases.
6.3 Methoils of Solution width or contains a large number of zeros, the effort
can be considerably reduced. Some of the important
A number of methods have been developed for the
methods coming under this category are :
solution of simultaneous equations. They may, how-
ever, be classified under 2 main categories. 1. Method of determinants
2. Gauss elimination method
l. Exact or direct methods 3. Gauss Jordan method
These methods involve a definite number of arithmetic 4. Crout Method
calculations, which are obviously proportional to the 5. Doolittle Method
number of unknowns or equations. At the end, an 6. Cholesky Method (for Symmetric Coefficient Matrix
exact solution is obtained, if one exists, subject to the OnlY)
un-avoidable round-off error during the arithmet]c 7. Matrix Inversion Method
work. If the computer retains more number of signifi' of successive
cant digits during the computation, more accurate Il lterative methods or methods approxi'
mation
results are obtained. The labour involved depends
upon the rnethod used, the number of equations, and These methods start with initial values of the unknowns
the characteristics of the cofficient matrix. If the and go on improving upon them in succcssive cycles
coefficient matrix is symmetric, or has a fixed band of calculations. They may or may not approach the
Q6tlsu-4vh
u lnq 'leuoEerp eql Jo eprs Jaqllo uo sluetuale oJOz ,(q ua,tr8 sr
-uou Jo Jaqrunu eql JoJ spu"ls '4 1oqru,(s ,(q pelouap s,{erre ,{Aou pu? pJo eql uee,^Aloq eouapuodseuoc eql
'qtpln pu"q Jl"H 'a.r loqufs eql ,(q pelouap eq 1! ia'I .v: uv ,l _ ev ,v _ oY ,o: tY,I: ,v,7: tY
'g slenbe 1r 'aJaq i,,'lor ,,{ue ut sJaqunu oJez-uou Jo
requnu runutrxeru eql slueserdel qlpr,{\ pu€g 'srauloc Sur,ruq (9) y ,{u.rre
uoltoq putq lJel puu do1 puuq lq8rr oql ur sllraruolo euorsuaturp-auo ,{\ou ? ut palols eq ,(eLu sluoulale 9 esoql
orez Surureluoc '01 x 0I ezrs Jo xrJluru e.lenbs e s! V .v:r:tv ,l _ tzy'l: zzv '0: trv.l : zrv'z: rrv
lBql eloN ',(1uz;c loJ paJoqunu en Y Jo sutullloc oqJ ere e13uur.r1
o'xzrrooooooo .reddrr eql ur slueluele aql 'perols aq ,(uru ,(pro
(or) ri
e18uer.r1 JOMoI Jo e13uu r.r1 .reddn eq] ur JOqJre sluaul
(o) zz
ox trzz oooooo
-ola 'pa^resuoJ eg o1 sr ,{roueu relnduroc ueq,\4. (q)
(s) sz Y tzgv rooooo
(D 6z 'x o z t 8 z I {o o o o 'poqtou 1uarpu.r8 cte8uftroc Zl'9 pu€ potllotu
(q) zz
ox oo tzrz t ooo ,(1se1oq3 I '01 '9 'poqto{-u }r1o.rJ g'9 'sure.r8o.rd
(s) vt 'x oootzgzl
ux oo NvAJAOI ur pasl.l sr a8erols qng ',(u.t-te leuors
(r) zt oooo tzvz I o -LleuJrp-oml .roxuleu arurrbs t x t u se pe.tols sr
(c) vt 'xoooootzgT,l V 'elqelu^p sr ,(:oureur relnduroo qSnoua uaq6 (e)
Q) 6r 'x oooooorzvl 't!y: ltV
(r) L 'x ooooooo rrz 'prauralo 'a'r 'orJloruru(s sr y xr.rl1?ur luerJUloof, eLll e.ioH
0t68L99Vtal ol
taqwnN S X V
irtl :
tzl: ilxl
,,''Xl iv tI
tl li
uolToubg 'v ) 'x| .o I ;,
xlrlBru IrarJUJoJ puEg t't'9 gXY
'oiez-lrorr eru sluoulala aql qloq 3r ,{1uo tt : suorlunbe g 3o r.ualsfs oql .leplstroJ
op ol pelJnrlsur sr relnduoc eql 'ouop oq ot sr sturel Z xrrlu6 lualJgoo] cgrlaruur,tg" y g'9
go uorlucrldrllnur ? 'aur1 ,(.re,rE 'sluetuele oJez Jo tlot]
: .ropull su o.lts seseJ
-ecr1dr1lnu Surpro,ru ,(q er"ur1 :elndruoc Jo lulrotu€ 1u€c
-gru8rs ones ol elqrssod sr tl tng pa^€s eq louuuc aceds lerrads eq1 'sruurEo.rd luraue8 arlt
Jo suotsron pagrpoLu
(1tq8r1s 1uq Surqlou e.ru ,{aq1 'socl,rluru lerceds qcns roJ
froue141 'auo leraue8 B se lr leerl o1 lnq o3 raqlo ou sr
sue;3ord luarcgo ororu e^Er4 o1 a;grssod ,(1snot,r,qo sr l1
eJeql 'puerl aroJaq pelcrperd aq louu€c sluetuola orez 'luercsi.o alotu urerSo.rd eqt eluu ,{uu 'tlnlocJB o}ul
Jo uorl"Jol orlt usqi1 'xrJ]€lu es.reds polleJ uoql st ualul Jr 'qclq,,rt 'srrtsr.rolJ€ruqc lercads ,(ue s'eq xr.liurrr
lI 'soraz ,(ueu ur?luoJ ,(eur y xrJlelu" luercseoJ eqJ IrrorJutooc eql Jl olue^pu r-n pelcrpe.rd eq ]oLluuc lr
xlrl€tr lualJgaoJ asrudg 7'7'9
i ro 'e.lnluu lulauo8 e Jo sr xlrluru luerJUeoJ orll iurll
'xrJleu luercuaos Jo .{letruiiap u,\1ou) st,il [rorliK pasn oq ]snru sr-uei8o.rd
rlous luqt reelJ sr ll 'Luorll uo pasuq suru-r8ord ;iyA
fr1oruu.,(s oql Jo ualet sr a8elue,tpe Jl 'JI"rl ,(q pe,res
-IUOC dolelap pup scrlsrraloEJBqJ lerceds fue lnoqlr,lt
oq ue3 crleuqlrru ;alnduoc ]Er{} peuorlueu oq ,(eu,r 11
ouo'e'r'xrJJEtu luerJSaoJ 1u.roua8 u o1 elqecrldde
'por{letu lopres ssn"D s€'ouo,{q euo'sporlloru e^oqe eqt,(pn1s lsrq lleqs a111
Z'il'9 pue por{toru s..(1sa1oq3.Z'01'9 'poqtou ssn"D
seJrrfutrAl
lualJgaoJ go sad,{1 g'9
g'9'9 stuerSord 51yg1gOJ ur pcsll sr luaua8uz.ue slql
'@g) a:1o11sary .re3er 'spoqleLu lle Jo ,{;?ruuns e log
eJeq
poqtoLu r.rori€xEl3u't
g: y letrc erenbs3o oZrS : SUotll?nba3o.reqrunu : u
poqlou uorlsrelr lopros ssll€D 'E
V Ke:rc poqlour uorl€r3Jr rqocef ro ssll?D'z
IBUOISUa[uIp auo /r\eu ttl luel'ualeJo lsqunu lElJos : lt1
poqtehtr tuorpurD ale8nluo3 '1
(t <tD y fetrc e;enbs ul lrraualeJo reqrullu utunloc -= 7
y fetrc e;unbs ut ]uetuoJeJo raqunu ,ror : / : er€ uaql Jo Ouros 'senls^ lerllur eql Jo acloqc
aql pue xrrlEur luorculeoc eql Jo scrlstrslJs.lsqc aql
eJeq,r
uo .(lureur spuedap ecueEreruoc Jo oler or{} 'e'r 'peeds
Zl0- l)/-({ Lu eqJ 'a8rea,rp ro a8re,tuoc ,(uure'r 'uorlnlos lcaJroc
-u)-Lrt:
6n sNorrvnoa snogNvr'Inl^rls
MATRIX OPERATTONI ON ITIE COMPTTTER
cluding the diagonal element, in any row. Here, it pondence with the square matrix it is easy to verify
equals 3. Symbolically, h : (w + l)12. that
(a) When there is no shortage of computel memory' ,4 i. the diagonal elements in the square matrix are all
may be stored as a 10 x 10 matrix as'usual taking in the central column in this rectangular matrix
care to see that multiplication by zero elements is ii. the elements in the upper triangle of the square
avoided. This is done in FORTRAN program matrix are all to the right of the central column in
6.14.3 .1 Gauss Seidel method. The non-zeto the rectangular matrix
elements are containedin columns i - h to i * h in iii. the elenrents in the lower tr:iangle of the square
any row i, provided i - i is greater than zero and matrix are all to the left of the central colunn in
i * h is less than t? : number of equations : l0 here' the rectangtrlar matrix
(b) To conserve computer memory' we may store only lv. the elements in a column in square matrix are
the non-zero elements of matrix ,4 truncating it to spread along a ladder in this rectalrgulat matrix
size l0 x 5, as shown columnwise belolv' the rectangular form requires only 50 elentetrts to
Equatiort be stored as against 100 elements of the square one
A B tttntber vi. llorl-zero element in rorv i and columnT of the square
J 5 matrix is located itr row i and colttmn /r in the
rectaugular matrix uhere
2 I 1 (l)
1
k:.i -i*h fori > i
I (2)
I 4 2 19
tc-.i -i+.i fori ) j
T2 6 2 1 34 (3) :
ft half band rvidth : (rr, * l) 12 : 3 here'
t2 4 2 I 32 (4)
Sucir storage is used for unsymmetric band lratri-
l2 6 2 I 34 (s)
ces, i.e. when lr; * Aji dealt with irr FORTRAN
12 4 2 1 22 (6) programs 6.6.3 Gauss method & 6.14 .3 '2 Ganss
l2 8 4 2 29 (7) Seidel rnethod. But the above tnatrix,4 is syn.rmetric
1.4 6 2 I 28 (8) and more saving of conlpllter nlenlory is possible
aa 22 (e) as showu in the next Para.
4 1
as in tlre old 10 x 10
Blanks stand .for non existent elements and may be using the labels of elements
may be shown sche-
,"fUc"O by zero values on the computer' or simply matrix A, the new arrangement
bye-passed- during the arithmetic work. By corres- matically as
under.
elo se^lolul sIqI 'fltun ol lenba sluauralo leuo8urp araq € : ZIQ+ /4) : qlPl/'r Pu€q JlBq: ry
Eur,ruq ruro; rqnEuztrl ;addn aqt ol pecnpeJ sI xIJlEtu t>[ roJ I+I-!:t,{: I
luerclseoo eql pu" erqaSle Iooqcs qStq aqt uI euop !<{ roJ I+t-[:t't: t
sr sE euo fq euo pal€ultull? aJ" salq?u€A uAroulun r+r-f+u(t-t):w
aql '1ro,Lr relndtuoc JoJ luelJsa ,{ra'r sr poqlau slq1, eJeql\ uorltsod q1 at tll pslucol sl xr.Il?lu
xlrlDry ruangffao3 n to asnc p]auat I'9'9 0l x 0l eruubs aql 3o {urunloo pu? ? ^\oJ uI luautela aql
'sluourela Jrerll SulutlJepun ,{q peUBIu ,{1'reelc e-I€ s,!\or
poqlol^l uollBulttrllfl ssnE9 9'9
3r{I 'llloruala snollllcg ? .loJ spu€ls x o^oq" eql uI
'ar0g
peluasard st ruer8ord NVUIUOI ou puu perno^"J lou
)cxz rTnlz97,t8l7,'
sr poqleu slql 'a^lllqlqo.rd eq plno^\ ralndruoc eql uo eq lll^ stuourole Sl lxart eql .{1.re1rutt5
peunsuoJ awrl eql sV 'suotsl^Ip puu suolleslldllptu
g/ou lnoqe sa^lo^ur aJoJe.Ieql uollnlos srll '9'7 1rV
l7,9iz?tz9IT,rlIZ
oq lll^\ v Jo slueuale
ur uaes s€ 'lueuttu.tolap red slloISIAlp pue suotlecrld
-r11nur g/*a luoqu 'tl aErel ro3'e.ttnboJ plno,l.r stqt 'o1q3 9I tsrg oql snql '.leqlolle .leu? .,!{oJ 3uo sluQlll
'slusululJalap I + t, Jo -ale aql Eur1e1 (0€) V .{ene leuotsuaurp-ouo € ul
Jo poqletu luorcrJe aq1 3u1sn eloqe (c) ered go ruro3 ruln8u€lca.t oql Jo sltlsluolo
uorlunl€Ae eq] sernbe.t snql suoll"nba u 3o rlolllllos aq1,
0g eqi eJols ol luarus^uoc punoJ sI lr salulleuos (p)
!.tY a?.V rrY
'poql3Lu l3pr3s
$v zzv rz7, : o
tttv zly tty ssneD tE'il'9 pu€ 'poqleu s.,(1sa1oq3 E'0t'9
'poqleu ssn€D v'g'g suerEord NVUIIIIOJ uI
e.lel{,t posn sr sacrJler.u pueq cularuur,(s .ro3 luaruaStte.lle stql
*A zX.- a :lx / > iroJ I+[-!:f'{:I
,dg atv ttv -tv.- tg rty !<t toJ I+./-!'-f 't:t
Iu:V l|Ity tzv tg
zg EaY taY tzv zg tzY, l"ov oov og eJOq,\\ xrrlEu rulnBuelcoJ erll uI
Ig arY rtY *tY tg ,tY lr,ty "tV tg r utunloc pue 1 .\\oJ uI pel€col sI xlJleur artubs
arll Jo / urunloo pue , ,\\oJ uI luoutale oJoz-uou ',,rI
leE e,$
*g t.at:tV * z;7zty I lyttV xrJlerrr a.rBnbs eql Jo sluoluale gg1 lsulu8e
t:ytzy * txt"y su pe.rols oq ol slrlotuala gg .(1uo sartnbol tuJoJ slql 'lll
"g
tg "X"ry + txtty
t::ytry * Jopp?l e ur ,hou
"Xrty +
eJe xrJleru erunbs aq] uI rlrunloc ? uI sluoulelo ill 'Jl
JOJ
zz-. tz,, I
xuleru relnSurlcar srql ur uurnloc lsJU eql ur
cr arsq'\\ lle e.r" xrJleru erznbs eql ur sluoruale luuo8erp aql '1
",; "'rl: leql ,{3rra,r
ol ,(sea sI JI xIJlBLu erenbs eq}
o 0 r{lr,r\ ecuapuodsauoc .(g '{Jo,t\ crloluqlJJ€ aIIl Sulrnp
?"X <- IX
- pessud-a,{q ,(ldrurs ro 'relndruoc aql uo sanlul o;az ,(q
I
I peceldar eq,(eru pu? slueuala snortllcg JoJ puuls slu?lg
l"g '"Y l"'v "g
l's "vl l"', 'g I
OI I'OI OI.OI
1eE e,r '"g:"X""V + 'X'"y ptre rg:dyzty' 4 tyrtyr 6 t6 z6 l6 0I'6 66
JOJ 8 €8 Z8 I8 0r'8 68 88
TL 7L IL 6L 8L LL
'^\oloq uanr8 ere
9 E9 Z9 t9 89 L9 99
suollenbe snoauellnrurs g puu 7 3o surals,(s -IoJ suoll ts 7,9 IS L9 9S ss
-nlos aql 'urqa8le a8elloc Jo txel ,{.re,ta nt p31ap uI
I
v t, zv w 9V sn nv
paureldxo sr pue elnJ s.JeIu?JJ uo pa$q sI poqleu sIqI c cc
Eg T.T Ig s€ bE
sluuulurala(I Jo poqlal^I 9'9 z EZ ZZ IZ nz tz zz
'poqleur I TI ZI II €I ZI II
tvoY salqDl $aN slaqpl plo
Iepres ssn?D V't'rl'9 ure.rEord NVUIUOI uI pesn sI
xrJl"ru lueJclseos pu"q clJleluru,{s ro3 luauraEuule srqa y t^aN vno
s Norrvnba snolNvrrnnus
I9
52 MATRTx oPERATIoNS ON THE COMPUTER
mentary transformatious on the coefficient rratrix '4 stitntion explairred irr Example 6.3 gives the values of
and the constant vector B exactly as those in Example the other unktrowtts as Yl - I arrd X.r : l.
3,9. However, to improve accuracy on the computer, On the hletltod
the largest element is found and brought in the iead-
ing or pivot position before the eliminatiorr of ele- l. This is a verv heavily used rnethod.
ments is done in any column. After the upper tri- 2. lt involves
angular form is obtained, the unknorvns are determined r divisions
as done in Example 6.3 above. rf + n' - tr rrrultiplications
$
ExlMprE 6.4 tr" + n" - &n algebraicadditions
Solve the following equations by Gauss elirnination 3. According to Klyuyev and Kokovkin-Scherbak (28).
method. no direct nrethod for a fLrlly populated (populatiorr
AXB means the nurnbet' of non-zero eletrrenis irr a nlatrix)
3 rl fx,l lr3l
n.ratrix requires less operations thatr Gauss elinrina-
2
1
3l
<l
lx"l
lr,-l lttl
ir+i tiorr. According to Bet'kett and Hurl (44). Gauss
elinrination is found superior to iteratiorr lllethods
l1 : r) L^,tJ lLLj
even for r -- 500.
l. The largest elenrent in A is 5 ; heuce, bring it irr the
leading position by exchanging row 3 with rorv I arrd 4. Forsytlrc G. E. and Moler C. B. (53), has given etli-
column I with column 3. The rrew arrangenlent cieut conlplrter programs in ALCOL, FORTRAN,
appears as irnd PLll for solving simultaneotts eqtrations or
obtzrinirrg a rnatrix inverse by the Gattss method.
15 2 3l rx.,l t22\
5. Iftlre solution of the system of equations exists i.e.
l.r 3 4) txi) |.r: j il the augmeuted nratrix is non-sir.lgular, Gauss
Note how the vectors X and B change. nlethod always works though other methods rtray
lail.
2. Following the procedure ol Exarnple 3.9. rrake
Ar, : 1, Azt: Aa, - 0. The result is 6. For lar-ee systenrs the solution may rtot be exact.
lnsuch cases, the solution rnay be improved as
2ls *4tsl
lt 4ls 3/sl [x,l 122ts) explained irr Art. 6.19.
lo lx"l - l4rsl
f.o t3ts tTts) txi) l+:,sJ 7. Z,ero elenrerrts irr a spar;e uratrix rnay gct replaced
by norl-zero elements dr-rriug eliinination. Hence
3. In rows 2 and 3, element An : l7/5 is the biggest; this rnethod may not be very efficient lor sparse
hence bring it in the leading position i.e. in place
nrat rices.
of A* by exchanging row 2 u,ith row 3 and colurnn
2 with colr.rmn 3. The arrangement now appears 3. Read also Booth (46), Faddeelc (52), Forsythe and
as Moler (.53), Fox (55), Lartc'e (66). McCrqcken and
Dorn (71), l4/estlake (86).
1'l 3ls 215r,
i0 tTls t3'si {xrl
ix,I
l22lsl
I43lsI Some points about the program
f0 ^4ls 4ts ) ix,l I 4ts J l. // : 3 stands lor the order ol the square coefficient
Note the clrarrge in the X vector'. nalrix A.
4. Following the procedr"rre of Exarnple 3.9 ntake A pt =1, 2. The prograrn rrses the 2-dimer.rsiorral array A for
A", : O.The restrlt is the augmented matrix of the syslem ol 3 equations,
I 3ls 2/5.l [X, ] 2rls the constant vector being accommodated in the
lo ar' 24t17)
f
rr/r7i lx, i i I
l+:lr;l (N+l)th. i.e. 4th column of l.
i.0 ix,j i48ir7j 3. Elimination is done (N- l) times.
5. Division of row 3 by ,{,,, gives finally the matrices as
4. Every tirne elirninatiorr is done, the largest element is
it 3/s zls) lX,,'l (221s l brought in the pivot position first. Row charrge matters
io t t3lti i, x, i a I l+z1n I little, but column change indicates modification of
i.oorji&JL2] the column vector X. So track of column changes
Matrix I now is reduced to upper triangular form. is recorded in array JCOL. To start rvith, we set,
Bs - 2 gives value of Xr. The method ol back sub- JCOL (l) : l, JCOL (2') : 2. JCOL (3) = 3, as
(x'D v *(I'f) I lugr
v: €:N
N .II: f OS O(I (e) rocr'(g) I'(e) x'(t'€) v NoISNanICI
OrM *$'D (>'D V
V: XIUIVhI J
JOAId AS I A\OU ACIIAICI
rNilrJlctaoc auvnbs :ISVJlvugNac J
NN
.II: ) OS OCI
SSII(NhINTOJ IIJVNIhI I'I:T
COHIAI^I 3
ssnvo sNolrvnba snoaNvJ'rnwts f,
0'r) v/'r : orrvu
zv '96'zb 0 'D v) sl
I'9'9 INVI{COUd J
(N 't : r'ft) rocr)'E6 JNtud 'uorletrnurla Suunp
(N 'I :) '(NN 'I : f '(f ')) v))'zo rNlud w Fpue.rlu ouop sr slr{1 s€ ,,irou ,(;essaceu lou sr lt' ,(q cprs
(roor)'ro)r puuq tq3u Jo uolsl^rq '!I JoJ uorsse;dxa eql aloN
r:
(tocr)'roJr: (D tocr tuotl*!-[
0)'roJr -'- r lotl-u: ! ty!!yl-I+u',y:!f,
,lol ,uyll -l tt .tty : uf,
dhlgr - (tocI 't) v
(roct 'r) y : (t'r) v sl €'9 elduexg
(t'r)v: dI\tar Jo seurl erll uo X Jolcs^ uotlnlos .ro.J ruq1uo31e eql',
N.T: f O?OCI zt. 'a8essaru B r{ons
I HII.,!\ 'IOJI NI In'IOf, IISNVHJXA slur.rd ;aludruoceql pu€ spBJ poqlau aql {1snor,t
zE'tv'ft (r- roct) sl Ig -qo 'oroz eq o1 snoddeq lueruelo 1o,,ud eql esec u['9
dwar : (t'ltout) v 0€
'oJez ol a13ueu1
(r 'mour) v : ft'D v
ro,4{ol aql ur slueuol oql les o1 ,(ressaceuull sr ]J
(r't) v : dl\r:Ir
NN'I: f Og O(I tz I*loll+l-rll tttV t[y tt[V :
uol 1* t:!'l 't{V 0!)
I HII,Ail A\OUI A\OU ACNVHf,X:I 'l-r/ol t-l -
jroJ !!Vll!V - tly Mor 1orr4 (r)
rrrout) gl
tz'tt 'tE (t -
sr Lrorlturutla JoJ p€sn ruq1ro81e eql 'g
AONIJ-NOf,
) : -IOf,I '? ;o enl"^ ar{l se,trE ,{1pn1ce
f .: aoul 'Z : ,X'Z: Q).IOJI ruo4.,(pepuu5 .uels.(s eqlJo
€,y
SV: DIS ;o an1ul aqil senr8 .(11en1ce 't: rX 'g : (t) TOJf
oz'oz'z (sv-cts) gl sV '-IO)f .'{e.lre ur pepJoceJ se peEueqcralul eJ?
slueruolo Jolcen eql lng .t: rX pua (l : ,X,Z: rX
(v'r) v) gsav: sv 'se,rr8 uorlnlttsqns IoEg ueql 7 go eceld ur sr X leql
N'I: )0ZO(I erunssv ',11 rolce,r Sursn 1noq1^\ poulelqo eq osl€ pFoc
N'I:fozoc rrortlllos snll ter{l llr^\ tqEnoql olllll V .? pue
O: DIS "X
nX ul"lqo o^\^\oqs .; pu" ,4 ueo,{\leq ocuepuodserroc
I : -IOf,I ,(q ueql 'rapro .,{.ra,r slql ul 'E : tI pue .l : zA
'Z : *.tr, sanr8 uaq] suorlenba rzpr8uerrl
Jo uorlnlos arll
I: A\OUI
TNAhIA]!I JOAId CNIJ i-z I
lol f"l l'',rl
I+I:II lil i'x i i',r i
IN.I: I09OCT lEl l"x) i'/ j
l: 0)'rof,f or 'e'l'x
N.I:IOIO(I .rolcel pegrporu slql ol lr alenba puu I JoIOeA B
(N 'I: I '(NN't: f '(f 'D v)) .26 J_NIud e1e1'oro;araql e71\'7, : G) TOf,f pue'l : (Z) fOOf
(N 'I : I'(Ntt 'I : f '(f 'D v) ) .to cvEu 'E : (l) fOJf se popJocer sl slr{J .z; puu
I+ N: NN
"X ',X s" sl X Jolcel urunloo eql qcrqa ur suorlenbe
Jo ruJoJ reynEuelry aql utslqo e*t 'JaAo sr >lJo,u uoll
I-N: IN -sururle uorld\ '? pue "X "X 'a.I'!X ;o repro red
es sNolrvnoa snorNyrrnx[s
5d MATRD( OPMATION; ON THB COMPUTER
3. Shifting the biggest element A* in location lrr, 4. Elimination operation is done on all the n collrmns,
we get r times.
ill0 2ls 3/5 I {x"l (22ts) 5. The algorithm or formula for eliminatin is
t3ts tTtsl i x"l | +ttsl
i. : Ai*lAii for i : I to n
[o 4:ls - +1s) [x,) | +1s) Pivot row Aik
: l, Ap : As2 :0, and get ii. Aitc : Ajt, aii Ai* i : I to n except i
4. Operate so that Azz , - k:jf lton-+l
0 1/l3l ( 40t13 ) ,
l'1
i0 t 17il31 rx,llx"l 6. It is unnecessary to set elements equal to zero or
i +t1rz
foo-24:113)lx,) unity. Operations pertaining to such elements are
I
i-241t3)
therefore omitted on the computer as usual.
5. Operate so that Azs : l, As : A2;1 :0, and get
finally the solution 7. Elements of the unknown X vector are then found by
with the values of terms of JCOL
3l ti:l
correspondence
tl 0 as in the Gauss method. For
lo r
rl f;l :1, hence X (l) : A (3,4).
JCOL (3)
example,
array R. Thus R, : Cr, R, : Crz, R3 : C13. 81 15. The algorithms for the procedure may now be
is also read. written as below.
2 Divide this row by diagonal element. (i) Elimination in column i - I below
,R1 :
R1/R1. This division may be omitted on the
Bi :Bi-BiRi for l-i:ltorr
compttter. R*:R*-Rih i.l:ltoi-l
R2 : fi2/R1' Ra : R3/R1' Br : BrlRa. t :(j- 1)n-(i- l)i+k>0 lk :i * Lton
(ii) Pivot row
3. As no more operatiotts are necessary on this rorv,
store the useful elements of R, i.e. R, and Rr in Bi : BilRi for i:lton
l, and l"
locations resPectivelY. R* : RrlRi for ri:1lon-l
l.t:i+ttor
Second cycle I :2
(iii) Elimination in columrl i above
4. The second row of C is read and tempcrarily stored
in ,R. Thus R, -' Czt, Rz : Crz, Rs -- Cr"' B, is Bi: Bi-Bi Atn. m :(i - l) u - (i - l)i +
also read. li:2ton
for I
Values of Constants
4t DO 50 J : l,Il J
JI:J-I JI
JJ:J+I JJ
JN : JI';'N JN
IJ:I"J IJ
11 J : IIl.J IIJ
DO50K:II,N K
JK==JN+K JK
KR:JK-IIJ KR
KL:JK-IJ KL
s0 A(KL):A(KR)
5I NK : N"Il - Ii'I NK
DO60K:II.N K
KN:NK+K KN
60 A(KN):R(K)
6l PRINT 2, (A (K), K : l, KN), (B (K),
I K : 1, I)
70 CONTiNUE
1 FORMAT (5F5.0)
2 FORMAT (8F10.4)
END
2. Divide remaining elements of lst row by Ar :2' 4. Pivoting operation (as used in Gauss method) is
and get necessary for achieving accuracy.
6. Replace finally the last element in 3rd row by equations is given below.
and example of an inverse matrix. For a given matrix Then change in X; is E. Pi. So
A, lhe inverse matrix ,4-r is such that A A-r : I,
where 1 is the identity matrix.
xr:0+0.3360x4:1.3442
Xr:0+0.3360x5:1.6803
Consider a system of simultaneous equations,
Change in R7 :
AX:B - E' 0t Hence
l'4
- 0.3360x l3lI l'-0.3668'\ I
Then, pre-rnultiplying both thc sides by .4-1, we have ^
P:- I
ls - o. 3360 xta) -|
.- I
o. zs-soj
A-rAX : A-18 or IX: X :A-tB
F:E Rr Qi : -0.3368 x l3+0.2950x 14: -0. 6384
Thus, the solution of the system can be obtaine<l by G : - FID : 0.63841122:0.005233
using the inverse of the coefficient matril, rvhich must
be evaluated first. Il the inverse cloes not exist, the New P7 : R; + G. (existing value of P;)
solution cantrot be obtained by this method. in that r'-0.3668+0.005233x4.]: r-0.3470)
case, it is quite probable that solutiotr too dtles trot
:
exist.
Hence P
i 0.2e-i0 -t 0.00s233 x 5J t 0. 3220 j
Second cycle
The methods for finding att inl'et'se ale siveu in the
above. We get
3. Repeat all the steps of the first cycle
next Chapter.
r2
| 1l! i-0.34701 l:l r-0.37181
This methocl has att edge ovcr othet's irl tirat wc cltll v-
n:
lr z.t I I
o:zzoJ o.zwsJ I I
although, rvith more effort ot.t the conrptttcr. Finding D: - 0.3470 (-0.3718)+0.3220 (0.297s) =0.2249
an inverse involves arithmetic work equivalent to solrt- E: 0.223110.2249 :0.9918
tion of three systerns of cquations. Hetrce this methoil .t, : I .3442 + 0.9918 (-0. 3470) : 0.9999
will be efficierrt only il rnore than three sets ol equa-
Xz: + 1.6803 0.9918 rc.322A) : L999
tions, having the sarre coefficient tnatrix but different
constant vectors, are to be solved. The solutiorr R-F:6':P:O
of such multiple sets is lurthcr dealt with in Art. On the Method
6.16.
l. The method uses a simple algorilhm citsy to program
Read Pipes 177). on thc comDttter.
6.12 Conjugate Gradient Nlethodfor Symmetric Coelfi- 2. Tiris is a semi-ilerative proccdurc. It rna-v be classi-
cient Mahix fied either as direct or inclirect. i.c. iterative. If the
We illustrate the mcthod by a truttrericitl cratnpie. round-ofl crror is absurt, thecrretioally, it should give
exact solution in a tnaxiirtttm of z iterittiotrs.
Exlupru 6.6
3. The method as presented abtx'e applies to a
Solve the systcm of 2 equations :
iymmetric matrix. It can however be rnodified to
AX B handle any arbitrary coefficient matrix. See Ralslon
12 rl fx,l i4l
antl Wilf (8O), lVesrlalre (86).
r 2)
f |.,r,; ls j 4. The arithmetic work required is six times that in
Steps :
thc eflicient elimination method. Storage require-
msnt is also high. It is not therefore favotued.
(4\
tt is inclucled hcre merely to illustrate horv direct
l. To start with, let P : -R : B :
l.rj '& : x' :o and indirect procedures can be conbined into
First Cycle one.
12 ll Like the other iteration schemes, the coefficient
2.t-et 8:A.P:i, Lr zj"i f4l _ ir3l
-
l5J Lr4J
5.
matrix is kept intact throughout, thus permittirtg
C :>Pi' Ri:4 x 4 + 5x 5 :41 its use in further operations, if necessary.
D :[Pi. Qi:4 x 13 + 5 x 14 :122 6. This method eliminates the effect of round-offeiror.
E : CID :4tlt22 :0.3360 7 Read also Marcas (31').
'srrrslqoJd '9 '(, 't 't 'I 'c
suuaesr?ua ul fJo^rtrJodsal sp?ol pu" strueuec?ldsrp ptos olocl
ol puodseuot g pue X sJolce^ 'sluonloc8ldsrp
Snoauellnwrs Jo poqleu eql sB rr^\ou{ os[B sr slql 'Z cNa
(r'otgr'ou) JYI truoc €
suorlrppB crrrqeSle lt-zu (t'otge) JYI luoc r
suorluclJdrlJnur -u (o'Esq) rvwuoc I
suorsrArp II ANNIINOf, 08
ANNIIINOJ OL
so^Io^ur poqlour srll'I (t) x'(r) a'fu) u'(t) b'f 'e rNlud
Poqlan aat uo
(r) a*onvu + ft) u ft) a :
zx N'l:f 0r()O
t^
gL'e -'x 'gzg'l - cc/sv-:orrYu
'S'0 : f; ocueg 'SL'Z == 'gZ9'l : "A'g'0 : 'A (r) b*(r) u + sv : sv o9z
'sc,uE,4 go suolltnba oql ur X Jo rrorlnlrlsqns : aptc pu7
N.I:fOgOCT
'S'S: t.tr' 'E:"X 'Z- tX aoueH 'g'g : €l
,t - 0: sY
"^,2: rA.0 : t), :"X: r; erunssy :ap{e 7s1 (r) O*onvu
- (r)u : (r)u os
: Japun su a:u sa1c,(o Z lsJU aqlJo slFSoJ aqi uaqf (r)a*orrYu+0)x:0)x
vl(xx*bt):tI ttv t ol
N't:f0soc
tl(X- 'X - Z) : "A purl zI t ri olJ,vu 'cJ'gv'e JNtud
zi("^'-v):rI r0tzi v CIJ/ BV: OIIYU
'xrJluul
(r)b,,ft)d+of : ctJ 0n
palueurSnu aqt t{'q pc;trasarcia.r eq suoriunbo € .lo (t)u',ft)a+BV== sv
urals.,(s aql lal 'uotlrrl()s lul.rg or{t ol .r8ra ruoc N'[: f 0tocl
ol ptes sr sscco.rd uorli?lelt to anr1rl:dal .rqt suaddeq O: CIJ
slql Jt 'sanlB^ ttotllllos [?uU "ro eni] Jlaqt o] asolJ O: BV
,(re,t fre,L qceo:ddu sul\oult{u aql .to sanlE^ poitino (x)a*(x'r)y+fu)b:ft)O
luc eql 'a'l ? Jo sanle^ sql ur e6ueqt olqeecrlou N'I == ) 0E OO
ou sr oJotll lqun Jo sayc,(c -1o Joqr-ullu pexg rrrulleo u JoJ
ureEe pue uru8e pareedJr uoql sr ssaco.rd cq1 .,{ o} o: (r) b
{pol"lnllr:o orp N't:f0to(I
lenbe 1es sr JolJa^ X ,1 ItB JelJv .A .rc
suorlenbo Jo eprs puuq 1q8r.r eql uo ureqr Surlrrlrlsqns N.I-I08OCI
';' go sen1u,,r,
luryur Surtunssu ur slslsuoo por{lotu ogJ SEhIII N IIIYUAJI 3
'uoqenbe,(ue ur ! f !' $qt'e,l : !,t.,2,1 .: I oreq^\ SNNIINOJ OI
0) u '(r) d'I'E rNrdd
lry1(fu ttyI:t3 --rs) : .',{ '^uer.rq Jo (r)a == (r)u
€
t{:yf(z,xzt;y _ rx rEY _ rg) : r,{
ft)a:(Da
O: (DX
"rvl(xr"Y _ rxrzY _ : r^
"g) N.I:IOIOA
trfrl(Xrrr' ,g) : t^
-zxztv - c
1;-I N 'r : r '(r) s 'ru',1Tllf; il?'Tliff
*g: rxt'y+"x"rv+tatr, N't: t '(t) g'(N't : f 'ft'I) v))'t cvgu
g:'X'"y+rx""y*tXwy Z: N
tg: exery+rx"ry+rxlry (s) u '(g) b '(E) a '(e) x'(e '€) v NotsNaI t-Ict J
: suorlenbe Jo los oql JeprsuoJ sNorrvnoa c
9NIA'IOS UOJ INSI(IYUC AIVDNfNOJ J
poqtentr uopBralMoJBf ro ssnsc g[.9 zt'9 I IVUDOUd c
EL s\rorrvoDg srooilNvrlnruIs
74 MATRIX OPERATIONS ON THE COMPUTER
3. SOR, viz. successive overrelaxation is an improved Note that new values of the variables are used in place
version ol this methoC. Read Forsythe and lV'asow of old ones a,r l,soon as they become available. The
(54) for its treatment. above operations constiut€ one cycle at thelend of which
4. The m.'thoJ may nrt alwrys work, i.e. may not we get tr1 : 2, Xz: 2.5, Xs : 2.875 in place of
converge to a solution, even if, it exists. Predo-
zero values. We now repeat this procedure every
time replacing the old values of a variable by a new
minantly diagonal systemi have diagonal elements
(coefficients lr'i associated with unknown variabies one. On the computer old values of variables are
automatically erased or replaced. Within 6 cycles,
Xi) very large as comprred with other coefficients.
we obtain sufficiently accurate results for this example
The method always converges if as shown below.
n n (4i)t_r
Cycle no. xr x2 ,Y3
j:1
.J.
i: I 2.000 2.500 2.875
tfl ) 0.7s0 2.093 2.976
or g i:tton 0.9s3 2.017 2.99s
: r, i+, l+).r
J
ror
i lAi,l 4 0.991 2.003 2.999
For other convergence criterii, see llestlake (86). 5 0.998 2.000 2.999
5. Read also Faddeeva (52), Fox (55), Marcus (31),
6 0.999 2.000 2.999
Varga (40). The actual solution is
6. This method is not as efficient as the Gauss-Seidel Xr: l, Xz: 2, Xs: 3
and hence FORTRAN program is omittted.
On the Method
6.14 Gruss Seidel method
1. The method involves the same amount of arithmetic
6.14.1 General case as Jacobi iteration method.
This is a method of successive approximations. The 2. This is also known as the method of successive dis-
unknown variables are assumed to have zero values, to placements. Vectors X and B correspond to dis-
start with. More and more correct values are then piacements and loads respectively in engineering
obtained in subsequent cycles of repetetive calculations problems.
or ittrations. 3. The method always works for a real symmetrio
positivb definite matrix (For properties, see Cholesky
Exltr.tpt u 6.7
method, Art. 6.10.1.
Solve the equations
4. The method works twice as fast as the Jacobi itera-
zxt+X2 4 tion.
&+4Xr+Xr:12 5. Before starting the iterations, the method requires
Xz+4XB:14
by the Gauss Seidel method. rearrangement of the equations so that diagonal ele-
ments are predominant. Thus in equation 2 above,
The equations may be rewritten as
coefficient of X, must be the largest.
xt: g- xr\12 (l)
6. The number of iterations required fcr solving a given
xz: 02-&-x"Yq (2)
system depends on the coefffrcient matrix and accu-
xt: (14 - x2\14 (3) racy desired.
Or &: (Bi-ZAii X)lAii for i: I ton, j:l to n 1.lt has all the advantages of iterative methods as
except i. mentioned below.
To start with let Xr : Xz: Xs : 0. (i) The round-off errors get automatically corrected
Substituting X, : O in equation (l;, we get XL: 2. in successive cycles.
Substituting Xt:2, Xr :0 in equation (2) we gEt (ii) It is not necessary to store the whole coefficient
Yz: 2'5' matrix. Elements in each row may & read in
Substituting Xr:Z, Xr: 2.5, in equation (3), we or generated on the computer as and when
get X, :2.875. necesxary. This facilitates handling of large
CINA N'[:I0EOA
s
(r' t.{'s II) Jvtrluo:I t6 OI
.I
"- CN 09 OCI
(t'srst) Jvhruoc 7,6 SE'^III Oi NOtIYUg.tI OC
(o'sgzr) Jvwuog I6 o: (Dx or
!INNU-NOJ 09 (r'D v/'r : (il n
':InNIINO:) OE N.I : IOI OC
(t) x 'l '€6
JNtud (N 'I : I '(il g '(N 't - t '(t'l) v)) 'zo rNlud
(r)n*,r{ns:(ilx (N 't .:t '(D '(N't :
s r'(r'l)v))'16 (vgu
gNNIINOJ 0z t:N
(r'r) v *(i) x _-- II (e) n '(E)x'(E) s '(E'e)v NorsNar^rl(
'oz
- nlns (t-l)Irnsgt
II 'tt COHJ:{I^{ -IgCIES J
fi't:f0zoc ssnvt; sxotlvnbs snotNVJToh{ts J
0)s: Hns I'f t'9 wvt{coxd J
dOIS IS
'dool eql Jo lno seoS lorluoc :gOOO')SV
SnNIINOI 0S
rr {JoA\ JeqlJnJ dols o1 palcnJlsur sr ralndruoc aq1 0g 'tE 'ts(r00' -- sv) ct
'gV ul pot€lnunc3? sla8 g1q clo + Bv sv ==
'g161 ol saoE (ep,(c qcue ro3) .t;1 3o senle,t
luuu pu" ltrlrur ueo^\leq ocuo.roJlrp Jo e1rl3^ o]nlosqv
(xY -vx) css\,- - ct(
'VX o] seo8 lX Jo enl?^ ,^raN (r)x:vx
(r) n,l.t\n-s.:
'xv 1,1*
ot saoE e1c,(c eql Jo Suruur8aq aqt le !X Jo enl€A (t) x : xt'
N.I : I OI O{I
'f11un1uena €00' ol lrnba .to
ustlJ ssal eq pFor{s lI 'asuereltrP lelor roJ sPus}s gv 0:tlv
0t 'f:JN0soc
s4tDuau stueuatqs NVYJVon
: Jopun ors r{crr[.ln. '4 '(cr.re lrr palo]s ere slecordrceJ Jteql
s? sluarualsls NvuJ.uoj asupor}ur ,(eru ej\[ 's1uaua1e leuoSerp Iq suorst^{p ,{rteul plo^u ol
e,rtlu8arr ro o,rr;rsod aq ,{r:ur oouarcurp aql 't00' oi oS 'uorltcrldrlpu u€ql aurl alotu sa{el uotsr^I61 'L-
pnbe .ro uuql ssol sr srlgtirsA € : r.r Jo senlu^ otll
'Jolcal lu?lsuoc aql g 'xtrleur ltlolsrl]Ooc sr Y 'Z
ur ecuoJs,grp laot eql'o'! 'I00' ot lenbe Jo u€tll ssol "ql
sr salcdc a^rsseJJns Z Ln lX olql?r-ru^ Krrtr 1o sel][E^ 'suorlenba .Io .ttqrulru oql .toJ spuuls t: u'r.
aql ut aoualr{tp se troos su suor]eJolJ eqr dols ot
"\l wotSo.td aqt urcqo s1ulod auog
lueA\ o1r\ asoddn5 'JeAo eJB (errrec srql ur 91) suolt
-EJalr Jo Joqnrnu po^loll€ eq] oJo.loq p?orslqo sI tloll '(gg) aryryna,y '(gy) o*tol '(t8) ptaq-'S '(09) ltttt puo
-nlos l)a.r-roc su rroos su uorlcluduoo aqi Surddois uotslDy '(1[1tuoq puD ud4ool7)W 'Ot] sncn74'(gg)
(11ecr;eurolnp JoJ cprAo.rd 1ou soop ute.lSord eqa'9 rog '(fS) irosD,ll puo atlt<ktog '\(9 CIMaPpuJ pBeU '8
'utelsds aqt uo purdap IIL\\ Jeqtuilu 'lnoqEnorql lc€lttl sulerrte.I xIJll]tu ua,trE eq1 (rrr)
aql 'ulerSord oql t{r pe,llolls sr se1c,{r 0l Jo ttliiut
'spoglatu uorl€uruni€ Aq perrrelqo
-rx?r.rr v 'uorl€JolrJo Jeq$nu IutJos aql sel€crpur JN 't 3q louu?3 uorlnlos eiaJnsse pu€ luelilJns
'suol1ecr1dr11n[r ur pJSn ueql -ul sllq aBzrols relttdruoc qotr{ln JoJ surets,(s
9L sNoIIvnOa sooaNYr-Innus
MATRIX OPERATIONS ON THE COMPUTER
50 CONTINUE 10 x(I):0
9r FORMAT (6F5.0) C DO ITERATION IO TIMES
92 FORMAT (6F10.4) DO50NC:l'10
93 FORMAT (I10, F10.4) DO30I:r,N
END SA:O
6.14.3.3 Symmetric Hatf Band Coefficient Matrix
SB:O
DO20J:2,KBH
To oonGerve further computer [nemory let the non-
zero elements of the band ccefficient matrix be stored
L:I+J-1
as explained in Art.6.a.3(c). Now,4 is of l0 x 3 IF (L-N) ll,ll,l2
size, containing elements in the upper triangle of the 11 SA:SA+X(L)*A(I,J)
sparse square matrix of 10x10 size. Here ly': number 12 K: I--J + I
of equations : l0 and KBH : half band width : 3 as IF (K) 2A,20,13
before. 13 SB:SB+X(K)*A(K,J)
Consider equation (7) ol Art. 6.4.3. O 20 CONTINUE
x7 : (29 - I Xu - 2Xo - 4 X, - 2 Xs) I 8 xB:B0)-sA-sB
Or, in symbols pertaining to the square matrix x(D :xB*U(D
xr--(8, - A.,u X" - Aro Xu - An A, - Arn Xo)lAn PRINT 93, I, X {I)
:
Due to symmetry, Azr A;z and ,4ro : ,4e r in the 30 CONTINUE
square matrix. But in the rearranged rectangular 50 CONTINUE
form of 10 x 3, Ao, and Au, are found in locations .91 FORMAT (4Fs.0)
Au, and lu, respectively. Similarly elements ,4rr, 9)- FORMAT (4F10.4)
A,,r, Arn are in locations A71, Azz and A* respec-
tively. Hence, referring to the l0 x 3 matrix, the 93 FORMAT (I10, Flo.4)
above equation may be written as END
(a) X,, == (8.,- Au" X, - Au, Xu - A2 X, - A?s Xs)lA.L 6.14.3 .4 Symmetric Half Band Coefficient Matrix
This gives the algorithm for X as Stored as One-Dimensinal Array
Xi : (Bi Xr, Xt)lAit
Suppose, for couvenience, thlt the symmetrjc rectarl-
-2Ar,i
il -2Ai1
foi i lton gular half band coeffi.cient matrix of size 10 x 3 is
- stored as a one-dimensiortal array containing 3C terms,
j:2toh i.e. A(30) as explaineci in Art. 6.4.3 (d). Then the
k:i-i+l providedk>0 program of the previous Art. 6.14.3.3 needs only one
l:i+i-l provided/)n modi{ication concerning the co-relation ol terms of
Excepting these changes the FORTRAN program the 10 X 3 matrix with the corresponding terms ol
lollows the steps ol previous program. the one-dimensional array. This correspondence, too,
was explained in Art. 6.4.3 (d).
C PROGRAM 6,14,3,3
Consider equation (a) of the previous Art 6.14.3.3.
C SIMULTANEOUS EQUATIONS GAUSS
Xz : (&
C SEIDEL METHOD - Ar" X, - Au, Xu ^ An Xu - A7r Xs)lA7r
It is only necessary to locate terms ,453, As2, A?b A7z
C RECTANGTJLAR SYMMETRIC COEFFI-
artd Ar., in the new array A. It is easy to see that they
C CTENT MATRIX OF HALF BAND WIDTH will be the 5x3+3:lSth, 6x3+2:20th,
DTMENSION A (10,3), B (10), X (10), U(r0) 7 x3 + l. -:22nd.7 x3 +2:23rd, and 7 x 3 +3:
N: l0 24th terms ol the array A (30). Hence the above
KBH:3 equation becomes
DOI0I:1,N x, : (8, - Ar"X,
- AroXr- 4pX, - A2lxs)f A22
READ 91, (A (r, J), J - l, KBH), B (l) The terms are underlined just to emphasise that they
PRINT 92, (A([,J,)J : I, KBH), B0) refer to one-dimensional and not a two-dimensional
u(1) : r./A(r,1) array. The neu'algorithm becomes
.Jepun
sE eJe suorlelnJlsc aql sunscJ aql (,
'9 : "X: tX Ul1,n 3u1ru1g .apr8rl8auJo ouoceq osJe v/'r : (D n
4X q sa8ueqc .e.r .a1q6r18eu eruoJeq slenplsal oql 0: fi)x
IIB Irlun peleadar sr elrpecord s^oq€ eql .anlr?A 0) a '(W) y '('r) V ,()) V ,26 JNrud
enll
slr Jo sr
oluurxoldde Jelioq € qcrq^{ enlu^ qseJJ srql (r)
s '(w) v '(r) v .()) v ,16 ctvsu
'lyp snld onl?^ plo st! == ,tX 3o
1ut.n 1nn qse{ or4} l*'I:hl
,{lsnorrgo usrl-L .ttx Jo lrreng;aoc/7y"i : ttxp :
,]- u, eSuuqc aq1 .7y Brrrpuodsarroc
- I+):1
aql Bruiueqc
f,g onz ol oonpeJ puu 7y
U lenprsoJ .ra8.ru1 eq1 pug
r+Hfl)*(r-D:x
'(Z) pue (1) suorlenbc ut ulerll olltltlsqns .qlt/\\ tr€ls N'I:IOIOCI
al '!X sul\ot;Iun oql senlp^
Jo olqBlrns Furwnsse nr
slsrsuoJ oJltpoooJd orJI
.slBllptser pollpJ
ele ry pue ,y ':HB)
OI:-N
(or) n'(or) a'(01) x'(or)v NotsNsr\lra
(z) t-axr+rx-au VUdV'IVNOISNA'\ICI :)
(r) t-rX+txz:ta -JNO SV CI:IUO-LS XIUIVfit JNAIf, J
101
-trr1oJ CNVS l-lvH lrul_Shihl^S 3
'poq]ou lrortexuler eql coHtgw'Iacles 3
^q SSNVD SNIOIJVNDiI SNOSNVITOhIIS )
t :'xz +'x
e:zx+txT, v't'vI'9 hlvucoud J
suorlunbaJo tres aqx o^los .suorlenbe
g .g 3-rdrrvxl Jo Joqulllr a3lu1 u JoJ posuolctrr oq {eu 11 .so1c,{c
uorlerolr Jo JeqLunu eqi JoJ spuEls JN .alojoq sv .,
poqtatr^J uortBxElau s1.g
'srrorlucoJ e,rrlcadsal Jraql ut
pe1 ,t11ce"rrp uaqt erE sluorlralo or{J .pelBlnclB, olE
CTN:I .peaJ
y Keuu ul sluerualo asar{l Jo sreqrunu
lurJes eql
(t'or.{ 'on) s) rvhtuol CA
sr pJt?c erlt o.rolog .p:ec red Aror euo paqcund
z6 c.ru .g
(t'or.Jl) rvnuol xululu tuotcluooc puuq Jl€q eqt Jo slueutola aql
(o'Egl) rvl/\iuot t6 't + HaXx(t-I)
:INNIINOJ 0s ,tq ue,tr8 sr stuJot luuofurp srrli Jo .raq[ultu lerJas
(N 'l : ) '()) x ')) ,f6 rNlud eql 'uorlenbJ r{ll eql ro1 ..,(1snor,rq6 .n ,{erre ur
perols aJe (Ot x Ot azrs 3o) xlJl?ru tuotclgJoJ pueg
(r)n *ax:0)x oe
ItnJ'eql Jo slr.roruole leuo8urp eqt Jo sluco.rdrcer eql .Z
SS__VS-(I)8 :8X
'(oE) ul pJ.rors x ozrs xr.rlaru
ENNIINOf, OZ v € 0I Jo truercueoc
(v)v*(>r)x + ss : BS puuq JIEII a^oqs erll Suraeq sucrlunba 0l :
N Jo
f*HB),r.(t-).t):) uorlnlos eqt roJ s.rstBr tuaulelels NOISNIIIAUC eql .l
el
r r '02 '02 (>r) cr tuotSotd atlt tnoqD slupd aruog
.ouo sltotlaJd aqi go
I+f )f zr sdels aq1 sluol[oJ
(x)vr,(rt)x + -r:
vs : vs rue:3ord NVUIUOJ oql sa8ueqc osoi{t Surldaoxg
f-l-HSX,,(r__D-x lr 'ruu.r3o.rcl eql sr Hg) : qlpr^\ pueq 31eq]: 7
zt'rt 'lt N - ff) dI t + t!(t-!): l
I -f + I : Tf !-+ 4(t-!): b
HS)t 'Z : f 0z ocl !'+UQ'-'D:d
0-gs tt(l papr,rord l-!'+ 1 : 7
O: VS 5r<y pepr,,tord t +. !' -- ! : )t
N'I -IOEOC tt
otz: !'
OI
,I : 3N 09 OCI t
SNNIINOJ OI roJ ty I (tX WZ -'tX dfZ- tg ) : lX
6L sNorrvnba sno:rNvJ'r nnrs
80 MATRIX OPERATIONS ON THE COMPUTER
Cycle Rl R2 Bigger dxk New X11 case the desired solution is obtained in less than l0
No. Rp
iterations, the computer is instructed to STOP.
8. The comment staternents further explain the signi-
1-3-3Rl 1.5 XL:l .5 ficance ol various important steps.
2 0 -1.5 R2 0.75 Xr:9.75
3 0.75 0 R, 0.315 XL:1 .125
C PROGRAM 6.15
4 A R2 0. 19 X2:O ,94
C RELAXATION METHOD
-0.375 DIMENSION A (3,4),.R (3). X (3), U (3), DX (_r)
5 0.19 0 R,
-0.095 xi: I .03
N:3
6 0 --0.09 R2 0.05 x2:0.99
NN=-N+1
7 0.05 0.05 Rl
-0.03 xr:1.0
READ 91, ((A (I,J), i - 1, NN), I.:1, N)
I -0.02 R2 0.01 x2:1.0
J:1, NN), i: t, N)
900-0.01
PRINT 92, ((A (IJ),
DO l0I:l.N
The method can be varied fora large number of eqr-ta- x(r)
tions. Instead of reducing the largest residual to zero,
- 0
DX(l): o
ail or several residuals may be redttced by a
10 ufI): i./A(l,l)
multiplying factor. This procedure is called block relaxa-
tion method. If the factor is larger than is necessary C START RELAXATION
to make the residuals zero. the procedure is callecl DO50NC:1, l0
overvelaxation. But ii the factor is not suliciently big to DO 20I =. l, N
make the residuals zero. the method is called under- 20 R0): -A(I.NN)
relaxation. Another variation is to make use of both DO301:l,N
the overelaxation and r.rnderelaxation techniques in DO30J:l,N
alternate steps in one and the same procedure. The
multiplying factor lies between I and 2, and is chosen
30 RG) : R(t) + X(J)1'A(l,J)
in such a way that the convergence becomes fa,ster. C FIND LARGEST RESIDUAL R (I)
This method may also be used to improve the soh.rtion BTG == O
obtained b-v- the direct methods, DO40I-l,N
For further study read Booth (46), Forsythe and Wasow AR : ABSF (R (I))
(54), Schekl (83\, Stanton (.84) Varga (40)' IF (BIG AR) 31, 40, 40
-
Some points abotft the computer program 3I BIG: AR
IROW : I
l. The progratn is based on the procedure used to
solve the equations above. 40 CONTINTJE
I
0L6tlezziil e
g:exe+rxE ty xrllevr pelueur8nu oqt Jo Iu€J : ,,t
,:uxz,+txr suumloc I + r/
z:"x +rx pue s,{oJ ru Eurteg xrJleur pepeur8ne : ,v
ed,{1 lsrrg Y xl$ern luerclgeor Jo {u"J : t
u <ut : suogonba snoaua&ourotl_uo71 a : w JI .a.l ,erenbs yr
'sourl lolleJEd o,t1
'y xtrlerlu luerclgeoc erll Jo lueurruJelep : V
slugserdor 11 ',{1pcl.tleuoeg 'truelsrsuocur sl .e.l .uor1 x Jolcs^ Jo $ueruele Jo Joqrunu :
-nlos ou suq ure1s,(seq; '0: V ,e : ,t,I : lereH sOJqBuB^ JO JoQrunu :
9:zxz+'xz Z uI suumloc Jo Joqtunu - u
suorlenbe Jo Jeqrrmu : tu
e:zx +tx suorlenbe go ruels^{s eqtr eq
g : X V tef
ed,(r pr1ql
'sJrlsuels"regc perJBA Burssessod,ad,(1
'seul1 Surlcasrelur
euo u€ql OJoru Jo eq ,{eur suorlenba Jeaurl
Jo ure1s.{s y
o,tl1 lueserdar suorlunbe eqa -l : zX : tX uorlnlos
J"IAIJI-uou enbrun sr sJeql '0 : V ,u : ,t: I oJaH suollunbg lualsJsuocuJ puu tnaplsuoJ Ll-g
t:"x+rxz 's ,*Y t,f] pue 's ,-Y -:
Z:ZX+,X ilf)
s3
ed.(1 puoca5
uallrJlr eq feru suorlnlos eql ,sruels.{s o.rl eloqe aql
'dre;1tgre sr ry oJaqa 'I tX '4 : ,X se rog 'snqa .x J o suorllllos lueJegrp aql urelqo ol
- Z:
uellJJtr eq deur uorlnlos eql .suorlnlos Jo ftrugur pegdrlpru-e.rd ueql sl g Jo ur.unloc qoBA .porrrur
u" s€q ure1s.{s a{i ,spJon Jeqlo uI 'rua1s,{s aql -Jelep lsJg s[ r_X xu]Brrr osJeaur eql ,rsldeqc lxeu
sogsp"s ourl oql uo lulod ,(rcire snq; .1 _ edols 3o aII] Jo spoqleu Sursn : sporlleru uorsJe^,ur xrrlel4l 'Z
aug 1qE1e4s oruss eql pu" ouo luose:der suorlenbe o.r,rl
eql 'fgeclrletuoeC .lsJg srll ueql selqurre^ aql lrloq? 'spoqlau reglo ur ouop
IrcJleruJoJur o.tour ,(ue ea,r8 1ou soop uouenba puoces eq u€c suorl€cgtpou reJrlurs .outl € 1ts euo ,suurnloc
eql'0 - V lueurruJolop er{I .u > : : / ereH o,r\l lsel eql 3rrr4e1 peuuo3red oq ol seq rrorlnlrlsqns
I !.1
IcEq 'poql3ur uorleururrle ssneg eql uI .poqloru
v:zxe+Lxe uEpJof eq1 ur ,{11ce.rrp suorllllos lueJJgrp o.r1 eq1 a,lrE
z:zx +rx sotunloc 0.441trsel eql 'f Jo sutunloc orll [e uo ,,{1snoaue1
ad,{1 lsrrg Jn rurs euop ueql are suorlu.rodo uorleururllo eql
u: ut : suotl0nba sttoauaS0tuoq-uo11 (^
tL !
t-
Z I]
'sasec cutceds euros Joprsuoo ,rou sn loT iL ( I IJ :Y
'edd1 srqt Jo uortl.llos euo .r.req .{eru e.n
ls"el 1" eluq surelsds snoaue8oruoq .auo suorlenbe Jo slos o.ri e,\oqe ati] JoJ sllql .€r Jolce^
IIV [Br^tJ]
egl seol poJJeJoJ sl uelsds s Jo 0 : lX iln uorlnlos V luelsuoi orll Jo sanle^ sldrlprur oq] jle oleporuluoJce
ol se pepuedxe os eq feru v xrrtew lrrorclgeoc oql
'selq€tJe^ ro sr.rt\ou{un aql uo
spoqleu oserll uJ : poqlol.rl r.rsprof ssn8g Jo ssnEc.l
lur?Jtrsf,oc JerllJnJ .{ue ssrc.texe ,{lsnora.qo lou saop rtoltr
.seldruexa
-unbe ue qcng .uieis,(s €ql ut suorl€nbe ;eq1o eql lrerll Z ,roleq e,rr8 er11 .srtreis.is
solg"rJe^ ogl Jo drqsuorluler €qt uo iq8rJ e.roru ,ro.rq1 rJJlls <l1 parldde ,(1rsee eq uec spor.Jloru BuroSe:og aq1
lou soop lJ uer{^\ luepunpeJ oq o} pn?s sr uortenbe uV .suorlunba
Jo slas
e1dr11nu su ol pJ.r.taJo.r o.re sruatsds rl;ns .Z :3X
pet"c $ u 'uorlnros ou s"rl rr JI r
'l : rX 'puz er[] ur I I : "X : tX .ruals.{s }sl ogl
s1 11 'e.tour Jo ouo 'uotlnlos e ""r;,ttiil:'T:,".Jj
sessessod rue1s,(s eq1 31
ur 'snqJ x .lolca^ oril Jo suotllllos Jo s]os lueJaJtp
on1 Sur,tr8 snql lrreJogrp sr €r .rolcal luelsuoc oql ]nq
'oJoz-uou sI 8r lolce^ Jo luouele euo lseel le
:eurus orll sr surels,(s oql qloq rrr t/ xrrluru luerclgaoc eql
'tue1s[s snoeueSouroq-uou eq] ur I trie1s.,(s snoeuaiouroq
eqt q oJez sr €r 'snoeueSoruoq-uou Jo snoeue8oruoq Q) 'g:xY pu? (t) 'g:xy
aq ,{eur uro1s,{s oql 'eJoJeq uees ,(peer1" pBrI a.r sV se f 11ecr1oqur,{s ue11l.l,rrt, eq ,(eru sruels,(s oA\l esaql
I8 S NOIIYNbEI sTIoEINvI.In}IIs
82 MATRIX OPERATIONS ON THE COMPUTER
Here r : t' : I < n or m. The system represents one ii. lf r:n,thenn-r variables may be assigned arbi-
and the same line. Two equations are redundant. There trary values, and the remaining r variables deter-
is an infinity of solutions. The system is consistent. mined uniquely.
The solution may be written as X, : k, Xt: 2 - k, Homogerieous systems
where k is arbitrary.
In the above examples of the non-hcmogeneous systems,
Second type if the terms on the right hand side are assumed to be
Xt* Xr:2 zero, we get the homogeneous systems. It is, at once,
apparent that the rank r' of the augmented matrix
Xr + 2Xz: 3
equals, in all cases, the rank r of the coefficient matrix.
2Xr + Xr: 3
Hence all homogeneous systems are consistent. They
Here r : t' : tx. The systern has unique solution have the unique solution all Xi :0, wlrich is trivial.
Xr : X2: 1. It represents three lines intersecting at a Irr addition to this solution, the system may have non-
point. The system is consistent. These results holp trivial solutions if r < n, i.e. if n r cquations are
even if n-m equations arc rednndant.
-
redundant. In that case, n-r variables rnay be
Third type assigned arbitrary values and the other r variables
determined uniquely.
X, + Xr:2
zxr + 2Xr: 6 It is convenient to write the general solution of the
system as made up of a particular solution plus others
Xr + 2X2: 3
obtained by assigning arbitrary values to the n-r varia-
Here r : 2, r' : 3. First two equations lepresent two bles. For example, the solution Xt : 2-k, Xz : k of
parallel lines. The system has no solution, i.e. is the first type of non-homogerleous set of equations,
inconsistent. Xr + Xz : 2 and 2 Xy * 2X2: 4, above may be
Non-homogeneous equations : tn < n ritten as
As nr<n, sufficient information about the unknown 'x.)
l'i
t2)
i I l- r l
io]- " l-tj
k
|
variables is not available and hence they cannot be
|
f tl
of the augmented matrix, then two alternatives exist
i. There is unique solution if r: n, i.e. if the rank
:
tx) - iol
lx'l
l.oj
+k
I^ l.-rj
of the coefficient matrix equals the number of The first part of the solution is the particular solution,
variables. while the other part is a linearly independent vector,
't - N - I I ur"rEord eql uI'su rou{Im N uI 0: I+ZX
suoll?nbe N Eur^los JoJ peJedeJd sI uIeJEoJd oIIL'I 0: tx
wDtSo,td aqt noqD stulod ouros : selrE uelsfs e^og" eqt ur onls^ slql Jo
'Eutlutrd
uorlnlllsqns 'I s" ?JoJ enle^ .{rerlrqru esooqc
aJoJeq ^\oN
sanor Eur3ueqcxe .(q 1r e8uerreor 'uolleredo uo11 lol f?l ol
lol i"l ol
[o or
ir
-?urrurlo Suunp peEuuqc uooq s€q
X Jolcal Jo ropJo JI '9 LoJ l'xj lo o ri
'uonnlos elolduroc egl sr srql '€r xrJl€Iu uunloc pue : suorlenbe snoeueSouroq eql Jeprsuoc
y x1llew Jo spJ?lluo d suunloc lurrd o1 relndruoc 'll u'?lqo oI 'Jolcol uorlnlos luepuodepur ,(peeuty
ern lcnJlsur pu" s,raoJ esegl ur uorilsod luuoEurp euo 'pe11ec sr IEI{1( 'eJoJeJeql 'suq ue1s,(s eqa 'auo ,{q
egl q I- elnlllsqns ,(1duls uoql 'sluoluele oJoz su/(oulun Jo J€qlunu oql u"ql ssel sr F'Jo >lu?J eql 'z
uteluoc w o1 d sA{oJ lel 'urelsr(s }uelsrsuoc s JoC'S 'uorlnlos repcrlred eq1 sl
',{l8utprocce eEessetu eq1 luud ol petronJls slqJ 'Z: zX 'l : tX sarr8 srql '0 : ? tos'I
-q q relnduroc eqa 'luolsrsuocul st ure1s,(s sq1 : s^\olloJ
'seop ll Jl : Y Jo slueruele oJoz Jo /hoJ ? lsureEe g s8 paur€lqo ere ,(eqa 'uorlnlos luraueE e se l1ozrr se
ul sreodde lueruale oJez-uou B Jr )ceqc 'o8"ls slql lV't uorlnlos relncrlred a^Bq sruals,(s qcng ',{11ncggtp aqt
"
ecueq !g or? su^\ou>lun oql epql\ 'Z s\ Y Jo Iu€J oqJ
(sltor go Jsqlunu :) sourll Jo
Jaqrunu pelnber eql euop sr uolte.redo uorleupulle (q) '{u"J eql sr uru8e uorrelrJc eql 'uollnlos anbtun
ou s€q ruels,{s eql l€q1 llnseJ e^oq€ oql I,uo{ JEels
.ro 'slueruele
osl" sl u 'luels(suoc sr ruels'{s eql ecueq llenbe e;e
orez ,{1uo ureluoc/sureluoc v ur s/nor remol eq1 (e)
g pue fz urslueuelooroz Eurureluoc s1r\oJ aq) l"ql eloN
Jaqlre ueqa suorluredo eql dots'€
Iol f?l lo 001
'uolleulurle rlcue eJoJeq uorlsod lond eql ur luoluele l"xl ir I 0l
lzl
lseFErq oql 3ur6ur.rq uort€ulurle Jo poqtoru u€prof lIr ['xJ io 0 r.i
ssn?C eql Surruollog gr uo su IIe^\ s? y uo ep:B,dg'7 sr IFSSJ eqJ 'o: zty''l -*,"y lBql os eleredo og
'eprs .,(q epls g rotoel ',{resssceuun ute8e sr surunloc pue s.\roJ 3o eSueqcxg '7
lu€lsuoc egl pu" v xrlleuJ truercwaoc eql ec?[d'I 0 ol
: Jepun sE {Jo,t rolndruoc rog sdels
Io
I sl.'0 SL'O 0l
eql ur€lqo em eldurexe e^oq€ eq1 rSZ'l 97,'r IJ
Jo uorlnlos eql ruoJg
sI llnsal erlJ
'uorlnlos lereue8 eqtr iueso;deJ Br pu" y Jo E urunloc
ueql i €ey uorlecol ul 0 3o eceld elntllsqns
ul I - .0 : rtv. : tzy ,l : ,ty Teql os eleredg
',(.ressacau sr sutunloc Jo sA\oJ 3o e8ueqcxe ou ocueH
: Jepun 'uorlrsod Surpeal eql ur .,(peerye sr llraurela 1se33lg'1
s? uorl€urlurlo Jo trlnseJ l"uu eql ruo{ peur€lqo oq 'poqlelu ueprol ssn€D erll eIA
,{ysee,{rel u€c uorlnlos eql 'ry lu"lsuoc oql 8ur11rurg ^\olloJ
sdalg
lol fr-l
lel+ fzts) flxl lvlt ,lt zl
vI t"xt, I I 7,1
iri lr )| 4=x
l0 .orj ilx) r r t 8i
sB uallrJA eq osF ,{eur uorlnlos eql'enr}eEeu
: stlorlenbe eql Jo suorlnlos oql IIE pulC
ro e,rrlrsod eq ,(eur ry sy ,
'luBlsuoc ue sr z oJerl,r
6'9 3'IdI{Yxg
ft fol
lr-lI 4+ \zl -.x 'uorlnlos a^oqs oql se,rr8 uorlelndrueur 1q3l1s qltn poqleu
i.o J irj uepJof ssn€O oql 'IJoA\ relnduoc ro3 lueluoluoc
: sE uellrJl\ uaql sr uorlnlos lereua8 eq1 ,(ren sr uorlnlos eql Surlr.rm Jo arnpecold slql
's1es snooueSouoq
l'r :A
I r- -uou pu" snoeusSoruoq eql qloq uI eru?s oql st Jolce^
LO luepuedepur,(lreeuq eql ollqa lles snoeueSouoq eqlJo
saruossq / Jolcsa uorlnlos eq1 ecueH uorlnlos relnc4red egl sI uollnlos oJez eq1 ',{lrupctpzd
'l- :zX'0: rX uorlnlos oql eleq suorlenbo o4.tl eseql eloN 'rrorplos preueE eql Suturrog reqleEot qloq
€8 s Norrvoog snosNYtannls
MATRIX OPERATIONS ON THE COMPUTER
Salvadori (72).Read Lanczos (67), Pipes, (77), Scheid reciprocals of complex numbers.
(83\, Westlake (86) 3. The other statements in the program are similar to
We now attempt to modify the FORTRAN II program those for a real system of equations, and hence need
of Gauss Seidel method and apply it to a complex no explanation.
system. We have seen how the arithmetic operations with C PROGRAM 6.18
complex numbers differ from those of real numbers' C COMPLEX EQUATIONS GAUSS SEIDEL
To take into account these differences, we add a few C METHOD
FORTRAN statements as explained below.
be three complex DIMENSION AR (3,3), AI (3, 3), BR (3),
Let A+iB,C+iD,G+iH
numbers, l, 2 and 3, resPectivelY. I BI (3), XR (3), XI (3); UR (3), UI (3)
PRF (A, B, C, D) :. A* C B*D
1.If G * i iI is the sum of numbers I and 2, we have : -
and H:B+D PIF (A, B, C, D) A* D + B*C
G:A+C
SF(A,B):A'N*2+B**2
2. If G + i H represents subtraction of number ?
DRF (A, B) : A/SF (A, B)
from number l, we have
G:A-C and H:B-D DrF (A, B) : B/SF (A, B)
N:3 -
3. If G * i 11 represents multiplication of number I
READ 91, ((AR (I,J), AI (t, J), J '= I, N),
by number 2, we have
G--AC-BD and H:AD+BC I BR (I), BI (I), I : 1, N)
PRINT 92, ((AR (I,J), AI (I, J), J : 1, N)
4.Tf G * i.FI represents the reciprocal of number 2
BR (I) BI (I), r: 1, N)
we have
G : Cl(Cz + D2) and H : Di(Cz + Dz) DO l0I: I, N
Note that a combination of operations 3 and 4 can be
xR(I):0
used to obtain the division of one number by another'-
xI(I):0
uR (r) : DRF (AR (I,I), AI (I, I)
In the FORTRAN programs for complex systems, opera'
tions 1 and 2 above may be written explicitly as shown' uI (I) -- DrF (AR (I,I), AI (I, I))
For 3 and 4, Arithmetic Statement Functions may be IO CONTINUE
used. For instance, for 3 we may write, DO50NC-1, 10
PRF (A, B, C, D) : Axc-B*D DO30I:I,N
PIF(A, B, C, D) == A'FD+B*C sR - BR (I)
Then, later in the program we may write, sI : BI (I)
G : PRF (A, B, C, D) DO20J:1,N
IF (t -'_ J) ll, 20, 1l
Some poinls about the Prog,rq,n
1. The arrays used are :
ll sR : SR-PRF (XR (J), XI (J), AR (I, J),
AR : the real part of the coeficient matrix I
I AI (I, J)
sr - sI PIF (XR (J), XI (J), AR (I, J), AI
AI == the imaginarY Part of ,4 l (I, J)) -
BR : the real part of the constant vector -B 20 CONTINUE
BI : the imaginarY Part of ,B
xR (I) == PRF (SR, SI, UR (I), UI (D
XR : the real part of the solution vector X
xr (l) : PIF (SR, SI, UR (I) UI (D
XI : the imaginarY Part of X
PRINT 93, I, XR (I), XI (I)
UR : vector for the real parts of the reciprocals of
30 CONTINUE
the diagonal terms of ,4
UI : vector for the imaginary part of the reciprocals 50 CONTINUE
of the diagonal terms of ,4 9r FORMAT (8Fs.0)
2. The meaning of the Arithmetic statement functions 92 FORMAT (8F10.4)
PRF and PIF is as explained above. The others, 93 FORMAT (I10,2F10.4)
viz. SF, DRF, DIF are meant for obaining the END
uorlnlos el€lurxoJdd€ eql 'eJnpacoJd IscllBlu I"Jo^es uo spuedap JoJJo eq1, 'luecgluEtsut eq
-aql"u or{l pu€ Jelndlllot Jo od{l 'xu1€ur }uolcseoc ppogs IJo^a Jalndtuoc uI JoJJe JJo-punoJ egl
eql Jo scrlsrrelo".lerlc eql uo spuedep ,(cernccy ,(lsnor.rqg 'JoJJe Jo-punoJ psll€c 'loJto u? uI
'.{cerncce ps}null Jo sI peulelqo uol}nlos 'cl}aur sllllseJ Jeqrunu € Jo uotleluosorder eleurtxordde
-rIlrJB erJl ur sJorre Jo-prlnoJ ol oncl 'suotle;edo qcns 'a uBr{l ssel s1r8rp ,(q Jeqlunu (uorlelueserder
ctleluqlH€ Jo Joqunu ellug e^lo^ul spoqleu 0s0qJ,'I Ierurcop ) tr8rp - a u? lueserder ol ,{ressecsu
spoqlaw l)a'ttQ
uelgo ,{rel st 1r 'rolndtuoo oql uo 8uq;o,t ueq14
Jorre Jo-punou 'z
',ttoloq ue.tt8 ere
'sa1c,{c a
sllnsor lnJesn ,{\eJ e Je^o.,'roH 'pesn relnduroc ;o ed.{1
eql uo osle sprredep poqloru e jo ,(cuercse eql ]€ql u€ql ssol ur peurelqo sr uorlnlos eqr 3r .{1uo peJoprs
-uoc eq u?c lopros ssn€D 0)rl poqleur o^rl€Jelr uv
uees .{pee.r1e e^Bq e,l,r 'reqtJnC '1ca[qns cqt uo Iooq
'tunoc srqt uo e1qe.re.;erd sr poqleu ssn€D 'spoqletu
,(-rolcnporlul srql Jo edocs eql puo.teq st suoIlBJepIS
-uoc e^oqB arll Jo lq8ll oql uI poqleu I{cEo }o {pn1s y lcorrp Suoruy 'ue'u8 ueoq fpeerye suq poqleur
LIJ?O ur po^lo^ur crleruqluB Jo lunou€ erll Jo €epr
'ourl oror.u .{1tq8l1s se1e1 uV 'par.re.;erd oq ol spoou {ro,tt crloruq}u€ ssel
uorlncexe rue;8o.rd eql .y uo^e poJJoJard eq feu 3ur,r1o,trr por{}oru e 'a1qen1e,n sr olurl .relndruoc sy
relnduoc oql uo tuerSo.rd o1 ,(sue ruqlrro8lu eldrurs y 'I,ro,\\ crlor.ur{lrJ€ otr luuorlrodord sr o[urJ ;e1nduo3
urqtrroSlY'1 .I
lJo^\ ctlotuqllJv
'po^los eq ol ere suorleube .io : slurod 3ur,uo11o.; oql Jo uortuJoprsuoc
se^lo^rrr spot{loru snor.rea eql Jo fpnls e,rrluredruoc y
sles eoLIl lseal le Jl riluo spoqleur rrollnlos lcerp qlr,4A
aledruoc uuc spoqloru uorsJelur xulelAJ 'suorlenbe spoqlotrAl aql uo otoN Y 0z'9
Jo slos eldlqlnur ellos ol ,{ressoceu sr lr sotur} euros .lsol
suorlunbe Jo sles Jo JequnN '9 oq lou 11r,u slr8rp luecgru8rs ecuoq pue lletus nu eJB
'spoqleul ]ceJrp ur d - : H y rue1s.{s oq} ur sluaruolo aq} leq} oloN
elgrssod lou sr slql ')ro,^^ reqylu ,roJ xuleu leur8uo 'e-rnpecord eloqe
eql e,uese.rd o1 ,{.ressaceu sl lr stuoiqo,rd ,{uuru u1 eql 3ur.Lro1yo3 ,(q f;essaceu 3r pelordurr eq uru8e feu
xtJleru luercgooc luur8r.ro.]o uoll€AleseJd g
srrlJ 'uorlrllos relleq e sa,u8 H + x u3r{J ',peurelqo
ll Jolcol Jo uorlnlos oql pup 'ssnuC se qcns 'poqlour
'lueurerrnbsr e8erols eql Surcnpet snql ,{ue ,(q po^los oq ,norr ,(uru suorlenbe ;o urels,ts slgl
eEelue,rpe llnJ ol sseuosJ€ds
oql esrlrln uec 'pueq
Joqlo eq] uo 'spoqleu uorleJolr oql '{ro,r rorlulu Y-_HY
JoJ lnJesn el€ lsql senle^ o.lez-uorr ,{q pecelder te8 e,r suorlenbe lsel o,{{} oserl} ruoJd
la8 ,{zru sluourelo oJez eql rrorlelrrturlo Sulrng '0:g-@ + X) 7 ueql'uorlnlos tcorroc aql srI/ + X
'xrJlpru esreds e pue (xr.rleru oql ur sluerucle oJoz-uorr Jl 'moN '(slenplser Jo rolJe^ 'e'r) .ro1ce,r IenprseJ erll
Jo Joqunu eqt ,tq pernseetu sr uorlelndod) pelelndod pellBc sr y ereq,{\ 'a -g-xy lal scueH 'oJoz
,(11n9 e ueo.A "loq qsrn8urlsrp tou seop poqlsu uorl eq lou IIr^\ eprs pueq lq8lr oql 'aluurxorddu sr ;g sy
-Bunurle ssn€C eql 'elduexe .tog 'xtrturu luercgooc '0 : g X v suorlenbe ue,tr8 eql ur JolcoA slqf
3o edAl I-re,te roj olq€ltns elrnb 1ou sr poqleu ,(.rea.g elnltlsqns
- .7. .rolce^ [rot]lllos elerurxordde eql ur"lqo
pue solorg€ Suro8e.to; eqt ur spor{}oru or{l ,(q urelsfs
xr-Il€tu luorcuJooc ao ed,(1 '7
srrll e^[os 'ruels,{s oq} eq g : X v :a1 'sa\olloJ
'cle 6clleruqlrre 3o ed,(1 'urerSord
3o se pe,rordurr eq ro^o,{{oq ,{uru norlnlos eleurxo.rdde
slql
r{18uol 's,{eue Jo sezrs uo spuedep srqa 'elqrssod su
'eleurrxo.rddu ,(1uo snql sr paurslqo uorlnlos
,(roureru ro e8erols ssol sB errnber plnorls por{}oru oqJ
oql ',(cerncce Jo ssol lrrecgru8rs € sr sJeql 'sruo1s,(s
lueurerrnbe;,'{roruey,1'g e8rel go uorlnlos oql ur pe^lolur suorl"Fcl€J Iecrl
'lo,rJe Jo-punoJ ssol -aruglrJe Jo Joqunu e8rel e ol onp 'ue>1e1 aJ€ suorln?J
ur llnseJ osle suorluJodo 3ur1oa,r6 'rorro Jo-punor -erd 11e usgt\ ualg 'c1e 'relndruoc eql 'xrl1?ru luerc .
ssel sollolur poqlou lnoJC 'srelndwoc ursuec -Seoc eql Jo eJnleu oq] 'suotlenbe jo requnu eql 'pesn
uo l€ql ueos ueaq fpeerle s€q lI 'c1e 'ornpeco-rd poqleu oql s€ qcns 'sro1ce3 I€Je^os uodn spuedop suoJl
'xlrleur lusro -enbe go urels,{s oql Jo uorlnlos aW Jo fcerncce aqa
Jo sllulop 'penlo,rur sJaqr.unu 3o e8uz.r
-SoocJo ed,{1 'crleuqlue Jo lunou" sB qcns s.rolc€J uollnlos aq1
;o ,{cerncry Jo lueueaordut Ol .S
SNOIIVNOA SNOANYI'Iru{IS
88 MATRIX OPERATIONS ON THE COMPUTER
obtaintd can however be improved as explairred 5. To compete with an elimination method, an iterative
in Art.6.19. method must converge or yield solution in less than
2. The given coefficrent matrix does not remain intact $ n steps.
during the computation work. 6. An iterative method is r.rot very useful for solving
3. In general, a sparse matrix does not remain sparse multiple sets of equations.
during the elimination or decomposition procedures 7. Iterative method is best for a sparse sys;tem of
of the direct methods. Hence the sparseness is equations provided rapid convergence is guaranteed.
not fully exploited. The characteristic of sparseness is fully exploited.
4. For real symmetric positive definite coefficient 8. Iterative method is best for a large system whose
matrix, use Cholesky method. coefficients can be generated on the machine as
5. For real symmetric coefficient matrix that is not and when required thus necessitating storage of
positive definite, use Cholesky method with pivoting. one row or a group of rows (in block relaxation)
The program given in Art. 6.l0.1will need modifi- only.
cation for pivoting. This may be done on the lines
of the program for Gauss elimination methods 9. All iterative methods have a simple algorithm
very easy to program.
It should however be noted that the diagonal ele-
ments in the triangular matrices may be complex. 10. For real symmetric positive definite coeftcient
In the alternative, use Doolittle method with matrices use Gauss Seidel method. For largc
sparse matrices arising from partial differential
pivoting, or the most general method of Gauss
equations, special methods like SOR have becn
elimination.
developed.
6. For arbitrary real or complex matrices, use Gauss
Special Cofficient Matrices
elimination method.
To minimize core storage and computer time alwayr
Iterative Methods use the modified procedures that exploit fully the
1. These rnethods do not involve finite number of characteristics of the special matrices.
operations. The iteratjons are to be carried until
an exact solution is obtained. The number of A Note of Cautiotr
iterations necessary depends on the characteristics In general it may be mentioned that Gauss elimination
of the coefficient matrix, and algorithm of the method. always yields a solution, if one exists, even though
2. The round-offerrors resulting from arithmetic opera-
other methods (direct or indirect) may fail. Tbere
tions in one iteration get corrected in the next itera-
is however an exception. When some rows of a
tion. coefficient matrix are almost linearly dependent
(see Art. 6.17), an accurate solutiorr may not be
3. The given coefficient matrix remains intact during obtained, even though it exists. In such cases
the operations. Jordan method is found to be superior.
4. An iterative method cannot be used unless one is For further study read References (26,27,28,32,
sure that it will converge for the coefficient matrix 35, 37, 38, 39, 62, '75, 8l) in addition to those
to be dealt with. already quotedearlier.
ilV 'xlJl€tu /hltuepr us olul flluonbasqns pu? 'euo
repSuelrl reddn luap,unbe u€ olul peuIJoJsuBJl lsJg sI
lir 4] tq : il t?:ti ti i ij f uoql 'rl Jo oprs eqt fq peculd sl f xlrl€rr uorr6 oql
se ezrs aIIIes eql Jo xulBtu ,{llluept u3 poqloltr slql uI
=TgXV
le8 Pu" '1 ltor poqtol i uolluultllllg ssnB9 €'1,
glll'\ E ao"or e8ueqcxe '1srg 'acue11 'rry uotltsod 'osJeAUI enbtun B sI eJoql pue 'orez 1ou
1o,r.ld lsrg eql olur lqSnorq oq 01 spoeu 1l 'lseE sr lueurlrrJolop eql 'xtJ1€tu relnEurs-uou e ro; 'frer1
-3lq eql sl t : '7 xrtlett ua,'r'r8 eql u1 'I
eey lueruale
-uoc eql uc) 'esJeAuI ou sI eJol{l pue 'onz s[ trueuur
sdalg -Jalep oql 'xul€tu reln8uls € JoJ l€ql palou aq plnoqs lI
'suollu:edo eq1 Suunp sa8ueqcrelut urunloc 'ereq uerrrS oJoJeJeql lou arE ruerSord NVUIUOC oqr
puB ir\or Jo Ic€Jl dee>1 o1 sn dleq III/( ry pu€ lx slueur pue uorl€Jlsnllr l€cueullu sll 'esn relnduroc JoJ lualc
-clg 'g pue 7 uo Alsnoeu?llnuIs suotlerado ,{re}ueur -ge ,{ra,r oq 01 punoJ lou sI eJuag pu? {JoA\ I€sllour
-a1aiur-rogred ,{q I/ Jo esJe^ul u? olul paruJoJsu?Jl -qluB snorJoqsl sa^lo^ul sIqI '1uto[pe eq] osle pus
eq ol xrJl"ru ,{1r1uepl eql sr g ]€ql loslno oql 13 e}oN lusuruJalap eql Jo uoll€nl€^e eql se^lo^ul poqleu sHI
lvl : t-Y
*v-
til=ft ti :?l i?="#) tT iii ',{11ucl1oqur,(s'rg'luuurtrrJalop s1r,{q paprnlp xIJ}sIu
TgXY uelr8 aqt ;o lurolpu eqt slenba xIJl€Irr € Jo esJe^ ul oql
,{q ue.tt8; g : X Y poqlatrAtr lutolpy Z'l
suorlenbe 3o rua1s,{s eqt 8ut,r1os frq t-Y ulelqo
uorlElrqruua {uer Jo poqlent 'l
a'Iil14[vxa
poqlau,(>1se1oq3 .g
',lnoleq urJoJ € uI pelueserd poqleu poqlou elllllood 's
^\ou
ssnsD ,(q suorlenbe;o ruels,(s B Jo uollnlos stll Jeptsuoc poqleu lnorc .t
setuuqcrelur qcns Jo eiuecgtu8ts eql pu€lsrepun oI 'Y poqlou uspJof ssnec 'E
xrJl€ru uelt8 leur8rro oql Jo letll ol Sutpuodselroc uroJ
poqleu uorl?ullurlo ssnsc 'z
ur Sutrq o1 se8ueqcrelur /(oJ ol pelcelqns eq o1
eJoJeJeql
" 1l 's€q 'uolleurrurle Jo dels leug eql ur peurulqo poqteu lulolpy'I
sB 'xtt1€ru osJeAuI Sururofpe eq1 'xu]€tu Sururolpe '1r Surpug .Jo spoqleu luelrodurr 8ut,tto11og eql
oql s" ile& se Y xrJ4ew ue,rr8 eql Jo suuntros pu? ,(pn1s lleqs ol[ 'surelqo.rd l€or]etueqt€ur relllo ul
s,rl,oJ Jo u.relled eql se8ueqc 'lene.ttoq 'arnpecord srql parrnber osl€ sJ lI 'suorlenbe snoau€l1nruls Suvrlos ur
'alqlssod s€ llnsoJ € al€Jncc€ se Sutrnsue pu€ roJJo InJesn sr xrJJ€uJ esJo^ul u8 /,Aoq uaes ,(puerle e^€q ed[
Jo-punoJ Snrzrtururur JoJ ouop ere suotleredo uoll 'xrJl?ru € Jo osra^ur eql pu?
-?unurla eJoJeq uorlsod 1o,trd .ro Surpeel eql uI luaruele
euop uoll€culpout ,{1uo eq1
Jequnu e.1o lecordrcal er{l uee^\leq ,(ilrepurrs ogl e}oN
1so38lq aq1 Suuq 01 sr (,
^\ou I r ol r- zlr. I',:rY [s E']
'peJrsap xrJleu osJsAUI i i-:rl'b'se i i i:Y
:0 t) i.z' 719- ) Lr z)
eql otrur paruJoJsueJl sla8 xlrlelu Suturolpe eq] lsql sl 'xrrl€Lu z xz e JoJ snql 'xrrlEru ,{111uepr u€ sr1 oJaqa
'Ar?s ern se '11nser eq1 'g reideq3 '61'9 eldurexg .;o ,I : y r-v : rY Y leql qcns r xrJleur erunbs e
I poqiew Jo ssurl er{} uo 'y pepuedxe 3o lrzd sl 1l JI JoJ ry xrJletu esJelur eql peugep peq e& '7 raldeq3 u1
sB xrJlsru ,{1r1uapr Sururolpe eql uo paleadar ,(1pexe
sre y Jo slAoJ aq1 uo ouop snorleredo i{reluoruele eql uollrnporlul I',
xrJlBtr l eslo^ul
I UsrdVHJ
90 MATRTx opERATToNS ON THE COMPUTER
Note that rows of ,4 and ,B are changed simultaneously. of X; with Yt. Xz corresponds with ).r, but others
The vectors X and f do not need any change. don't. They should also be in exact order as they
Actually multiply A by X, B by Y, and verify that were in the beginning. i.e. as
the value of each row of lX equals that of the XL Y1
corresponding row of BY. x2 Y2
x3 Y3
Now exchange columns I and 3 of ,4, keeping.B un-
changed. This necessitates change in vector X, but To bring B into proper form, it is necessary to ex-
not in L change X, with X". This implies exchange of rows
AXBY or equations of the -BY system. Exchange of row 1
with row 3 of B gives
(4 l 1l !'X" : 3l l'0 1l Yr:
ri ix": 2i
ir 3 2) i0
0
0i Yz: ,31 I {i-3lr -37 -2' Y2 Y1 ,i ix' l'l :
l.r t l.x, rJ l.t
I
o oj Yz- t 5.j =tl : loi"l
-li<l l|x,: 2i
I
|
. r J Y., : 15 lx': 3J
A and Bsoth at A' :1,
r
|
2. Operate simultaneously on -L
suM:A(I,J) DO120J:I,N
JM:J_I SUM:O
IF (J - I) 5, 35, 35 IF (I-J) 101. 102, 102
C ELEMENT LEFT TO DIAGONAL IOI L : J
5 IF (JM) 25,25, 15 69 16 103
C COLUMN2TOI-I IO2 L-I
15 DO 20 K: 1, JM 103 DO 110 K: L N
20 SUM : SUM -- A (I,K)"A (K, J) lF (J-K) 106, 107, 106
c coLUMN I TO I-1 106 AKJ : A (K, J)
2s A(I,J) =.SUM/A(J,J) GOTO 108
GO TO 50 107 AKJ : 1.
C COLUMN I TO N IO8 SUM == SUI{ + A (I, K)*AKJ
35 DO 40 K : I,IM 1IO CONTINUE
40 suM: suM-A(I,K)*A(K,J) A(r,J): SUM
A(I,J) : SUM 120 CONT'INUE
50 CONTINUE PRINT 92, ((A (I. J), J : l, N), I : I, N)
60 CONTINUE END
C FIND Y INVERSE OF L EXAMPLE 3.20
C Y (I,I) :1 7.7 Cholesky method for symmetric matrices
Do 80 I : 2' N Symrnetlic nlatrices can very conveniently be inverted
IN : I - I by using the factorization method of Cholesky. Let
DO 80J : 1,IN the given symmetric rnatrix of order n :3 be
suM:o ln' A* A,r-,
DO7OK:J,IN A: lA* Ar" A""i
IF (K-J) 62. 64, 62 | n," An A"".'
62 AKJ : A (K, J) Steps
GO TO 66
64 AKJ : l. l. Express A as'a product Tt x T where lis anupper
rransPose or r'
66 suM : suM - A (r, K)* AKr :i,"::i];.l,.T"lil.e,lJJ,",t'ul';,X"
7o CONTINUE r
.. 2. Elernents of are stored irr the uppor triangle of ,4
80 A (I, J) : SUM
C FIND X INVERSE OF U EXAMpLE 3.16 3. We now hnd ,{-r frorn L
DO90 I:1,N AsA:TtT, A-r-:(TtT)-r
90 A (I, D : l.iA (f ,l) Frour formula (CD)-r - D-r C-r, we get,
DO l00I: 1, Nl A-t : T-r (f')-'
: I+I
II formula (C)-t __ \C-t)t, we get,
Frorn
DO l00l:II,N A-r: T-r (Z-t;t -_ RR/, where R: I-1
SUM:0 The inyerse of anttppertriangularmatrixisalsoupper
Jl : J - I triangular. Hence R is also upper triangular. If
DO 95 K : I, J I R is found, A-r can be determined.
95 suM : suM - A (I, K)*A (K, J) 4. As R : T-r, R r : I where 1 is an identity matrix.
100 A (1, J) : SUM * A rJ' J) I* expa'ded forrn, we can write this as
C FORM X Y EXAMPLE 3.22Y (I,I) : I
c TRIANGUL;R [5" fr:: f;:l i?' T:, i;:l
x uppER y LowBR il[o o? lJ
3]
: N
DO l2o r l, ro o-- R;;j l.o o- r;j
I+I:II 'osl" I'0I'9 'l.rv uI po{reluer dpearp
IN.I:IO'O(I s" Ierluesso sr Eutlo.lrd secul?ru ctrlaurw.fs Joglo Jod
'.{cerncce Euunsue JoJ pepoou lou oJ" suotluredo
XruIVW IUAANI 3
: Eu4olrd secrJl?tu elugop e,rtlrsod crrtraruufs Jod'€
(N 'I - I '(N 'I f '(f 'D v))'z6 rNIlId 'elq"lrns
ANNIINO3 OI punoJ oq .,(eur poqleur u€pJof sos?c qcns ut isrelnd
dI Igr : fi'D v -ruoc eluos uo elull onpun elunsuoc ,{eur qctqlr loor
(wns)grubs/'I : dltgr 8 erenbs Jo uorlceJlxe sa^[o^ur Je^eaoq pog]eru eg.I.'U
OI OI OD q,{r1ourur,(s Jo uaI€l sr e8elue,,lpe sB JI€q o} pecnpeJ sl
dI ItIxl\iOS : U't) V L uJo.l[ orleuq]u€ eql 'soolJl€tu culeruur,{s Jo asJeAuI
L 8 Lft-r)gt 9 xe Surpug JoJ oJnpocord lnetcge tsour eql sl slq;,'I
0'x)v*(t'))v-wns - IIns s poqpw aw uo
NI .I:)gO(I V '.(ressaceu sI ouolu f
r'g'g (t - I) sl flrteur Surrols ro; ,{roureru snqa '4y uo {!g pue
' fu'r)v: wns .fu sluaurele uo uolllJl'r-relo eq usc fy sluourele
N.I:fOIO(I oS 'pelenls^o sr !'tg .rer;e perrnber 1ou sI 4y pue
'perrnbar 1ou sl IJ 'pelepclec st ./.ty ocuo 'Br pu" U
I_I:NI 'permber
N.I:fOIO(I Jo stuetuela JoJ sploq uoll?Jeplsuoc eur€S
(N'I : r'(N'I : r'ft'D vt)'z6 rNlud tou st 4y lueuele 'pot€lnol€c s1 !!1 lueruele ecuo
Jog '.relnduroc 3o .{.touteur ol€s ol Z Jo slusuelo
(N'I : I'(N'I : f '(f 'D v))'16 cIVa)I arll uo uellu^.-Ja^o oq pFoc J Jo slusluele eql l€ql
(e 'g) v NoISNIII IIcI
I '0I '9 'trY '9 reldeq3 uI eroJoq trees .{peerle p"q e,d[ '9
I-N:IN uot[:1
COHJIII^I A)SII'IOHJ 3 'u ol ! : ['Lt oll : I JoJ t[y:tlg= : {tg
NOISUIIANI XIUIYW JIUJEI^IhIAS J s3 usllu^\ aq ,{llueru
|r wvdDol{d J -a^uor ,ltou ,{eul oelnru.IoJ eseql 'Itg : .t'tt Surtmd
lsnf ,{q peur€lqo eq usc slueruele Jeqlo ecueq pu"
'lnoqEnorql trcelul uleueJ xr.rl€I'tl I?clJleruru, s e sI €r leql pogue^ ,(psee eq uec 11
e1Euer.r1 reaol eql ut leuo8etp oIIl .ttoleq Y Jo sluoutelg '9 t:tu' 8sU : e88r
'e13uerr1 reddn 3€y ezur
- 8?gr
eq1 u! U uo uellIJAt-JoAo pue 'e,toqu peuteldxe se,{1uo 8zU. ezy
+ zzY zzY _ zzg
alEueul reddn eq1 ur slueulels Jo 'o'l ttty >t!y slcnp'9 €eu.8ry : €r€r
-o.rd dn Eunuurns ,(q punoj aJe rY: /.tg sluaruelg 8zY rrdr + zzu ary : 8?
'31os1 6 dels sru rru. + .Iu zty 1 rry lly : IIgr
ur puoEetp oql ul perols pu€ pel€lnslec re^e/(oq sI
ItJll:tlv uo ue11lJ^\-rolo pus 91'5 aldruexg {q uo,u8 aJe gr Jo sluourele usql
JIoslIJ .*g try,l
ruo{ slueuolels Sutsn punoJ sr J 3o esre,ttl oql 'y't l'.*gl
.Y 'itag zzg ,rg! :g:
uo uollrJ^\-J3^o puB I '0I ' 9 'lJv luo{ slusruel€}s
lttg "g ttgj
tunn punoy sI xlJl€tu reln8uet.tl reddn ue J rolceg 'g ""y "'ui) l.*'uzau
tty
'"y ttu o ol :ry
o i lr:ay 0i
'1ro,n :elnduioc 0 0 r'uJ i"y .ty ttYJ
JoJ permber lou ere S 'rY 'V 'tJ 'J seJul€W'Z t
'pousAul oq 01 r xlJl?lu Jo ozls eql roJ spllsls t : N 'l _tot!:4 I ./.ry ( ttg t1y=, - :t"t
trttt.tSo.rd aW tnoqD slttrod auog tuotl*t:{ I
I-uoll:! roJ l tgl@1zry!)- :.ry
'relnduoc eql
uoll:1 JoJ llJ,ll : !!Y
uo olg3lr3^" oq lsnru orloruqlus xeyduroc ;o ,(1r1rcej
'suorsserdxe Eullrollo.; eql Sursn f,q'9I' g eldulexg
'ocueH 'xolduroc eq .(eru slueruele luuo8urP 'eltu
-gep ellllsod 1ou are leql sacrJlel.u ct.tlstutu,{s Jol 't ur peureldxe s" peulruJalep sl U xIJlsIu ssJeAuI egl
66 xruwl s$rgANI
100 MATRIX OPERATIONS ON THE COMPI.'TER
DO45K:J, N L- J L)
45 SUM : SUM + A (I, K)*.A (J, K) 6. Obtain ,4 using the formulae Ai*- Ai* AJi, A*lAt
A (I, J) : SUM for i: i + -ltan
50 CONTINUE k:i+lton
PRINT 92, ((A (I, J), J : 1, N), I : 1, N)
and Aik:0, for j:1toi, k==llon
9l FORMAT (eFs.o) Ait:9. for j:i+1, k:ltoi
e2 FORMAT (3Fls.4) Thus l* is the only non-zero element.
END Azr: Arr- AnA\tf An: 4 - 3 x 4ll -: - 8
(t /.1
I zJ
I'
l- toj
A: t: )t 24)
IJ
_l
5J v:t- st i r- 3 2J : i l.- roj
Steps
rl 0l s: (-t6l 14) (- 8) + (- 8) :
i^
- lof the same size as l. 16114
l. Let C r_ \t)
LO IJ
2. Subtract identitymatrix fromAartdget
".*, - flL3 1l4j
c: I \i,,i
?l
-l
t)
Firstcycle,i:l It is unnecessary to do lurther work as C : A-r,the
3. Let U and V be one dimensional arrays containing inverse of the given matrix.
n : 2 elements each. They are obtained as under- On llte Method
using the relations Ui-ZC1< Aki for j:l to n '
vj:ZAit' Cti k:i to rr
l. The method involves about
:
Ur:Crr.ALr+C2tArr:l x 1 + 0 x 3 I 5 nz multiplications and divisions
Uz : Cn A11- C22Azr: 0 x I + I x : : 3 5 fls algebraic additions
Note that if "B is exact or accurate, .B r4 equals .I' As -B one more array and a few FORTRAN statenontl
is approximate, B I is not exactly equal to /. Thus, more.
R, the residual matrix contains vcry small elements. The final result ,4-1 is printed with eight digits to the
The elements of Rr, Rs are then obviously still smaller right of the decimal Point.
and smaller. This justifies tl.e assumption of the
convergen@ of the matrix series. C FROGRAM 7.10
Making use of tle terms of the matrix series we have C N4ATRIX INVERSION BY ITERATION
(/+R)B:B +RB more accurate than -B DIMENSION A (3, 3), B (3, 3), BA (3, 3),
(1+X+R'3) B:B+R,B+RzB still more I R (3, 3), RB (3, 3), RRB (3, 3), C (3, 3)
Eigenvalue Problems
rR(I): o IrJ
DO lOJ: I, N 2. Write the equatiort A X : .B and calculate B as
Note that Azr: An: 0 4. For matlrematical discussion read Ral.vton and lAilf
(80).
2. Annihilate next -4rr. Here i - l, k - 3.
lo 0.64 0.77) l.*.o.or o 3.31j 4. R-l is obtained by changing the sign of the relevant
terms of R and is stored in R itself. Then product
This completes the cycle.
R-l -B is obtained and stored in l.
Note that the off-diagonal elements are tending to
zero. At the end of four such cycles ,4 becomes 5. The off-diagonal terms arrnihilated are A12, An,
and Ar" only, i.e. elements in rows I to Nl : 2.
completely diagonalized and appears as
in the lower triangle are
Corresponding elements
lt.s2 o o l not considered due to symmetry.
A: i0 s.tl 0
l.o o
i
3.31J 6. The number of iteration cycles NC is limited here
of A are 1.52, 5.17 and3.3I. to feur.
Hence the eigenvalues
{7p) uosut1ltrpl peer fpnls rer{1.rnJ rod N'I:It090c
'xrJluru ue,rrE eql Jo lusunuJelop oql 'o : (-I ')) A
Jo enlel oql spnbo sanyerrue8re orll Jo lcnpord sql .6
N'I:T0gOO
'ecBJ] N'[:)090c
s1 slenbe xrJletu u Jo soltle^rreSla eq1 .g N't : x'(N't : T'(T'){) s) )'zo lNtua
Jo r.uns eql
':red (-r'trt)u*(r,l'))v + (T'))g: (t'x)s 0s
uAlo slr 'esrnoc3o'Eurldecxe ,y3o .ro1caa,ue8re .(ue'o1 N't - h{ 0s ocl
leuoSoql;o sl ty Jo rolcea.ue8re fuy .sen1u,nue8re o:(r'x)s
eur€s orJl e^p.q ry esodsuerl sl! pue y rcrrluur fuv .l N.I:'IOSO(I
'rY Jo N't ) 09 0c _.-
sJeco;drce.r eJe y Jo senle,r.rre8ra eq1 .s-rolca,rue8re (N't : ) '(N't : -I'(-I')) u) )'z6lNtua
eups eql eleq r_P, astenut slr pue ,7 xrJleru fuy.9 dJ: (f 'f)u
leuo sl xIJlcIu ds : (r'r) u
,(relnrn e Jo sanlp^ueEre eql Jo anlp^ ejnlosge or{1. .g ds-:(r'r)u
'slred dJ : (I'I) d
ur .u1cro sanlu,rueSre aq1 ,xrrluur leuo8oql.ro ul? JoC ., I:()'))uot
'lual solllr?^ue8ra s1r lle spq xt,lluur uurltur,reH .E o -- (-r')) u og
V
'lea.r sanlelue8rc s1r .Z N 'I - 'I0€ O(I
JJB sBrJ
xrrleru cnlauru,(s leeJ y
N'I:X0tO(I
sB erues oqr erp gy x'.w 1c'pord U XIUIVW \IOIIVJOU AIVUSNEC )
," :'St*:;j;,H ,
joord lnoqlr,r\ .uotleruJoJl-rr JoJ ,r.o1aq ue,rr8 .fiHa) JSoJ : df,
o:e rualqo;d enlenrre8re erJ] o1 Burleler slutod A\oJ (rnd cNrs : ds t(,
V
'purluelu ol uooq olqelr.re^ u aq ol palord n98L'0: IHd ZT,
seq ;alnclruoc 'sos€c qcns rrl.socrJl€tu
00g x 00g uang Or OC EZ
Jo sanle,lueSre Jo rrorlsutrutalep Sur1\lonur suelqord (cv/gv) cNyJV,,9'o _-- IHd tz
aieculur qlrl[ Ieop o1 ,re,talroq ,eABq sJeIJoAt r{cJuosog ,ZT, .IZ
'ualqord eql IZ (JV) dI
Jo eJulau eql Jo eepr uts 1aE o1 remrr8aq (t'r)v-(I'I)v:Jv
e -roJ ?clgnsllt^r onoqp rranE luaurleerl frosrnc aq1 (f 't) v*z : gv
uolsnlcuoJ S.g N'II:f060(I
I--I:II
CTNA IN.I:I06O(I
gNNIINOJ OOI b,I : f,N OOI OCI
(l'orge) rvruuoc z6 SINAhI!I-Ig f,
.IVNODVIC-CCO
(o'sgo) JVWuoc 16 AIV'IIHINNV c
ANNIJNOf, 06 INI -N:
(N 'I : ) '(N 'l : 'r'(r 'x) .,r))'z6 rNlud r:0'DA\ oz
(N't - )'(N'I : .t'(t'x) v)).z6 rNlud o: (f 'I)^A. oI
08
(t'rr) s * (n')) li + (r ')) v : (r .>) v N'I:folO(I
N.I: I IOSO(I N.I:IOZO(I
o : (t.x) v i\\ XIulVhl AIIJNACII AMitNgC
N.I:"I08OCT (trt 't : I '(N 't : f '(f 't) v)) '26 rNldd
N.I:)08OCI (N 'i : I '(N 'I : f '(f 't) v)) 't6 cvgd
ds-:(r'r)u
ds: (f 'I)u E:N
(N'r : x'(N 'r : -r '(t ')) ldJ ) 'z6lNrua (E 'e) ,l\ '(€ 'E) A I
(r':r) A : ('r ')) /rr oL I
(s'E) u '(e 'e) '(t '€) v NolsNahlro
N.I:'IOTOC CIOHIflhI ISOJVf SgNfVA c
N'l:)0roc -NADIA XIUIVru CIUISWI^IAS 'IVAU 3
(t'll) u*(t{ 'x) iA + ('I ')) A : (t';) n 09 t'8I iVUCOUd J
60I SW:I'ISOUd En'rvANa9Ia
sorlBruaglqhl poilddv spJ?puels Jo nsorng
lsuoll"N 'tS6I '{JoA rmN ..cul ..oC
'trcat11 xltlory u! stnaroallJ clsng ,.1A1 .sncre141 .15
Tr lnqeuru lloH'ttoaqJ xlttow puo otqa377 uapon
'w6I ot uolpnpottul ,-/t\.U ,lleg pue .V.U .luournuog .9I
''ury 3o 'oossv 'ql€hl ,, .oN qde.r8ouotr4 Ieort€tu
-aq)pw snte3 ,sac14ow pu? s)otza/I ,.3 ,eagng c"hl .0g 'oJ Burqsllqn4 .unpqcs *rrrrrqz?.6!,:Xl:+ .r,
^\eN
'gt6l ({ro^ .1961 .qEmqurpg ,p,(og pu"
'uas1eq3 'satr4oyty to [toat11 ,.3.3 .eegnq ^\eN
cery.6Z Je^rlo 'sacu1o1;1J puD stuouluttap([ ,.J.V ,ua{llv .rI
'9961'eruro31p3,pro.; soqrfBl J
-rretS ',tlls;e,rrun pJoJuulS .'lldee ecuercg :e1nd
-uroJ 'lZ 93 sgodag .t1ta1 ,sttotlnnbl lo suralsr{g '9961 '{ro1 ,tr.e51 'sser4 clr.uopeov ,lJ uott)of,
ctotqaSlV tnau!7 lo trotlnlog atlt ,ro! suotlotad6 Swpnlaut sta1nduto3 puo SurtuwotBot4 o7 uouJnpo4uJ
JItauVU.ty to taqunN a4l lo uotlzzluttu!t\r aqt r,rutro4 ,, ''C .z11 ,oruntr41 pu€ .T .141 ,ulels .€l
uO "I'N 'I€qreqcs-url^olo) pu€ .A .1 ,,refn,{1y .g7 ,.cu1 ,suo5
'zg6l '{ro^ ,,rte51 ry fe1111 uqol
'9961'sllesnqcBSSBI .Furpueg,'o3 Burqsrlqn6
{ 'ta1sa1o1ny uDtttol ''g.q'uosuqof pue .iI .)I .qtJug .g1
,(eJse16-nosrppy,saeuTo1g pLtD suottDnhJ naaT '896I'<sgesrqcpssu1z1,Surpeeg,.cu1 Burqsrlqn4
'uo^ 's 'u'{calApun .g.c,€cud ,.g.1 .uolsuqot.LT ,{e1sa16-uosrppy,lI u:ortrol ..D.U .{caquoqcs.II
.0/61 .rr?f .lJ"s ,gg .[oA ..uc
,suoltonbE ''01.61 '!ril3c ,!\oN "pl'I 'l^d €rpul Jo IIBH-scrluaJd
'lS 'f 'gIJSy "cot4 nauyT .to/
ntply 3uttutuol8ol4 .tandutoS lo sa1dnutt4,.n .uuuerelea .g;
suouryos |ua1ag[g,.y .c .e1re4 puB .c .H .uesuef .gz
'tg6l ')Joil i\\eN <.cuI ,rro1surr11 pue utsqeruu lloH 'w6r
oststtuapg plros toJ '1roa ,,re51 'of {oog JllH-^1,"rCcI I ,uorpn4sut-tlaS
utqa7ly. xlttDJq ..d .ts.roH .gZ tot uro.tEot4 y 'uo.r1tog ol uotpnpogal ,'O .S ,qurnld .6
'gs6I .{.ro^ ,roN '9961 'silesnqcessul4l '3urpue11 ,.cu1 .o3 Burqsqqn4
uulf nucel 'ntqafiV x!.rtDI,U
[totuaua7 <.A'C .uqoH .rZ ,.I.J..4crue8rg .g
,,(eJsa1tr-rrosippy 'nw1.t4 uzrtrcf V-
'sg6I'{ro^ '996I
/r\oN ''o3 pJorJureg prn?JlsoN uea ,staaul&ug rc!
otqaSly x!.tt7h[ "rI '/K 'leneer11 plrr? .IA[ 'I .oreo .€Z {ro1 ,roN ''cu1 suog T ,{ell1\ uqol ,Su1tuutot&ot4
,,lI uo4to-:I ot aplng y ..O .C .ue1cur3c1A1 .4
'296I 'sJII3 poo,ralSrrg ..cu1
'1961
'1Jr11-ecrlrror4'ttoaql xtttnJg clslrg,.g.f .JeJlnC.ZZ '>1.ro1 .te1q ,(egzlt urqol ,sutututot&ot4
"cu1 'suog T
.Ll6I 1topuo-I i{yVJVOI ot aplng y ,.q.'e 6ualc€rJc4.g
'ssar4,{1rre,rru1 e8prrqruu3,saeu1o1,17 [.ro1uawa1g 'ES6I
'X'y're11o3 pue .1.X1 .uurunq ..V.U ,nzetg.17 '{ro^ ..t\3N .oJ {oo{
IrH-.r{rTrDOI^J'SurtutuotSotd lI uotttc!
..g .4 .,{a1pe1 g
'9961'SJIIJ pooar.el8ug '01.61
.'N .f .u!l{u"J-{ .02
'{ro^ '.oJ {oog IIIH
"ctr1'11u11-acrluaJd,[toar11 x!.ttDtr:[ -./trer9c6 '8u1wutot8o.t4 ^\eN ,.1 .g ,uosruel .7
lJ uDurcf
'9961 'ocsrcrre-rg '€96I 'lqleq ,re1q 'uorlerodro3 ep?rI plrol11 W{I
trBS 'ueureeJC .H ./h ,suo1tou.r.tolsuo.r7 naut 7 'uo"t|tog 'astnoS uouzrutsul patutuol&ot4 Ir{gI ,INf{l .E
puo sa?t.UotrN ot uolpttlrottul .,.L.q. ,reuroqlurd.6I
'696I '{ro^
'996t'qoc ,!\oN ''cu1 'suog T ,(ellld, urqog ,&u1wutot3ot4 17
'lntrg 'oN Z6 .loA ,.nrq scrueqceyg Burreeur8ug
uultof puo JI uotjtol ol uotpnpo4ttl ,.>{ 'q .ro,rru3 'g
Jo [BuJnoI'gcsv '.cot4,swa\qotd xrttDw puag lo
uoryryos qdo.tg .g1
.1761 ,feganog ,.plT .l^d
otolg ..[.1 ,:usaeg pue ,.3 .3 .Buag
.S961 '{ro1 suorl€crlqnd uf,reruog'11y tot nfidutoJ,.1.T,pnJlrlg .I
ne1q,.o3 Burqsrlqn4
I1apsreJg 'sac1uo141 Jb sruDwalltDry aLlJ ,.1 .4 ,sra,eq .11
SururururEor4 uur1rog
socueroJeu
t12 MATRIX OPERATIONS ON THE COMPUTER
Series, No. 57, U. S. Government Printing Office, 46. Booth, A. D., Numerical Methods, Butterworths,
Washington, D. C., 1960. London. 1957.
45. Berzin,I. S. and Zhidkov, N. P., Conputing Methods, 63. Kuos. S. S., Numerical Methods and Computers,
English Ed. Vol. II, Translated by O. M. Blunn, Addison-Wesley Publishing Co., Reading, Massachu-
Pergamon Press, Oxford, 1965. setts.1966.
_T
'896I 'IJoA ,r\oN ('cul 'suog ry ,te1r16 'tg6l 'lro^ 'srarlsrlqnd
u\lof 'suottanbE nanT Jb uotplog pttq uotsta^uJ ocuorcsrolul'strorlonbE ctotqaSly^\aNI
puo Suuuwot?
xutpry lo)uaunN /b ryoqpuo11 U ,.U .f 'oleltsol[ .99 -ot4 'uorlotall : I spoLltary loJtrauotN '.9 .olqoN.St
'996I 'IJoI /r\oN "cuJ ssord cnuop 'l.96l '{ro^ ,roN '.oJ upllrulcEhl orIJ
-ecy 's1s[1ouy lDrtrautnN pr!taroatlJ ,.g 'go:pua11 .gg 'sts{1nuy lD)ttautnN ut spoulaJ,{ ..1 .) .uoslerN .tl
'01.6I ')ro1 ,roN ..cul 'suo5
'9961 ',(esref ,t\oN 'sJrlJ pool(e13v4 'SuuaaurBuT ry ,{e1r16
puD a)uatrs tof spoqlay1 f)rr.tawnN ,.D.U ,tro1ue1g .pg ugoS'SuttutuotSot4 lnttvLtraqwl['.J .u€llrhlchJ'€,
.1161 .,(as.ra1
'896I '{JoI ,roN '.oJ Ioog IlrH-^\eJCcN ,sts,i1ouy
,reN ''cu1 '11e11-octiltord 'uol1.tog u! spottpnt
1ntuawn11 lo slualqord pLtD titoatll ..C .pelqcs.tg
D)traurnN 'C'trAI 'llc'pu^lss put 'I^.f 'clruJo1clN.ZL
'896I 'FIIoC .&eN 'oJ 8r"rrqsr1qn4 HSI
T proJxo tg6l 'IJOI ,na5,1 '.cul ,suo5
'srs{1otry locrnluat!rcA[ p)traurnN ..g .1 .q8noloqrecs .Zg T ,(all.,11 t-tqof '8urtuuto.t7ol4 uoltroJ puD spoqtary
.996I .lrllo6l ,raN ..pl.tr (.t^d) lloruawnN "g'16 .rr.to6 prl€ .C .( .rro{csJf,ol4l 'If,
f
slpuJ Jo leH-octllroJd ,SuuaautEug Lr.t spo1lary '1961 'IroI ,tap ,.cu1
lDzuatunN '.T.hl .uoreg puB .c.I^{ .l.rops^les.Ig 'suoS 4t,,{e1116 uqol'SttttuluotSotd uprtrof pup
'1961 'T eurnlo^ .0961 .I erunlo^ .)]oI aoNl ol uottrnpo.u,{ ,.u .I 'BIIeJo'^[ .0,
spotilalq lDillaLunN
'.'cul 'suos T foll1\ utloJ 'stattrdruo3 lotr|tq xl' 'I96I'1roa,ua51',l,.ru;qr1 luctqdosolrqd :spoqpry
spotttal\l lp)ttouaqlD,,y..s.H .V .uolsluu .0g 8uryndwo3 u.tapol['puel8ug'rrotSurppal ]€ .(Joter
JIIA\ pul?
-oqu1 lecrs(qd [er.lorlBl\I rrotsr^rC sorrsrusq]ery .69
's961 ')ro^ ,roNI '.oJ
IooB llrH-,\\l?rDcN Jo
'ttstlDtty la)uatunN ut asJilo7 tsrll y ..y ,Lro1s1ey .61 .tg6I .IroI .\\0N ..cul
'grrog ry,(ey116 uqop 'srsIlouy lort.tatuTtAJ '.fl ,uoc?W 'g9
'ca6l 'I.roI ,/daN
''o3 Surqsrlqnd IlapsrElB Lspotlpn p1)t.taLuilN pun But .1961 ,fos,re1 ,{,oNI .sgrlJ poo/r\
-tuutot8o.t4 uDrtlol )tspg ot uotj)npo.t/uJ,.16 ..ra8e.r4 .g1 -:13u9 'lleH-acrluor4'sts[1nuy patlddy ''3 'sozcue1 .7g
'696
.096I 'uopuoT ,eglll ,.tafidtuoC
I 'I.r(.)A .\\0N '.'cul
'suo5 ry ,,{e1r16 rrqol ,7ut.raaut7u7 ur spotltayJ talnd paadg-t13t11 tot sltoqtaytr lD)ttaumN ''N'C 'ecu€.I .99
-luoJ xlrtpJ,li "v'S 'uelssoue^oH pr"ru 'V .1 ,sedr4 .11 .tS6I .)tro^ ,tre11 ,.cu1 ,oJ
loog
's96I 'troA IIrH-,\r€rCcW 'ststpttV lDrltaunlN "g'y 'zuny .99
-.,ne51
'o3 rr1?llrluc€l^{ at11 .srsf1ouy 'ZV6I
lDrttawnN puo '\ro1 ^\eN
''cul 'suos T, fe1r16 uqol
spoqlaw taydwo3 (,ro1tnpo.ttu1 ,.H .U ,uo18trrurre4 .91
'Suuaarn8ug uapory to stttouraqtory ''D 'g '.relle).t9
EII sacl.lllwIau
eloq? sB I '{ '!l h2 atyS- :ltX't:trx ,oll.-./'l
reln8uer;1 .reddrr lrtrn sl
utoll:!) {tg a ly: {t2
n JI u x Lu ezrs Jo J 'g ,V sacrJleru Jog t.t .xil
I-lorl:ry.)
roll uoltlppv xruDw
+t:li 1tt2 ztSl3\ r{X - -
I-aoll:lj tt2l@fi ,t!X : ltx SNOIJVXAdO XIUJYhI itTdhi IS
uotl: tl =) - :
!!nll !!x
'.,(:eruurns
I: Xn : 2y 3ur,(;sr1es 'a ezrs srql trr pe]lrruo ,(1snor,lqo eJe 'cla se8ueqcxe urunloc
pue X sarrrleur reln8rrer.rl reddn .xg
lon ,rog 9I.t put? ,{\or a)ll senbrtrqcel ?ururuurSord .61
lercadg
./ ot + / :7-'l 'pauruldxe ra^e,ror{ e.re .ecusrueluot
uol *I:ll ,{eq1
.roJ pasn 0g 01 puq lxol oqt ur esoql tuo4 lrroJo.grp
Iol -;: t) '!vl(tg,t!v 7- !ry):{tg ,{tlqSlls slogu-r,(-s ',(;eruurns strl} Jo sesod.lud aq} JoC .6
uot :!l !!yltj : !!g
'suqluotle
t{Y : J 8ur,{;sr1es n ezrs aqt rrr parldurr sr slrJI 'ruerl] Jo sonlE^ a,lrlrsod
Jo C'g'y'sacrrleru leln8uer:1 .reddn .rog SI.t .xg roJ ,{pro petllcoxo ole sdels ruerSor4 .asodrnd
I srrlt ,roJ uollrppu ur poslt erc y'1 'seldtuuxe cruos ur
nol-for,r:)I
I+!: { i .(1ug 'sldr.rcsqns .roJ pupls .J:n'4 '!''i sJelial .g
IIBTuS
I*aolr:t j 'oo1 sesBc
ttgl@g:t!y !-I3) : tly
u07 :/l !!gl!!c:!!Y iaqlo eruos ur euop sr slql 'su-ru.r3old ur pesn
lou a-re ,(er1l qSnoql rre,re ,(1i.ru1c roJ prureter eJ?
Uy : J 8Lrr,(gsrlus u ezrs A'X 'n 'Z eI!l sloqruXs suelqord uorsle\ut xuleu uI .,
Joc ,g,Y seollleu teln8uur.rl lacldn .rog .xA
tl.t 'qlpl,\l. pueq JIPI{ roJ 11
{or ixr.rleur esruds u lo qlpr^\ puEq llnJ rql loJ spuels ,1{ .9
uol :11
uol = !) ltg ttp,<: {tC 'oouorrreluoc .roj .i1uo'.i.reuruns
slqt rrl '( ) ur d-reur8utur prre [ ] a.ltt sla{rerq
Sy: ) 8ur,{jsrlesuczrs lur rr,,*oqs sr xr.rleur xeJduroc e 3o 1.red leer er{I .g
JOJ 'g'7 sacltleut re1n3uer.r1 .reddn log EI.E .xg
uol 'SOJlll€lll lereuet
uol :!J lty rg : tt3 luesarda-r,(utu 'cla )'g'V sloqur,(s srseJ raqto IIB uI .t
.XIJlPIU
t/ ozrs Jo ,,(eue Jeuorsueutp crro ur peJols sl 67 Jl luarJgeoo eql 'V Jo s.tololU Sururro-1 .ila.rrlcadsar
ilot I :.f l socr.rleru ,reln8trerrl
laddn prre Ja,\\oJ e.ra ,1 pue 7'E
uoll:lJ {tV lg -- !t3
VA : ) 3ur,(;sr1es ,/ ozts.lo J puB X soculutu
.ua x u sauroJeq
ezrs slr '1r o1 paurolpu sr xlJleru .uairrfi
orenbs pue O xrJll?ur letro8erp u .roC Zl.t.xg l Jl
^ltluopr yrlleur JoC .Z
sr u ezIS Jo p/ xul€tu orenbs 'trors:e.lur
/01I:ry1 '(t f u) X ,, ozrs Jo oq llrr\ y ,V ot
aotl: {i
utoll: !) ttg;tt73:IC peurolpu sl g JI 'u ezts Jo socr.rlutu urullloJ g pue X
'xuleru e.renbs v st v ,leleua8 ul .ocueH .pellos
gY : J 3dr,{1sr1us ,1 X li pue
'tt x I'l X ul sszts Jo J,U,7 saorrluul .loJ II.t .xA eie srrn\oulrrn u ur suorlunba ta cJoqa lI.9 .try ur
ldacxe'suorlenbe u .;o rua1s,{s e sluasa;dar g : XV .l
uortptrldttlnw x!rtpw
'r!\oloq paureldxa eJe pasn
uoll:ll !!Y=- Vocerl t.e .xE s1oqu,(s aq1 'ecueleJcJ {pear ro3 ereq papuadde sr
xtrlow a.mnhg o to acn.t1 sruq1r.ro8le ro
oelnur.roJ luulrodurr jo Ireuruns Jelrq V
suqlrJo8tv pu? eBlnrurod Jo druuunS
I
!
\k==ltoiorj :m.-lifAmm:0
j*fti"fr.r"r ;t : mtf Amn*0
lsmaller
SIMULTANEOUS EQUATIONS
TfA:Bt
Cii :2A1e Ait<:/Btci Btci [i,.i, k as above Ex. 6.2 Method ofForward Substitution
xr - BllA\
Ex. 3.22 For matrices ,4 upper triangular, B lower Xt:(Bi-2AiiX)lAii li:2ton
triangular, C square of size n satisfying C:AB
[;:ttoi-l
Cii:2AitBt<j ri: lton Ex. 6.3 Method of Backward Substitution
lj: rton
lk:i to nif i)j Xn: Bnl Arn
| :jtonif i<i Xi : (Bt-ZAii X)lAii li : n-t to I
TfA:Bt [7:f+ltoz
Cii - l.Bri Bni :2Airc Ait j, k as above
Art. 6.4.1 (b) Row matrix ,4 containine n(n+ l)12
[i,
Ex. 3.23 For square matrices B and C of size n, and elements of the upper triangle of symmetric matrix
a row matrix A containing n (n + t)12 elements B of size n
from the upper triangle of a symmetric matrix m: in-(n-k)-i(i-1)12 Ik>i
satisfying C : AB Am: Btk
-
aorl f r:{l >t+!!-u(t-[):t t\oJ lo^rd .r
I-.r01 I : rl ,t+{ [-t)-u(t-D:t dr x u ezrsJo V'pueg clrleuul{su11 €.9.9 .UV
I-ttol z: lj 'lV otpautqsty
,roll + , :{l zt-1+u(I-!):t '(O t't'9 'l.rv Jo e?lnruroJ Sursn punog ere feq;
.a,4,oqu 'lry uuv 't!y ,q!v ,{!y to t{y ,ttly
uotl: !) '/P' ol patJIL{s Zdr I'9'9 Jo
slueruele 3ur13rqg',rr sruJol 01 puodser.roc ,bV ,dy sIuJsI
ly "y "y
,lolt+l:ry] !+{ 0-!)-u(1-t) : tu uol + t:fl
I-.rotI:ri )t+[G-i-u(t-{): t Iol r- u : tJ : lX,tylug : ux
I-ttolz:lJ 4v uY lY :lY
- 'yl(x bv1-tg)
I-torI:rl t + {g-!)-u(1-t): tu uorlnlos'JI
uotz: lJ '*vlg-tg:lg uol -t:Zl sylny q_{g : tg
e^oqe ', uu.rnloc rrr uorlBurr.urla 'lr tr 07 +/ =/!
uotl +l:ry] I- olI:l.i 'ylryby-dy:dy
I-uolI:lJ lYI)IY:'IY uorleurullfl .l
4ol
t:.4 l)dl!g : lg '(q) t't'9 'irv ur
,{roJ }o^rd 'rr ua,rr8 se palols xr.rluu luercgooJ crrleruru,(g Z'g'g 'tlv
o<ry+(r-r) -u(t-D:t
rott +{:fl r/otI+l:Il
I-tolt:{l tvty-4tr:)ty 1 or 1-u : tJ {y {ty-t+tt'ty:!r
uotl:tJ !ytg-!g:!g uuvfr + a.uv : utr uortlllos .ril
aolsq I-, utr.il1loc 1{r uorl€ullurlg 'r
Icuorsuerurp euo g 'y 'y s,{e.tru u+llotl+J:-yi tttV r[V-ttty : tt[V uoquurrurlg'rr
'inor,(q A\oJ peeJ xrJlsu luels$aoJ a3.rx1 7'l'9'\.nr' rolI+t--{i
I-u : jj
ol I !!Vl4!y : ,t!V ,rror lo^rd 'r
'.' .5,,i,S .,,,
(1-u)xu
[+u o]t+I:ry.l az:.s'y xrJtr?ur luarcgeoo paluau8ny I '9'9 'UV
o}:
l+{ 'u I : fi tttv ttY-atv : {r uortvulrulll 'll
u ot I !) llvlrlly : 4!y /'ctot lo^ld 'l poqlaw Lrorluurrurlg ssnec g'g'try
(t +u) x u szrs Jo p' 'esBJ IEreusD t'l'g 'lrv
o^oq" I
poqtetra{ uEprof ssrlBD l'g ']rv (c) ur se 1 '11 t+t-f+tt{J-r\:ut
qolz: tu
!s) : lx 'V xttlew A\oJJoray saurooaq
1-tu*!:I 'tvl1x*tY3-
ruyfug : uy
Ioll-u:1 U'xuturu arunbs p {tV 'az;.s 7l{1xa) rr.;o xrrleur
tror1n1o5 'i11 A\oJ 01 pesueplroc ezrs
ux aJo F crJleruur{5 esredg (p)
,t+t-{:w)
I +!-.r: / I
r>{l t+!-!-r'{:r
l-rloll:41 t<t1 I -L !-{: f '! : I
(r41-a+ rlvilgtlY -- lg : tS
ort+t:fir)l ttvl*ty tly-tt{V :t1ty .Y.U xu
1-uot | : !) rrorl€rrtrurllJ 'r go /ry sauroxaq V 'u x u p {tV 'azrs ryx uJoV
Ll x u ez$.;o y 'pueg .lleH cr,narrrrufs t'g'9 ':t.l17
ot posuapuoJ ezls u x a Jo t' IeclJlotuu.{s esredS (c)
d{olI+tl :wl
q-ttt + ! : ,ll ,tX w!y <--!g -lX I>l [+!-q-
loll-u: lj ttuyfug : uy Lt+t-[:)t
'il[
r.rotullos
!<[l
drotJ+tl-w) tgrty-tg:{S eJoq,r y ',1t 'x u -Io
tuly t{y -- tt{y : ttty
t+[-u: Ii lltl saruoJaq V u x u p lty 'az\s ft\ X tl Jo t' ol
t+ {-ut : ,ll uorteullurl:[ 'rr prstrepuoc ezIS ll x u Jo V lecrrleuru,(sttn asredS (q)
t_tt+ t I
olI+t:.ri qlyllg : lg Zlfi+,tt):ry(e)
I-rol I: j !
4!VlwlV : wlY xul?I tr luersgeoJ pueg €'t'9'uv
Lll sr^rHrruoolv qNv gvlnl^tuoJ rIO .Luv$Utns
T
{
Art.6.8 Crout Method. A : U, U is unit upper Art 6. 10.2 Symmetric coefficient matrix stored as given
triangular, J adjoined to,4. in Art. 6.4.1 (b)
i. Decomposition Formuale of Art. 6.10.1 are used after finding the
corresponding terms of one dimensional array using
column elements Air:Ait [i: lton formualc of Art. 6.4.1 (b).
Ai1 : Ai1-lAit Atj li: : jton
I i 2to j-ln Art. 6 . 10. 3 Symmetric half band matrix I of size n x h
I i-: I to i. Decomposition
Rowelements Arj:Aif An U:2 toni-l
Aii : (A1i-2 zi* Ar,i)lAii li:j+ltor*l T1-t:1/g1r-2 Tp,Jpr) {i.- IIton
li:2ton to n-i*l
l"t: t to i-l or & whichever
is less
ii. Solution Xtr : An, n+t T i1 -- @ i1--l Tp r Tps) f T i1 k:l to h-i or
Yi : Ai,n+t-| Aii Xi li : n-l Iol i-l whicheveris
li =-i*llo n Summations are carried for posi-
less, &> 0
p:i-k
Art. 6.9 Doolittle Method A: L U.L is unit lower olk. 7"over written on
tivc valrres r:k{.l
triangular, -B adjoined to,4. A. s:j+k
i. Decompositiori ii. Solution by lorward substitution
Elements in rows left to diagonal Xi-(Bi-2Tl"p Xr)lTir i: lton
Atj: At.i t .i :lton 7:lifi+l<,
or else
Ai1:Qi1-/ ApA*ilAti li.: 2to n
:i-n* l provi-
I to i-|
iL: I to 7-1 dedj>t:l
Remaining elements in rows
k: jto i-l
Aii : Aq Aitc A*i i:.2Ion P:j-k+l
-2 j: itort iii. Solution by backward substution
/c: I to i-l Xi : (Xi 2Tip Xt<\lTi,
ii. Solution - li:ntoL
Z over-written on A. ij:nori+h-L
Xn : A1. rt + rl Anu
Ii:rt-ltol I whichever is
Xi:(A t,n+ r-2 Aii Xil A ii I less
lr:i{lton Summatiolr omitted for.i4l a I l, t -i+l toi ) ,
Art. 6.10 Cholesky Method 'tp - k-i+l
Art. 6.10.1 Gelreral case, square matrix A : Tt T Art 6.12 Conjugate Gradient Method for symmetric,4
Z is upper triangular, Zr is transpose of Z. of size n x n, one dimensional P, R, Q, B, X, all of
size n.
i. Decomposition
i.StartwithP:R:B
7,i : (Aii-/TttiTti) {i: tton :
l.r: t to i-t ii. Repeat r cycles for.i I to n Q:AP,C:2PiRi,
Ty:(Ai1-2Tti Tt<)lTii li.:tton D:ZPiQi
lJ: tton E: ClD, X1 : Xi + E Pi,
l.A: lto i-l R1 :R1-EQi
Summation of terms carried only for positive ,r':>RiQi,G: -FID,
k; T overwritten on,4.
values of Pi:Ri+GP1
ii. Solution by forward substitution
Art. 6.13 Gauss or Jacobi Iteration Method
Yi: (Bi->Ar<iY1,)lAii f i : lton
Summation omitted for /r: 0 Io: t to i - I i. {i : (Bi- E Ail X) lAii [i:lton
t ton
l;:except
iii. Solution by backward sustitution L i
Xi: (Xi->AikXk)lAii li: ntot ii. After all Yi are calculated
Summation omitted for k>z l. f
: ; + I to n Xt: Yt Ii:ltor
--
l't u I
'Y n^o elrJA\ pu? otI * 't!Y !tY-'t{Y : $y
6'9 'rrv ur sB n pue 7 srolr"J olul r esodluocec .l tlt ol 'r::"1 uoneunuqil .rr
uol
I :1.i llYltllY : llY ! or loard 'r
poqlnt elllrlooc g' L'$v
')
[=tluot[: 'ueJEord w y Kq 'soJez glrl\ polg Sureq u ot I - &r sirroJ
K J\ootr:rJ lpeczlder.y g 'I'x 'n 'T sloqurfi 'pepuedxe sr v 'u > ut JI 'su1r\ou{un u ur suonenbe
uol I:fl nv uo uellrJ^us^o I 'x ut :suorlenbg luelsrsuocq Jo luelsrsuo3 :I'9.lJV
uoll: ti {tta tryK - lts
AX:t-Y:S'm. Ienptsar tse88tq : -rY
I-.rolf:z') uoiI:d )tlyi:ly --]tX : ttx
I-.rotI:.fl uotl: lj {yfty7- g- : ty
uolz: l) ({:ttr ttt77)rt,t
- : poqlew uorlBxPl:u !I'g 'uy
tlTleq'try=) - : !t,r.
uotl - tl llTlt : !!tr t -f+l:ll I -9 t.I-ll : 't
fq ue,rr8
sl r-7 : ,1 'll I + {-!:4 | [ - tttl-!): b
ttotz : {i {+tttt_tt:4
I-./ort {l : uott - t) ,y IQX bV <-'rxdv =-tg | : lX
uoll +l:f!
I-z or I : rJ (hr1 aty() {tx ,terre lruorsuarurp
uotl-ll - :
l:!!X 3uo se perols pueg JIeH cr.r1eruru.i5 f t fI ^9'lJV
,{q ue,rr8 6l r-O : X 'll
'y JaAo uoql elud\ puB tKt-t+1:/l
esoduroceq 'r o <t + t-t - ll
8'9'UV ur sB/? pue T srotceJ otu! f qolz:[l
y xr.rlew arenbs .poqlaq lnorJ g.t .uV uoll: ll
!!Yll : !!Y '!yl(tX {tyl-tty !tr'3 - lg; : !f,
!!vl!!Y
- - !tv'
r ur.unloc .ro3 e8uutlcxg 'rrr
tt ., ii 5:s Jo y
xulphl tuorcsooJ pu€gJIeH crrleturu.i5 : : iI 9'uV
t tdscrs -t-
u ol l:r/ tr*) I
l ldecra :tty tty >ttV :- l{y '04t '!+ z p3p I
u ol I ri : - uorlErnlutlfl 'tr -rnon q--[+l:ll
uof t:-1J !!Yl\!Y : IlY lo^ld '! ,1.tOlI:/l
^\or uotl - !) qlyl1X {:e 3-,gr::11
u ezrs Jo y rcJtew erenbg
poqlentr oSueqcxg-poqlaw usprof ssn€c t' L'ttv hr xu az$ Jo F \:'-:I{ luarJ
-lgooJ pueg relnSuelrod crrleruu,{su1 I : rt 9 'uV
u ol I +r:ry]
uT ot l+ u:{i
I ol l*u:r J t'ty rtly tty "<tl
'o< !''t+{!
- lV -
srrtor reddn JerIlO 'Ar peprno.rd i
uuyf [.rV : tav z +-! ot z-! - {i
u7ot l+u:[] lsET .lll tt ot :
1!.Zoll+!:ry1 ^oJ I t) ttyl({y ttv ,g. .= tX
uott+!:{! 'xrrleyq iuJrclueoJ asred5 a.renb5
=-
>lyttV-tttV -tt[Vuor1ul1sllg .ll ! l[ 9 'uV
l-uotl:!)
uT, ot l+/ : ry'l '(q) t't'S'uV Jo ?ElnuloJ Eursn feue i"-iL:T:ixtrrp
I-rol I : tJ !:ylrrly : )tv ,v,o-r to^ld .l euo Jo suJel Surpuodsarror oql Eurpug .r:-rre psn
uZ x u ozrs Jo (J'y) xrtpptl .poqlol/{ ssneD f 'l .l.rv ere I'?I'9'1rV Jo aelnurroC .(q) t.l'S -::a- u: ua.rri
se porols xFleu tuerJwoo) culeuuri5 J rI g-lJv
xlul_vht asua^Nt
'uorlnlos / tdacxe I
eql o.,lr8 I + u o1 d suunlo3 'tu o1 d u 01 I :.f i
uotl:!) ttVl(!75 ttV!-tg1:ry
erroJ ur uorlrsod leuoSerp ul I
- elnlrlsqns
'soJoz ur€luol ut ol d sinor Jr Jerl.ruo Jo as€J l€r3u3g I f I'g 'uv
ss1c,r(c a Jo pue aqt te peddols uorlaurullg .lll poglow Iepres ssn"g f l"g 'uv
6lI SI^IHIITIOCTV CNY AV'INI{UOd dO I,UYfiTI^INS
120 MATRIX OPERANONS ON TIIE COMPUTER
)
t 3-
d c- 8
.:J,NVNIhIUgIg( INVNII^IUAIgCT L
(t't) v (rf)v 6Z
I 'I nz
I 'I 9I
r*l +I z t zv
Jo uo 0z I 0t
k-Y) 'Y z T 8€
'G-Y) 'Y
Jo .r Jo vz
,OY LE
0t z
,(z,z\"tY
y (z'z) II L 9E
v
7 .I LI I ZE
c s s€ I I€
lrtn tilX 'iln ttx LT T 0€
,rn tto s€
enFrn ttx aan/?rn trx €€ z 6Z
trY ttv L7 T 8Z
pu" dn LI
6rJ ,J tt
t) ttN gI LZ
le o ol (e o I II
lo e ol lo e I OI
LooeJ Lo o eJ 6 z TZ,
J$t\ zlr\E L I oz
Y_ v- 9Z I 6I
.{'O'sd c)'o'sd nz
qqq'1 qq'I- SI I 8I
'0qqq 'Oqq LZ L LI
{: I -! 9 z
'0qqq .oqqq
ZE
'zqqq'0qqq'oqqq q'Oqqq'Oqqq 6
€qqq tqqq 8
_I
-I E
-f -f
0: 0- I I 9T
f t
t*t - 8I z 9I
(N'I :r H'i :i 8I I vt
t!) {') ,z
t{) 4) II T, €t
,"3 ,r) EZ z 6
-epls ol -ol3 lsol 6E 7 €
L-'l*9 Puu I*){*9 t-'IxgruI*)xS L z
(f't) o (t'r) q 9V
it'ct- 0's vE zt o'9 az I T,
' -
ppav {o poatsul au!7 trutnp) atpl
vrvuua
Page Colunn Line Instead of Read
43 15 0
1
28
-0
22 L2
4+ I 15 /-
/'2t Azt: 8
-
46 2 26 B4 B?
4V I 33 x (/) x (J)
48 I 9 Aga Acs
l1 A* Ar"
50 2 l9 j-i+j h_i+j
5l I 39 42x 4lx
) 2t 1Al Ar, B, lA1.aArrBll
)') I Az, Azz Bz I AzL A22 B2l
23 I AsL Azz Bt | 4L Asz Bsl
52 I 25 At, A"r
54 ) l6
l7
59 I 5 WITH WITH I
2 10 time, is time, it is
60 2 t2 (i- t)i + (i- t)j + i
62 I 38 U. U,
53 ) 28 Ai*lA*i /;p A*i
6s ) J L", L", Ls' Ls'
66 2 42 Atr Arr
69 I 40 X X
7t I 23 l,N I, N)
73 1 6 I:l,N I: l, N)
7 I:1,N I: l,N)
) 4 B B2
t0 Ait A'j
39 B B
76 2 2 l, l, N)
79 I 8 is in
82 I l2 holp hold
u I J M+t M+l(:MM)
l5 N+1 N+1(:NN)
30 C READ 91, M, MM, READ 9I, M,
N, NI, NN MM, N, NN
85 l. 3l 515 4t5
) t2 A,,' A,,'
86 2 l9 BR IBR
87 I 4r n n13
90 I 40 YL Ys
93 I 38 v __1t
At- Yr:l
94 I 39 K:1,N K:l,N)
97 I l5 Y,, Irr
ll5 I 40 Ai Aii
) 31 ;_ j:
116 I t0 i- Ito i--..ltol
ll jfltol -i*/toi
tt7 I 7 <i j<t
23 n+n n+1
1IATRIX OPERATIONS ON THE COMPUTER
.L L Bhlrud
Rs. 13.50