Matrix Operations On The Computer - LL Bhirud 275x210 PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 134

t.''.'i.',.1i;laiifffi.

,
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-,

MATRIX OPERATIONS ON THE COMPUTER

t4 -7-'86
)orlr.arta

(e. srtr trtiga; a )


,/
_-_--_n
uficla) toqwog tqpe ilaN
'oc cNIHSItSnd HgI A (Iuodxo
tDquog 'tulraau!3ug to aSenoC ptod top,tos c.uo^DtIB otprA o,(n\firlg
SulnaulEug NIC to tuawtndaq .poav puD rosselotd
PnJII{g 'T 'T
UETNdWOf EHI NO
SNOIIVUIdO XIUIVW
L
r
I

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

5.14 Gauss Seidel Method 74 1.4 Gauss Jordan Method 92


'14 7 .5 Crout Method 94
6.14.1 General Case
6.14.2 Symmetric Coeffi,cient Matrix 7.6 Doolittle Method 96
1 .7 Cholesky Methodfor Symmetric Matrices 98
Stored as One-Dimensional
76 7 .8 Matrix Inversion by Rank Annihilation lm
Array
7 .9 Special Matrices l0l
6.14.3 Band Coeffioient Matrices 76
7. l0 Improvement of Accuracy of an Inverse l0l
6.14.3. I Square SParse Matrix 76
I
7. I Inversion of Complex Matrices 103
6.14.3.2 Unsymmetric Rectangular Band 7. 12 Conclusiol 103
CoefRcient Matrix 77
6.14.3.3 Symmetric Half Band Coeffi- 8. EIGENVALUE PROBLEM 104

cieirt Matrix 78 8. I Nature of Problem l0{


6.14.3.4 Symmetric Half Bar-rd Coef{i- 8 .2 Leverrier-Faddeev Method of Generatiog
a Characteristic PolYnomial r05
cient Matrix Stored as One-
Dimensional ArraY 18 8.3 Largest Eigenvalue of a Symurr-
Matrix by Iteration l{16
6.l5 Relaxation Method 19
8.4 Jacobi's Method 10-
6.16 Multiple Sels 80
8l
8.5 Conclusion l(B
6. l7 Consistent arrd Inconsistent E quations
lrl
6 18 Complex SYstem of Equations 85 REFERENCES
6. l9 Improvement of Accuracy of the Solution 8'7 SUMMARY OF FORMULAB AND
6.20 A Note on the Methods 8l ALGORITHMS r$
filrtlsrc-st-) t
'gloq Jo saJnlueJ uou.luro3 cql fluo osn .cJoJeJeql '(gg) sotarytoly cas .clduruxa ;og 'dnor8 e8u s1q1
3o
'a1yruJndod orour oJaAoaoq .eJu Al NV5IUOJ lgauag aql JoJ s{ooq luallerxo peonpoJd a,ruq sJognu
puu C-II NVUIUOJ .lalnduoc rulnupud E ol auog ; ,{q6 jlasll Jooqcs qBIq oql ur sreEuueal
paldupu rlJsr NVUIUOJ Jo suorsral ,,(uuur aru a.laq1 oql ol pecnpoJlul aq plnoqs soorJleru luql Eur^\or8 sr
turlao; D 'serJlunoo eluos uI .scsJnoc alunpur8rapun
'Iooq
,{uuru ur rqe11,(s eq} Jo ped lur8alul uu su ,(pn1s vFluw
slql u! l! asn aruoq puu NVUIUOg ra3crd ,ool apnJour ol slsruollucnpa pel suq lcalqns aq13o aruupodrur
'a,11 'rzgndod cJour pue orour SunuoJaq sr NVUIUOC oql ',{pn1s 3o serlcu8Jq ,tuel'u ur siooq paJuBAp"
Jllls tnq 'NVUIUOC o1 paruduroc sellllpuJ luuorlrppu
s"q .1OC'IV 'ssautsng u! pJlrll eql puu SuuaaurSua Jo Jsgrunu a3ru1 u Jo oJnlEeJ uoruruor oql auoreq
.o^\l a^Bq saJrJletu 'sr llnsoJ orll 'slgord e8rel uree o1
pue cJuelJs Jo splog oql ur lsJg eql .so8un8ue1 pasn
ruaql osn ,(epo1 3o uaru ssoutsnq uolg 'soctJlBlu Jo asn
,(1apr,n lsou aql oru.IOgOf, puu NVUIUOJ ..IOD-IV
'anSorr ur sa8un8uul ,{uuru orll aql qlt^r ,(1uo uorlrnpord runrupdo Jo suoqtpuoc oplJcp
Jo auo fue ur ucllrJl\ ol alqu erB slsrlBrusnpul 'ruolu uo3sun aql Jo aJnlBu
ag ,(uur sluoruol"ls pell"c .suoll3nJlsur eql .sllnsoJ cql
anrsnlc orll olur redaop 3ura,1ap JoJ .socrJleru luopueJ, sa
Ino slurrd puE Jrleuqlur po:rrrbcr aql sJop ,uaql sraqd
-rJap qsrq/yr, ;alndruoc cql ol pal spJBc oql uo paqcund
u,\lou{ oJB lErl^\ asn 'ool ,slsrcrs{r{d 'sacrJlElrr oldurs
art ruc;qord u ol Sururulrad suorlcnrlsur pup €lup aql Jo sluJal ur tuolqord aql Sursserdxo ur JIeslJ srrJaJuot
'lnd1no JoJ JallBI eql puu lndur rog JauJoJ aql .lelurrd u8rsap aql Jo pud lsrg eql lsorulv 'cla sJooJ llogs
aql puu ptuJ aql 'atpour o,lrl ,{lururu asn o^t ,)iooq stql 'sa8ptrq uorsuodsns'sessnJl's8urpJrnq,{a.ro1s-rlprur c;J1
,oldtuuxa
rog 'sgag
ul 'ro1ur.ld pup .rolr,trcdfl .urnlp cllauteru .{slp seJnlcnJls Erq u8rsop sreaur8ua
crlauEuru.odq cllau8rur .adul radud .pruc pcqcund .{uutu ur lsllut u euroJoq suq ,{pn1s rreql .suralqord
'zrA 'clqBllBAB cJB Etpau uotltrJrunrutuo3 SurJpueq ur soJrJlur.u dq paprogu,{11gre4 aqlJo asnuoag
Jo Jaqunu V
'uolletruntutuor JoJ afuntduul B pue unrpaur u : sEulql .l
l0t 0f
o,lrl sol?lrssccau rclndwoJ eql uo sruolqo.rd Jo uorlnlos loz 0ri -J
relndruo3 oql qflrr .uo!l;sn^uoJ, e.I 0fl
0rl -g
07, )
'JnoqEl
pue emll ur siur,rus Jo sa8eluuapu peppe qr!,t\ loz ot otl:v
'spot{lotu lJrxo ol puodsar lou plp 1uq1 suralqord o1 : salduuxa eldurrs ouos aJE eJaH 'sJaqlunu Jo
suorlnlos elquldeccu utulqo o1 clqrssod sr U .st llnsal luorua8nerru uu ol ua,rrE aulur.r IpJauoB aq] sr xrJletrAl
oql 'soJrJlulu 'e'r ,sJaqlunu ^\ou ',t1lua
3o sdnorE Jo .sJaqlunu ro lrafqo '1run eJ8ars e su pal?oJ1 .uaqurnu
go uo11u1nd1uunr 1sn[ o1 sursJqord eql ocltp]J spoqlaur Jo las Jo dnor8 e ol sJeJaJ lI 'luarua8uel? JoJ aureu
asaql 'surclqord
cluclJlur Eun;os roJ spoqlaru I€qJ Jaglorre lsnf sr .,{uly, 'paads pu? espa ql!^r suelq
-aunu pesr^op cAEr[ snerJrleuoqluu .f11gre3 stql iloJdxa -o:d lucrluruorltutu llncsrp onlos ol sJequllu o8uer:u
oI 'puorcs nd suollJppu uor4ru B oerll alotu saop uatu lBJroqoal pu8 'slsgluaics 'suErcrluueqlEur op
ralndruoc uJspou u .oJuelsul JoJ .paeds Eurulq8r; q1r,n os 'sseursnq uru8 puu sJauolsrlJ IJBJpE o1 doqs aql u!
sJequnu uo s{Jo^r 1i 'o'r .slrSlp qlr,r st8ep lI .ralnduor s8urql sa8uurru radoel doqs e 'cJour slnpord ol uralted
IBI!8p cql '.u!EJq rruoJlcala, eql Jo luo^pu erll ol enp ;ulniar E ur seoJl lyr.r.; sa8ueuu JaurJDJ E .JBA[ trr.t{ ol
,(1urcur sr stusr( luaJeJ ur saJrJluru 3o fluulndod dJp:rleruoldrp suorsrlrp ,{:eyJru se8uer:e 3eqc .,{rure uy
"qI
rrlnduol yo prdrul Z.l ,{pnlg x;r1e141 roJ perN I.I
uopcnpo4ul
I lI:tIdvHJ
MATRIX OPERATIONS ON THE COMPUTER

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

FORTRAN statements Explanatiott


printed in the next 12 fields. Printing is ahvays done
right-justified in the assigned field. If the number to be
printed is smaller than the rvidth of the field, blanks are
produced in the left-most columns; if the nunrber is
longer, its left-most digits are not printed and are thrts
lost. In the present case the printed result s'ill aPPear as
bb12345bb1234567.00
where b stands for blank spac€s. Note the 2 places
(zero in this case) beyond the decimal point as
required by the FORMAT statement.
PRINT 3 These 2 statemenrs catrse first I blank line to be left,
3 FORMAT U2X,6HMATRIX/4X, IHA) then on the next line, 2 blank columns are left and the
word MATRIX is printed. Again i causes control to
leave this 2nd line. On tbe 3rd line. first 4 b!anks are hft;
then letter A is printed.
Study these 4 statements.
DTMENSION A (2) This specifies that the array A cotrtains 2 terms. Let
each ofthe termsequal I.II and 2.22 respectivelv.
READ I, A This causes the rvhole array A to be read.
PRINT I, A This causes the whole array A to be printed.
l FoRMAT (2F 5.2) This specifies how the elements of A are either pun;hed
on the data card or horv they are to be printed. Tbe
data card may look as
1'llb2.22 or as bl.l1b2.22
The printed result rvill be as
bl .l1b2.22
PRINT l, (A (I, J), J : 1,2),I: l, 3) This rvorks like a DO loop. The lernts are printed in thc'
order A (1, l), A (1.2), A (2, l), A (2, 2), A (3. I )..{ t-i, l).
Action is equivalent to
DO l0 I:1,3
DO l0 J:1,2
l0 PRrNT r. A(r,J)
First : I, J: l. rhen J'=2.
Next :2. J: l. then J:2.
Finally I:3,J:l,then J-2.
STOP This causes the computer 1t.l stop uorking t'rr the
problem any further.
DF (A, B): A--B This is an arithmetic statement function. lt is kept at
the very start of the progrant. lt is used to do repctitile
arithmetic elservhere in the program. For examDle
writing T:DF(X,Y) later in the program u'ill sause the
difference X-Y to go to T.

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

C:A-B the concerned terms by y.


IF (10000.* ABSF (c) - ABSF (A)) l, I,2
5. The result of dividing a finite number b-v- a very very
I C:0 small nunber, nearly equal to zero. uill be a very
2 CONTINUE big number that cannot be accommodated in storage.
It is thusclear that a constant watch on the nttme- In such cases, colnputers give an OVERFLOW
rical values of various variables at different stages error lnessage. But such division, apart from being
of calculation is necessary for faultless and efficient meanin-eless, serves no useful purpose. Hence avoid
work on the computer. it. This can be done by instituting a check to test
value of the divisor, and, instructing the computer
4. Division always takes more time than multiplication
on the computer. So, to save valuable computer control to bypass statement involving divjsion, irr
time, reduce the number of divisions. When division case the divisor is found to be a verl' verl' small
of many terms by some particular term, say x, is number, i.e. found to be less than a specified
necessary, obtain first y:|lx; then multiply all smallest number.
'Jelnduoc 3ql uo ferru luuotsuarurp-auo e^oqB or{l Jo t lueulale qtrAt I luol.uele aEuuqcrelul
z'z a-rdvlvxa
'plau pallone '0zqq'0tqq'o€qq
aql ur pJgrlsnf-1q8rr palur:d oJ? sJagrurlu eql oloN palugtd qnsay
^\orl
'JaAo sr ruerEord oql l"q] poruJoJur sr ralndruoc eqa oNa
'I luaual?1s l"r.rrJoJ rad su
F/Jo slueruala aql luud ol palcnJlsur sr ralndruoc aq1 V .I INtrUd
'PJec euo uo trsruJoJ-J
ur paqcund sraqunu I are oraql luql sogJcads slql (o'scE) rvt^tuoc I
'l trueual€ls lEr[JoJ .
rad se 'f Jo sluauale p€al ol pelcn.tlsur sr ralnduror aq1 V .I CIVSU
'sruJol € tulneq'luuorsuerurp
-euo sr y f,etrc eql luql peurJoJur sr relnduroc aq1 (s) v xorsNErurcr
trotTounTdxg utp.rSo.rd NVVJyOf
.PIAU
'sl g. 'utul'lJoJ e ur peSuuua o.ru sJsqurnu eql .eJ3H
pepolls eql urqln\ ereqn,(uu paqcund eq ,(eur slu€lsrroc
lurod Eurleog l"ql oloN 'rrrunlor {uEIq B JoJ spuuls g lozl
qq'Ozqq'Orqq'0e l0tl -s
[0Ei
: Jspun sB pJEc se uollrJ/( oq osle ,{eur e,roqu sJeqtlrnu saJr{l srll
oglJo suunloc tsrg
"l€p
agl ur paqcund eq,{eur srequnu
SI
asagl '02 (ZX/ 'OE : (t)V aunssv
: (€)v '0I : xJrtutrAj urunloJ Ez
.I'ueql
oz:ev '0r : ?'Y 'ot : ty
lurrd pue p"oJ ol relndruoc aql lonJlsul 'sutunloo
S olllncasuoc ur lurod Surleog rrr paqcund oJB senl"a ss ol peJroJal alu ,{arJa
esogt\ 'sruJal € suteluoc y fe;re leuorsueurp-euo V 'suuel Jo slueluele € sulBluoJ lI .xululu lr\oJ e pellec
'erogaraql 'sr ts '^\oJ ? ur pe8nu;re eJe sJaqutnlr oql
I 'Z srdr{vxg 'eJoH 'slrnrJ Jo sadfl g Jo rlJl"q B JoJ spuuls X eJaq,$
',{etre luuorsueurp-ouo B poJIEc osle sl V loz ot oel:ru
: (€)v 'oI 'og : ,(q pelouap eq .{eu slrn{ ar{l uoql 'sa8uero 97
oz : (z)y (I)v
,NVUIUOC ur ,snql .sur.re1
pue 's?ueueq 91 'saldde 0E strrcluoc lsISBq e ,asoddn5
E Bul
-ululuoc 'y fes ,ferre palducsqns e16urs e ,{q o1 peJJeJaJ xrrl8tr^i z.z
eq u€r slueruaSuurre eaoqe eqt qloq .NVIIIUOJ rrl ^rou
',y Jo ty : €r s3 uallrJ^\ sr pue .y 3o esodsue;1 ' uoulssaursrlq pue slsrEolourloal
eql palFc sr Er uaql '€r xrJl?ru utunloo E Jo sluourala 'sreeurSue 'slsrluercs ,{q pasn sed,{1 1ue1;odrur aql 3o
8urpuodsarroc aq1 pnbe f xrJl?ru ,roJ Jo sluetuale JI euos qlrl\ sollesJno ezu€llrureJ Ileqs s^\ .relduqc sn{l uI
" .sldecuoc plueruepunJJo uorleluesa.rde.r ledord.ro srroJleJ
xlrlel4tr utunlo) ro u go esodsuur; ,.2 -nclec Jo JnoqEI Jo uorlcnpeJ elulrlrceJ o1 ssd,{l .reu Bur
^rog -l€1nruJoJ,{puelsuoc aJE srrerJrler,uaql?htr .suelqord go
0z :89 '01 : zg rg
'09 : uorlnlos eql ur pasn secrJluur jo sad,(1 ,,(ueur a;e ereql
sB 01 peJJoJeJ
eJ? Slusr.uala slJ 'xrJl?ru ulunloc B pall€c 5sJoJaJsql
uollJnporlrrl l'z
sorlJtBtr^tr Jo sad,{1
z rilirvHJ
7-

8 MATRIX OPERATIONS ON THE COMPUTER

FORTRAN statements Explanatiort


TEMP: A(l) Value of element ,,l, is temporarily stored in location
TEI\4P; variable TEMP is given the ralue of .,{r.
A(l): A(3) Value of ,4, goes to l' autolnatically erasirtg its oid
value.
A(3): TEMP Value of TEMP. i.e. old value ol ,4, goes to l*
automatically erasing the old r,alue of l:r.

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

N:3 N stands for the trttntber ol telnls ol .4 t'r -8.


DO l0 I: I, N I becomes l, 2. 3 in succcssion.
l0 B 0): A0) Terms of B are giverr the values ol the co:tesn.lilding
tenrs of l.
J'l rNlud
f,.I CVEU
.t s! (l
-) Jo 3tllu^ elnlosgu aql luql oJu sluaualBls lu8^olal aql
Jequsuau 'sr.uJat eA- Eururuluoc s,(e:.ru ot alqrrrldde 'esr,\-rrrulrlor .ralndruoc aql ur palots aJB sluauola eql
uur8'o.rd eql sa{uu eulu^ altrlosqtsJo asn '01 :ea f sl osneJoq alqrssod sl 'luerueEueJJu Suixopur-11as puu
slql
lueuelo lsa86rq oql']l?nrJoJ-l ur 'suunloJ S o^lllrcesuJa sldrrcsqns aql Surlilruo '3 feue eloq/$ eql lurrd .ro pea.r
ur lua[uela auo 'tsr/h-,\ror paqrund'xulutrr ua.rrr8 aqt eq o1 raludtuoc eql lJnJlsur ,(ulu a,^tr 'o,rrleurallu rru sV
or osl (o's-rs) rvruUor r
l'ot' :y
i0r 0t 0zr (r 't : f '(z 'l : | '(f 't) f,) ) 'f JNIUd
loe oz orJ (E 't : |'(z 't : I '(t 't) J) ) 't (IVJU
lal Jepurl sE aq usrll lll,rA strreualels l_Nlud pue cv:Iu eql.
'sruln:rruud str lu!.rd puu 1 ut lueuale (an1u,r, qq '09qq '0fqq ' 09qq '0zqq 'Orqq '0 r
alnlosqu) lsaSSrq oql pu$'.1! lur.rd 't! p?or o1 ;alnduoc aql '/rr\Olaq SP
lcnJlsur '€ X e azrs Jo F xuleru .ruln6uulcar ? ua^rC asr^\-uunloJ paqcuncl aq oslu ,ruur Xaql 'pJeJ €lup aq1
9'Z 3-rdt^tvx3 uo esrl\-A\or paqcund e.lp sluaurala 'as"J e,\oqu eql ul
'
09qq' 0sqq' orqq'Otqq' Oaqq'0 Iqq
patut.rd Unsay
CINS
'a^oqP su
le[uroJ puu acuanbas auus aql ut palur.rd alu sltralual3 (z'i : I'(E't : f '(t'r) J) )'t tNlud
(o'scs) rvr dor r
'ppal eJ? zs;r puu ..J .t.J slusuela
pue Jaqlouu JaUp euo t '7, 'I saltle^ seLultssu 1 uru8u
:Z seuoJaq I uaqA 'uorsseJrns ur pBaJ alu tI3 puu,;t,
lrp sluauala snql '€ pnu Z'l saruof,aq ,{lanrsseorns 1
'l : I lsrg 'lsl[ Surxapur-j1es 3ur,{1dr.ur-gq e sr srrll (z 'l : 1 '(r 'l : f '(t 'I) f,) ) 't cvau
'paqrtads sr 3 ,(u.r-ru Jo azts aql (E'z)r NoISNst rcr
tuorlotrnldxl LuntSo.td NVyJVOt
qq '09qq 'Osqq 'Orqq 'Otqq ' '
0zqq 0 l stlql .]uarusla eql Jo
se ;uoddn ,(rur pruc arl] Jo sutultloc 0E uLunloc aqt'/ puu eqt JoJ sptrBls r lducsqns e.leq,r,r
^\or
lsJg aql 'pluc e18urs e rro surlrnloJ S o,\rlnJasr.roc ril 'LD su ol parraJa-r elts J Jo stuauola aql 'sutullloc
teuJoJ-C ur parplrnd aq fuur slr.lsruele g aqlJo ssnlu^
aqf Jo Jaqrullu orlt '[ puu s,\\oJ Jo Jequrnrr eql salouep
l'os os orl a a.req^\ '!->.a ezls Jo xrrlpu.t .luln6uulcar E pall€J sry
:J lal
Lor or orj .,(rrurrrooru,(. l-'J
ttJ "rl
foz or 0f I : r_
'll lurid prrl? pvJ.r e1 .relndlnoc e111 ' L''J ''J "Jj i-o; ot oei
lcrlJlsr.lr 'EXZ azis Jo J xul?ru -ru1n8uu1ca.r ? u3i\t! se uallr.r.\\ aq ,{uttr J xr.r}€Lu .urs11ud slql 8ur,to11og
s'e lldt^,iYX3
0a 0t 0E z ^{od
'umllloJ 'pu6 orlt pue ,to.r Eur 0z 0t
-l?crpur ldrrcsqrrs tsl 'elqpr.rul paldr:rsqns-alqnop r {q
0E I ^\ou
sa8tto.rg s'DuDuDg salddy
palouep sl J eM xutpru reln8uulcar E 'NVUIUOJ uI
'xllleut -tuln8ue t utunlo) z utunloJ I ut.uqo)
-ical ? Jo seseJ rulncrlled eiB saculuru ururlloc ptrp : Jepurl sE po]tslnqcl eq ,(eur slnl{ or{I '3Aoq"
^\oJ su lslals?q eq] qlog rrr slill{ aLIl 3louep J xrJ}E[r le.I
l"ql eloNl ',(e-r.ru leuorsueLulp-o^u pallec osll? sr J
0z : Urunloc pJ[ puP "
lsl eLIl Lrr luet{-lalo : 8) x!$s4 ruln8uulcay
^\oJ 9'Z
sSJIUJaI.l{ do sairlr
10 MArRrx opERATIolils oN TrrE coMpurcR

FORTRAN program Explanatiotr

M: 3 M stands for the number of rows.


N: 3 N stands for the number of columns.
DIMENSION A (3.3) Size of A is specified.
READ 1. (A(I,J). J: l, N), I: l, M)
PRrNT 1. (A 0.J). J : 1, N), r : l,M)
BIG:O Variable BIG is given zero value.
IROW : I l, i.e. rorv llumber of At, to IRO\\'
goes
ICOL : I l,i.e. column number of ltt goes to ICOL.
DO 10 I: l, M Cousider rows 1 to M, one by one.
DO l0 J - l.N Consider columns 1 to N, in rorv I, one b1'one.
AB : ABSF (A (f . J) ) Absolute value of A (I,J) goes to AB.
IF (BIG AB) 6. 10, l0 BIG is compared rvith AB, the absolute value of term
- A (I, J). If BIG is equal or greater. control goes to
10. or else to 6. Note horv equal terms are
skipped.
6 BIG : AB BIG is assigned the absohfte value of the bigger term
Aij.
IROW: I Row number of the bigger element A6 is assigned to
variable IROW.
ICOL : J Column number of the bigger element lr7 is assigned
to variable ICOL.
l0 CoNTINUE During the execution of the Do loop, BIG is compared
u'ith a// the elements of ,4 and assigned, every time.
the vallre of the bigger term. if any. The rorv and
column nnmbers of such a bigger term, if ally, are
preserved in locations IROW and ICOL.
PRINT 2, IROW, ICOL, BIG IROW and ICOL are printed in l-format in consecu-
I FORMAT (9F5.01 tive 5 columns - rvidth first. then BIG in F-format in the
2 FORMAT (2I5, F5.0) next 5 colurnns.
END
Result printed
bbbb2bbbb3bbb70.
If all the terms of ,4 rvould have been zero, the printed
result would sirnply give particulars of the first term
Art as
bbbblbbbbrbbbO.

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.

FORTRAN statenrcnts Explanation

N:3 Total number of rows or columns


I
-''
I stands for row or column of A2".
C FIND PIVOT ELEMENT
BIG:0
IROW : I
ICOL: I
DO10J:I,N Consider elements in rows I to N.
DOlOK:I,N Consider elements in columns I to N in rou' I.
AB: ABSF (A(J,K)) Absolute value of A1k goes to AB.
BIG is compared with AB ; control goes to 2 if BIG
IF (BrG
- AB) 2. 10, l0 s less, or else to 10.
2 BIG:AB Absolute value of Aik goes to BIG.
IROW: J Row number of bigger element
ICOL: K Column number of bigger element
10 CONTINUE
C EXCHANGE ROW IROW WITH ROW I
IF (IROW - l) 21,21, ll Row exchange is done only if IROW is greater than I.
11 Do20J:I,N Consider elements in columns I to N.
TMEP: A (I, J)
A (r, J) : A (IROW, J)
20 A (IROW, J) : TEMP
C EXCHANGE COLUMN TCOL WITH
C COLUMN I
" 2t IF(ICOL -l)31.31,22 Column exchange is done only if ICOL isgreater than I.
22 DO30J:I,N Consider elements in rows I to N.
TEMP: A (J,I)
A (J' I) :
A (J, ICOL)
30 A (J' ICOL) : TEMP
3I CONTINUE

2.7 Equal Rectangular Matrices form a 2 x 3 rectangular matrix B: A.


Exlwlr 2.10 The two matrices are said to be equal when
Given a 2 X 3 rectangular matrix i. number of rows in both are equal
ii. number of columns in both are equal
rl23\
n:lro iii. corresponding elements in both are equal.
5 6j Thus,
'lr ezrs Jo JepJo Jo eq ol prES s! lr 'suurnloS .lsln8u?lJal B Jo Js"c JBlncrlJud s sr xulEtu aJznbs V
e s1Y\oJ : u lI 'SUtunlOJ Slr lunbs S,r\OJ sU 'xrJlBrU xlr18tr^tr arBnbs 0I.z
'/.ty luauralo ol seo8 enle^ oJeZ o: (t't) v oI
N'l:f0toc
I'l'l:l0lOA
v Jo surullloJ €:N
vJo s \ou Z:IAI
v Jo ezrs (e'z) v NorsNaI trIct
tuoltotto1dxg stuautatDts NYvJvol
'xrJleu -ole stJ IIB scq € x Z azrs Jo f xrJluru :uln8uelcar y
ot?z Jo llnu 3 sr: ua\ou{ sr xrJlsur 3 r"Icus zl'z sldnvxg
'relndruoc eql uo p' ol"JeuaD 'oJez
ol lenba sluau xrrf8t{ oroz ro llnN 6'e
'pellrlllo osle sr Q Jo Eurlu116
tueurole
.{t2 p
Eurpuodsauoo eql Jo onl€A eql uazrr8 sr fg luauelg (t'r)c:(f'I)c OI
'c A\oJ Jo
JO Cr Jo f ur,unloc JaprsuoJ N'l:f0lOA
D Jo uulnlo) to o Jo I Japrsuo3 I,\l 'l : I0l OC
^\oJ
o Jo s1noJ Jo, Jo suunloS E:N
o Jo suunloJ Jo J Jo s/t\ou e:tr^{
o pue, Jo sezrs (z 'e) q '(E'e) f, NoIsNahtIC
ttoltouo1dxg sluauatots NYvJvol
: Jepun sB
eJ? stuouoluls Sururcuroa 'e^oq" saldurexe oql ur it il :"
peumldxe su puor puu poqcund sq f, Jo slueruole erll le-I Ir Ii
xulertr reln8ur:lcer Z I x u ruJoJ
,C Jo tC: O
se uellrJ,rl ueuo sr pu€ J go esodsuerr eql pellec sr O
{t3 : {t6 i: I il:,
xrJl?ru rulnSuelcer € x z 3 uaArg
su [11er
-qoqufs palels aq feur srql '3r Jo suurnloc puu s^\ol I I 'Z lr'rdr^lvxl
Eur6ueqcralur ,{q peurelqo sr O xrrlul,u luql realc s! U xlrlBtr^i reln8uulray u 3o esodsuuJl g'Z
(t'l)v: (r'l)s oI
'J ,\\OJ Jo N Ol I SuunlOJ uI StruaiueJ3 JaptsuoJ N.I-fOIO(I
'g Jo v Jo N ol I slvroJ raprsuoJ hl 'I
: I0I OO
'9, to Y ur suunlof, Jo Jeqrunu salousp N
€:N
'g Jo t/ ur s^\oJ Jo Joqunu salouap trAl e:W
uoltoun1dxg sluauQlDts NYvJvoI
ltY :11g fgs
sl, polBls aq ,(uru srqt Lee l]: "
"!1ucr10qu,(5
gI NOIICNCOUINI
t4 MATRIX OPERATIONS ON THE COMPUTER

2.11 Upper Triangular Matrix : equal to zero. In particular, Azr: An : Asz: 0,


i.e. row number of the zero element is greater than its
Exlupre 2.13
column number. This may be stated symbolically as
Given a square matrix of order 3
Aij:o for i>j
n231
,{:lo I 2i Such a matrix is knorvn as an upper triangular matrix.
For computer work, the zero elements need not be
Loo4j punched on the data cards. The remaining non-zero
instruct the computer to read it from suitably prepared elements may be punched row-wise in F-forraat, in 5
cards and print it. columns width as

This matrix has all its elements below the diagonal l. bbb2. bbb3. bbbr. bbb2. bbb4. bbb

FORTRAN program Explanation


N:3 Size of matrix
DIMENSION A (3,3) Size and type of matrix is specified.
DOlOJ:2,N
K:I-l
DOI0J: l,K
l0 A(I,J):0 l',':o l'4":o
READ l, ((A (I, J), J : I,N), I : 1, N) Note the indexing. When
I: 1. J: 1. then 2. then 3
I:2, I : 2, then 3
I:3, J:3.
Thus only non-zero element s are read.
PRINT 2, ((A(I, J,), J : 1, N), I : l, N
l FORMAT (6Fs.0)
2 FORMAT (i3F5.l) /causes skipping of a blank-line before printing. This
facilitates reading. 1 in F5.l stands for digits to the
Result printed right of the decimal point. For bi-q rtumbers. more
bbl.0 bb2.0 bb3.0 column rvidth may be used.
bbO.0 bbl.0 bb2.0
bb0.0 bbo.0 bb4.0

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

2'l4scelerMetrix This is a diagonal matrix havin-e all the diagona


Exelrpr'r2't6 terms equal to 2. Such a matrix is known as
Giverr a 3 x 3 matrix a scalar matrix. Its terms can be formulated
l200las
A:io 2 ol :2
l.o o 2l .q,i

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

bbb2. bbb0. bbb0.


bbb0. bbb2. bbbo.
bbbo.bbbo.bbb2.

2'15 unit or rdentity Matrix idenlity or unit matrix. It is denoted by I or u. The


In the above example, all the diagonal elements equal procedure for formin-e it on the computer is exactly
2. If they equal l, the diagonal matrix is cailed an as given above.
(tL6tlgZZ-SilZ
'Oqqq '?-qq's-qq
'rqqq'0qqq'z-qq
'eqqq'zqqq'oqqq
pagg.td tlnsay
(IN3
(o'sce)
rvnuoc z
*.v__ztY.ttv_ : I?.V lztv _ _ rzy (N,[ : I.(N,I : f ,(f ,Iv)),2 JNIUd
(l'r)v-:(f'l)v ol
)'l:f0lOCI
I-I:)
N.Z: I OI O(I
(o'Ess) JVr^ruoJ r
'p€al eJe ttt' Puu t$Y '27'V .Ety .ztv .rry sutJal (N't : I '(N 'I : r ('r't) v)) 't cvEu
(E'E) v NotsNEI ro
sutunloc JO S,\\OJ JO J3qU.l11N €:N
uoltouoldxT wn.r8old TIyVJAOJ
'Oqqq ''qqq ' Oqq ' Eqqq'zqqq'0 '11 turrd PUE sP.luc
su surunloc a^rlncosuoc E uI 'trutuJoJ-J UI peqrund .i1quilns ruo{ ll peo-l o} ralndruoc oql lJnrlsul
asrlr-,{oJ paqcund eq el8uurr1 .raddn eqt ur sluotuale
9 oql leT 'sluotuala pEaJ eqt o1 8ur:re.;ar ,{q sanlu,r Io n- E-]
pautrsse eq ,{eur sluouolo Burureueg '?l'Z pue tl'Z
lv o z-i:Y
lE T, o )
saldruexg ur peureldxe s" pBeJ pue peqcund eq paatt
{po (e18ueu1 ra,{\ol ro) e18uerrl .roddn eqt uI xrJluur arunbs g x € B ua,\rg
slusr,uele eql 'xrJlnru Jtrlaturu,t's-,t^a\s B pelluJ sI 'z :lrdhlvxS
8 t
xrJluts qcns 'oJez oJB sluaruele leuoEerp aql pue
zEy "
_ :tEV.tev _ :try,t"y _ _ atv ,XtJleUJ Slql ul xrxlBtr i rJrlautu,{g-na{S ,I'Z
tEy-at,Vl ttv:rrv ztY IiY (l'r)v:(f't)v oI
-
z:ai- r:r I:f
)'l:f0roo
I-l:)
_- I:) N,Z:IOIOO
7:I (o'sss) rvhruor r
'pBeJ AtB EeV .84r, .rzy .t'ry 'ztv .rrv Sluotilelg
(N'I: I '(N 'I: r '(r'l)v)) 't avau
(E'g) v NotsNgl,^uc
€:N
tuoltouoldxl stuawatDts NVvLvoJ
'(e 'E) p' lucrrlaurrui(s eJE sluoruolo oql snql '[v : [tv 'a'I
^{erre aloq,al eq} sa,r8 srqa 'siuauolo pner 8ur
zty _ xzv .LtV Eth/ .|zy ztv ,xr.r1utu Str{} ul
- -
-puodsarroc aql ol Eul.ue.;er ,(q sanpn pautrssu oq ieru 'ralrrduroc
sluar,uele Surur?tuor aql ueql 'g1'g elduexg ut sE aql Jo ,{routatu aql uI 1t Surpuar 3o si(e,t o,,ir1 uteldxa
pBaJ puP esr,r-/r\oJ paqcund aq ,(enr xrrlsr,u ru1n3uur.r1
.-\
reddn eqlJo 9 pue S 't'e 'Z'l "zl^ slueuele 9,(luo'Z igs ri
l- lE v zt,: Y
'g'i alduuxE IL L t)
Jo seurl oql uo xrJluru reln8uulcar u ss peJols pue xul?tuorenbsgxg B ue^rD
pueJ 'osur\-^ror paqcund aq feur slrrauola 6 eql llv'l
: eJB lr Eurrols pue Surpear .;o sie,,rr eq1 'xrJluru JrJl ,l'z r-Ianlvxg
-oruufs e poll"c sr xulcru qcns 'leuoEerp er{l lnoqB xJrfBtrAI cJrlauw,(g 91 '3
"
LI srSlurrw .!lO S.IdII
l8 J\IATR]X OPERATIONS ON THE COMPUTER

2.18 Complex Matrix numbers. I is therelore called a conrplex metrix. We nse


Exalrplr 2.19 FORTRAN lV as it f-acilitates their handling. To read
a complex number, its real and imaginary parts urust be
Giverr a matrix of size 2x 2 punched either irr F-format or E-format. Suppose,
Z : 12 + 31i, is a con.rplex number, then it may be
A==it +i l-2+3il where ri : t/ - t pnnched as
t +i i)
r 2. bb34. bb
instruct the colnputer to read arrd print it. It may then be read and printed by using statemeuts
Here the matrix l, contains elements which are complex follows.

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

FORTRAN slalenrcnls Erplarntiott


M:2 Rorvs or r
N:2 Columns of ,{
TYPE COMPLEX A Cornputer is inforured that rnatrix ''1 is con.rpler.
DTMENSTON A (2, 2) Computer is informed aboLrt the size of ,,1.
READ l, ((A (I, J), J : l.N), I : 1,il,I)
l FoRMAT (4C (F5.0, Fs.0))
PRINT 2, ((A (I. J), J : I.N), I : l, M)
2 FORMAT (2C (F5.0, (Fs.0))
Result printed
bbbl . bbbl . bbb2. bbb3.
bbb0.bb-l.bbbl.bb-1.

In FORTRAN II, the real and imaginary parrs of a I )l


-l
complex number are handled separately. For example,
AR:
0 1j
the complex number Z:12 * 34i is treated as a
combination of 2 parts, real say, ZP.:12, arrd imagi- AI: 1 3l
nary say, ZI:34. where ZR and ZI are FORTRAN
variable names. The variables ZR and ZI are then Note that
-r -rj
AI are treated as sinqle syurbols
A R arrd or
read from pr-rnched cards as any other numbers, as nanres of variables.
given belorv.
The values of the elerlents may be led to the contputer
FORTRAN statentents
in 2 rva1,s.

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

(iii) l2l ,4t _ v'r2 -


A:lyT, I3l2J [3
t 121 For further study read References (14' 15, 16.
ttz 312) 19, 21,22,24,25, 34,36, 4l).

"
: 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

Bananas Il'l Oranees The difference may be denoted by matrix D as

s 20s
I

Basket l:sl n f,r10 sl


l*l
,B 25
big
0j
Or synbolically,
If they are all put in basket C, express the relation of
Dii : B;i - Aii for i : 1,2 and T : l, 2, 3. Or in
fruits in C, A, and B. FORTRAN, D (r,J) : B (I,J) - A (I,J)
The fruits of each varietv in C rvill be
Ex.qMprE 3.6
Oranges Giverr rnatrices
Basket C
A: lli+
Lz
2
s
8
:l D: i'l 3
e) o 3l
3l
Or symbolically, 0 lt 0l i000'l
Cn: An * 8rr, Ctz: Atz * Brz, C,": Ar" + Br,, 1 u: io oi z:
ol lo o o
Czr: An -r Brr, Cn: Azz * B"r, Cr": Ar" + Br"
o I,o t) oj lo
obtainthesurns P - A + D, Q--. A+ Uand R A + Z. :
i.e. Cii: Aij I Bij, for i : 1,2 and j : 1,2,3.
Let M:2: Numberofrorvs ln this example D is a diagonal matrix, U is an identity
N:3:Numberofcolumrrs or rrnit matrix. and Z is a null or zero matrix. The
nur.nerical work on the cornputer can therefore be
FORTRAN statenrcnts saved by usirrg their properties.
DOr0 l:r,M In the sum A + D, only diagonal elements need to be
DOI0J:l,N considered.
l0 c(I,J): A (l,J) + B(t,J) In the sum l g U. only diagonal elements of .-l are
Exnlrple 3.5 increased by l.
ln the above example. find horv rnany rnore liuits of lrr tlre sum A + Z. elements ol'R eqr.ral tlre correspoud-
each variety are contairred in B than in ,4. irrg elements ol A.

FORTRAN statenlents Explanatiott


N:3 Rorvs or colurnns of the square nratrices
DTMENSTON A (3,3), D (3,3,), U (1,3)
DTMENSION Z (-1,3), P (3,3), Q t:,:;
DIMENSTON R (3,3)
DOt0 I:t.N Considel rorv I.
DOI0J:t,N Consider elernent in colunrn J ol rorv l.
P (r.J) .- A (r. J) Matrix P set equal to nratrix .,{
Q(r,J):A(r.J) Matrix Q set equal to rnatrix I
t0 R (r. J) .=A (r. J) Matrix R set equal to matrix I
DO 20 I .= r. N
P (r, I) = P (r. r) + D (r.r) Dii added lo Pii and stored in Pii
20 Q (r. I): Q (r. r) + l. Qii is increased by l.

Exnvpre 3.7 equals twice the corresporrding element ol matrix ,4


Using this fact, obtain C or-r the conrputer.
Given matrices
Symbolically, the relation of Cto A may
l2 4 6l
be expressed as
n 2
A: i; ; ;j B: A c: A+B: ls
3l
ro rzj
Cii:2 Aii
Here 2 is a pure number or scalar, hence this is called
it can be easily seen that every elernent of n.ratrix C scalar multi plication.
I nto.t to o zltl ltl r'Y lv z tl
1eE Pue Z : ,(q 1 tror eP1^lq 'I [l'i]:' i::l:"
sdalg
',(ltun ol lenba slueuala luuo8erp Eurleq ii
?):' ti 2):r iz ll :'
xrJletu ruln8uulrl reddn sI perlnbar ruJoJ aql 'V 'ssctrlBul Z X Z
oY se
€ JepJo 3lu?s eql Jo xlrl€tu,t}lluepr uB sl J pue eql .laprsuoJ ',^Aoleq peutuldxe eJ€ sJot{}O 'sloJoq
sA{oJ Jo Jeqrunu olu"s eql Sut,req xlJl€tu uunlos 3 s}
g
peleJlsltllr ueoq ,{peerle e^31'I Z puB 1 suorleradg
'xuleLu erenbs s sr U l€ql leslno eq] ]e pelou eq '(etu 11
t Z aleq,\\ o
',
pue 8r Jo s,{AoJ aql 'E
'uLunloc Joqlo auos ol uulllloc e seull ry Jo uolllppv
uo suorleJado eql pllelxe 'Z Jo suolluruJoJsrtaJl eql
Eurrng 'luouelo eql Jo enl€A euos selouep x eJeq/!\ ol)t
orsrl,AA reqlo euos 01 ,{\oJ € setull 7 Jo uotllppv 't
lr o ol "4\or
tx I 0l z reqlulltl
lx i iJ oJez-uou e .{q tttunlot Jo ,^^oJ e Jo uoll€cr1dr11ntr41 'g
ruJoJ B ol Z tuJoJstlu.il 'suolleJedo f'reluor-ue1e Sursg rel{lotr€ tllr,tr utul'lloo ouo Jo e8ueqc'te1tt1 '7
fr o ol [sor] i-os or sl Jeqloue qll,^^ 1r\or euo Jo eSuuqcrelul'1
io l oi r8t i lezstnt
'8 'suorleuJoJ
lo o Ii rvt ) v z) -suer1 ,(relueuele pellec eJe suoll?rodo 3ur'no11o3 eqa
)gv
suollBluroJsuu.rl,{ruluaualg ?'€
',l\oleq u.4Aotls se opts,{q eprs 1de1 eru Ix€ szls Jo
, pue'1 x g ezts Jo g't x € ezlsJo f 'seJllleu eelql (f 'r) v',c : (r't) v ol
6'[ lldl{vxg N'l:f0Iocl
'tl xtJlutu o1 1cr:luntnba er€ 3 ptle 'Q 'J 'g .I :
I,^\i I OI OCI
secrJleu oqlIIe 'alduuexa o^oq€ eql uI 'V ol tualo'l (s'z) v/'t : c
-mba eq 01 ples sr f xrJl€Lu Jatlloue tlo suolleulJoJ sluaualols
-suerl ,(reltteluale Jo ectrenbas e ,{q peululqo 8r xlllEhtr ^lYAJAO.I
serlrlrtr^J 1ua1e.t;nbX E' g u Jo sutullloJ €: N
z Jo s,A\ou z: lN le1
'I Jo'O 'J 'Br s.lcul€tu olul tz '1t ,(q s.raqtunu
xrJleu tuo{sLIBJ} sttotlerado ,(.tu1ueute1a esaq} snql
tua,rr8 eql flchlyntu pue roqlul'ltl l€ql Jo leco:drral oql
? xuleu senr8 'y Jo Z ulullloc ol I tlulnloc Eurllnser eq1 rrrulgo ol 'roqtullu a18uts e ,(q peptltp
alrq,r\ ql.ro.tt sr ll
Eurppe ueql pu" 'Z fq Y Jouturlloc 3o trorlucrldrlltr6l
I LtDll
oq ol eJB sloqunu ,{ueru uaqnt o5 'uotslttp
'o xrJl€uI atutt ssal satlnbat uotloctldtllnttr relndpoc aql uO '9lI
selrrB 'y Jo Z ,/t{or ol I ,t\oJ 8ull1nsar eql Surppe ,{q uorlecrl<Irllnu lnq Surq}orr sl 9 Joqtttnu ,(q uotst,rtq
usql pue 'z ,(q Y Jo I ,t\or Jo ttorluclldrlln;41 't'
'tay fe X Jo llrauole rlcee apt^I6 uI
', crJlBLu sa.u8 7 fiq V Jo I ulrlllloJ jo uorlurr1dr11n141 : ez7 lueuala eldruexa o^oqe eql tll
1se33rq eql sr 9
'gr xrJl€ru olur sllnser Z I l\oJ jo uollecr1driln141
Y Jo
^q, 8'g ]'IiIWVXA
: aloN
tty 7: tt3 (r'r) v ,,.'z : (r 'l) J oI
'l Jo I utunloJ Lll ltlouelo roplsuoJ N.I:fOIOCI
^\or :
'I ,r\oJ JaprsuoJ I tr .I I OI OCI
J ro v Jo suulrloJ t:N
ro v Jo s^\ou
J Z:htr
tuotlouttldxT stualuatus NVVJYOf
SNOIIYUAdO XIUIVhI 3'IdT\]IS
t7
24 MATRTx oPERATToNs ON THE COMPUTER

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 :

t0 10 l0l t20l l-2 I 0l row2 i:lto2


3. Multiply row I by lr, : 6 and subtract the result Aik: AitlAri fork:i*lto3
from row 3 to get row 3 (keeping row I un- Bi: BtlAt
changed) as Cit : CitlAii for /c:lto3
[0 28 36] {641 -3 0 ll row3 Aip: Ait< - Aii Aitc for k:i+1to3,j:i *lto3
The matrices now appear as
Bj: Bj - Bt Ai* for 7:i+ lto3
AB Cik: Citc - Cii Ait< for k:lto3, ,l:i+lto3
(1 ) A) (1) tl2 0 0'l
lo 16 rdl
28 36)
lzol 2 t
3o
0l
FORTRAN statements
N:3
[o lo+J lJ
Note that the elements below the diagonal in
Nl:N-l
column I of A are eliminated, or reduced to zero. DO 60I : l, Nl
This elimination procedure is now repeated on other II:I+1
columns of ,4. RATIO : l. /A(I,I)
4. Divide row 2 by Azz: l0 and get it as DO l0 K: II, N
1/10 0l l0 A (I,K) : A(I,K) 'r'RATIO
[0 I 1] l,2l l,-rl5 row2
5. Multiply this row 2 by Arr: 28 and subtract the B(I):B(I)nRATIO
result from row 3 to get it (keeping rorv 2 un- DO20K:1,N
changed) as 20 c (I,K) : C(I,K) * RATIO
t0 0 8l t8l lt3ls t4ls ll row3 DO50J:II,N
DO 30 K: II, N
Thus elements below the diagonal in column 2 of A
are eliminated. 30 A(J,K): A(J,K) - A(J,I) *A (I,K)
B (J) : B (J)
6. Divide row 3 by lgs : 8 and get it as - B(I)'i A (I, K)
DO40K-l,N
t0 0 ll tll [t3l4o 7120 l/8] rov3 40 c (J,K) : C (J,K) *'
The matrices now appear as
- C (J,I) A(I,K)
50 CONTINUE
lt 2 4) (7) tl2 o ol
io io ilrj Iti - t3l40 l/10
rls 0l
60 CONTINUE

lo |.'j 7l2o l/8 i Exlrr,tplr 3. l0


We may now program this elimination procedure. Given matrices A, B, and C as in the previous example,
Some points about the progrsm transform A to a r,rnit or identity matrix, operating on
the rows of B and C simultaneously rvith the rorvs of
1. N:3 for the sizes of matrices A,B, and C.
stands
,7.
2. We omit reading and printing of matrices A, B, and C.
We give belorv 2 methods of solution.
3. It is waste of time to ask the computer to set the
elements equal to zero or l. This work is therefore LlethodI .' Sleps
omitted. As no further operations are done on l Following all the steps of the previous example,
such elements, they are left out of consideration. transform A to an upper triangular form and get
4. Elimination operation denoted by I is repeated Nl : A
N - I : 2 times or done on the first 2 columns of I 124)
or on the last 2 rows of l. io l li t7lltt200l
i2i i-l/s r/10 0i
5. As division takes more time than multiplication on lo o rj [rJ l. r:i+o 7'l2o l/8J
the computer, the reciprocal of the diagonal element 2. Multiply row 3 by Au: l, and subtract the result
lrt is stored under location RATIO. This variable from row 2 (keeping row 3 unchanged) to get row
is then used in multiplication. 2as
: el€ ENNIINOf, OOt
ocuonbas ur pe/$olloJ oclnrulo1 llzJrtutuelJlutu ot{l '? sNNIJ-NOJ 06
'l .lo o:az o] slrraluaio 3ur11es Jo l-ro,^ atlt ]rruo eu\\ 'f (x't ) f,,,(r':'f) v-()'f) J : (x'r)f, 08
'sacr-rlsru fo Surtttr:d puu Surpua.t lrulo ai1'U tl'l:)08ocl
'J puu'g'y selulrtu Jo sazrs 5q1 .toJ spuuls E - Ir{'t (n)9,.(w'l)v-(0s:(0I
tup.tSo.rd )qt lnoqD s1u1od aLuog -I .I : f 06 OCI
'ir 3ur I+'I:W
-ur?lqo Jo spor{l?lu luul.rodrut Z ot.ll sJte.usnllr elduexe I-N:-I
slqJ 'uorlucrldrtlrtu lut1133 ,{q pagr.ra,t eq feur srql IN.t:IOOIOC
'rh' 'o'l ';z xul"tu ue,lt8 eql Jo osto'\tlt otl] st paulul I-N:IN
-qo J xrrlunl l"uu aql lut{t 3.Iaq petlollustu eq ,(uttr 11 sttorualDts NVVJYoJ
'elo.Joq sE
'o.rez ol 1es (ldurrs oJu slttottlole potcs.Uu sll
l's n €l il Ir 0 0i sc xr-rlptu trr saSuuqr p;oJoJ o] f;essecattttu st 11 'y
rE 0I- lT.- 0tI !I lo l ol t/
Loi- eE- ol i-t [o o r,l >1,u3 >(y' a$ :7J3
-
se .ruadde socul€tLl aql '€ €olI:-Y
^\ol (rrr)
tzY 'Z /t\o; ttro.g lru-rlqlr5
pa8uuqr aql seturl 'I : ug*[y-lg:[g
.[ 1r\O-]
: tr, 'l Tolt:/
pafiueqc aq] saturt '7 tuo.g lce.r1qn5 (rr) l+l:tu
^\o-l
'S =: 0e
P' luauel? F-luoSerp Xq g ,uo.r eplnlg (l) l-E==!-u:l
d1p:rluaubas og 'g
Zoll:!
lt slvt s/€ t igl fr 00.l : are DOSII aplllLu.roJ l€Jr]€tuatllutu pue sloqtu,(s eq1 'g
l0 0l/l slt, -
0l16 'surJJnioc.Io s,\\o.l T: 1 t.
losrt - i, i;i ;?j -
pe8uutlc SI tlollutlltull!['Z
se luadcli; seJr.t]1llu etll 'z
: I - N: It{ tlo auop 0q ol A\olt
^\o-r 'e-Iaq
oql sautrl'37 : ttv 'f A\oJ tlro.U lcellqng (rrr)
'z pepnlcur eru stuetueteis Stttutetuel aqt ,(1u6 'eldurexa
^\o.t stror.ro.rcl er[] ur
uallr.I.\\ sluaulal€ls ttD.tJlol oql llwo ei11 'I
pe8uuqc ?rll satull A\o.t tuo{ lcl?llgtlS (
'7 : zr, 'l rr)
'Ol:7'vy ( wotSo.td aUJ ttnqD sltnod atuog
r)
tuaurJl3 luuoSerp (q 7 nol apl\l(I
,{llurtrrenbss oG'z II TI qt rl
is irool
IC 0r - tz- ri r0 r 0l
r) r-i sz ol I
let l.or 9r'- 0I IJ Lo o rj
0l
ir t z I
i0 irsl !01
!0zl
l.r z ?j ) I Y
fo o zn: ttj sc .reedde ,(11eug
JSv 'I.ro/^{ rrorluLtrJoJsuurl aqt solaldruoJ
soorrtuul eql srql
'6'g ayduruxE3o g r/als ur stl readde A\otl secr,rll?tu otl f
'I A\oi aql serun g:t'Y '€ tuo-u lcel]qlls (lll) rnlo'r lrlt- otl6- ,lt I ttl to o Il
^\ol
'l arll serurl l: tzv 'c_,/\\o.l [tlo.IJ ]Ju.Ilqrts (ll) se I 1aB o1 (pe8ueqcun
^\o.r ^\oJ
.Z : ttv fq [ opl^ig (l) U A\o.r Surdeal) I ,ry\oJ urou lltlsJJ eql tc€rlqns pue
^\o.r 'f,: zr, [q I ,nor ,{1drrpr14 'Z urunloo ur luolu
.,(llurtirenbas og '1
-a1e ltuo8erp-Jo oJoz-uou auo ,(1tto sut€lueJ eJaql '?
sdatg
'oJaz ol pornpa.I Jo polsulLuIIo
'ulunlos lxeu eql aJ€ [ uunloc nr stuauela leuo8urp-go eql 11€ snql
o1 uo sstd oA\ o.Io1oq ttulttloc fttc ttt sluewelo 1erro8
-"lp-Jo aql lll? ollturrur[o aA\ poqlolt-l srt{l tlJ 'e18uelrt luot l7l1- slL- sir- I Ie I to 7, tl
J€,\rol e![] ur sluetuela leuo8urp-go eql Sttrluttttutlo leUts s"I
,(1uo pereurrurle eJo,\r 71o elStrur.rl -raddtr eql ut slrtotu .no: le8 o1 (pa8uuqcun E Eurdeal) I i\\oJ luor3
^\oJ r(1dt11nNg
-e1a luuo8erp-go aql 'a,roqt: uairtS poqlatu ls.lg eql uI llnse.r aql lJ€Jlqns pue ';, : "v f,q €
^\oJ
z poqla I4l Tdto"tlsll- nlt- onlrc-l ttl Io I o]
fr sNorrYuSdo xlurYtr[ a'Id]$s
26 MATRIX OPERATIONS ON THE COMPUTER

i: I to3 Express the relation of apples and bananas distributed,


Bi: BilAii with boys and girls.
Aitc: Ait<lAir for /r : i -f I to 3
The lruits obtained by boys and girls are as under
Citc: Cl lAii for /r : I to 3 :

"/: I to 3 excepting.i: ; Apples


Bi: - Aii Bi
Bi
A;1c: Ait - Aii Ait, for /r: i * I to 3
Boys l0x2 *
20x3 -i- 30x4 - 200

Cit': C.1t; - Aji Cit; lor /r .- I to 3 Girls 15x2 *-l0x3 + 5x4 - 80

5. PIVOT stands fol tlie diagonal elerrlent lii. Bananas


FORTR.AN statentents Bo1,s l0x4 = 30x6:260
-l- 20x2
N:3 Girls 15x.4 = l0x2 -,- 5x6 -- ll0
DO 60 I: I, N
PIVOT == A (r.I)
Let A be 2x3 matrix denoting the distribution of
bo-v"s and girls in classes.
B(r)-B(r)/Prvor
II:I+I be 3x 2 matrix denotins the distribution of
DOIOK:II.N frr-rits in classes.
10 A (r,K) == A (r,K)iPrVOT C be2 x2 matrix denoting t.he distlibution of
DO20K:l N frr.rits anrong bo1 s and girls,
20 c (r,K) -- c (r.K)/Prvor
DO50J--. l.N theu

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

3.6 Matrix Multiplication i:1.2: rolv ol A or C


Exa,uprr 3. I I .i : 1,2: colLrnln of B or C
The distribution of bovs and sirls in 3 classes of er k : 1.2.3.,- column of A - roq' of ,B
school is as under :
fi stands lor sr,rrnmation of
terms for all values ol /r
Classes for el'en, possible combination of i and.i. For brevity,
/r irr the symbol f is omitted, it being Lrndersrood that
Boys t0 sunrmation is to be carried for k, the synbol repeated in
Ail; Bt;j. This is called matrix multiplication. It wilI be
Girls seen that the second matrix viz. B should have as many
rows as the number of columns of the first matrix
Apples and bauarras are distribLrted to each one in the
viz. A; otherwise multiplication is not possible. Thus
class rooms as under :
nrr-rltiplication BA is not possible. Matrices A and B
Apples Bartarrtas are said to be conformable lor multiplication AB
Class I 24 but not for 84. If matrix ,4 is of size m x /, and
Class 2 _\2 matrix B of size / x rr. then the resulting matrix C will
Class 3 46 be of size ilt x n.
,{q uo,t rB t 'Z 'l: { pu€ t '(, 'l : ! roJ {tV tg : {t3
r(pee1c aJ€ J xuletu Jo sluotuole oJez-uou eql seuocoq ueql €llltuJoJ
'pepro^" eq 01 spoou 8r Jo rz uI Jeqlle sluolusle uorlecrldrllnut xlrtEtu stlJ 't : (€) A 'g : (Z) C
orez ,(q uorlzcrldrllnru (rr) puu 'pBeJ pu€ peqcund eq 'Z : (l) C snqJ. 'C uotl€col ropulf iV t Z1
tou peeu g pu€ r'Jo sluaruele oJez (r) >1rolt JellldutoJ {zuu lzuorsllorurp eLIo B s€ peJols sI xtJJeu leuoSetp
ro.{ 'ru1n8uer.r1 Jcddn erp g pue Z qloq treql eloN aql '.ralndruoc eq1 uI oceds ,(rotuetu elJesuoc 01 1y\oN
'8Y : il rrr"lqo E 'Z 'l : { pue t 'Z'I : ! JoJ IY lg : !t3
'se pesserdxe eq ,{eu
oolloool
r 0l :s ls ? 0l:v srqt ,(11ecr1oqu,(5 'O Jo $ueluele puo8erp Surpuod
ti s L) l.E z t: -seJJoc eqt ,(g Z Jo s^\oJ Sutpttodserroc oqf 3ur,(1d
secrJletu reln8udrrl :eddn 7 ue,rrg -r11nu ,(1durs ,{q peurulqo eq U€3 J Jo S.tor eql 'st 1zq1
e I'E a'r.r^vxg l'sE zt 8zl
lSt sl zll :J luqlpagl-Io^,(yrsteequ€cltueql
!IONIINOJ OI Ts v T,)
(r't) v'.(l) c : (f 'I) J /l o'l
N.I: f OI OCI
le 8 lv o
s vt :v lo € ol -o
N.I:IOIOCI lils i r! to o z)
rar
E:N 'vxo:3
(€'€) v'(e) c NotsNaI Icl lcnpo;d aiil purC 'ozts E x € Jo XIJJELU ror{trotle sI }
sJualuatDts NYYJvol 'cr ettl?u olqeIJBA orll Jspun ,{urru leuorsuolulp-ouo
€ su peJots '€xE ozrsJo xlJleu leuo8etp E sl O
sr 1l
: s,4\olloJ
sB uellrJ/( eq ueql feur suorlonJlsul relnduroc eql zI '€ aIdwYXE
'l'l.l'l'l.l'l'1.
se ,("ru,l ) 'I 'I soctpttl eql dn
atg X azg X azy I zrg X rdy :zzJ
"dy +
rtg y tzV + t6g X ztV a trg X tzy :tzJ
Et'g y tty + E.g X ztyt a zrg * uy :23
X
rtg y trV r.g .tV + rrg y rrpz : rr51
+
osBc slql uI ',(russac3
ere sdool 6q (reqlcue urqlr/h euo) pelseu t 1eql olotl
'suorllppu e^rsseccns ,(q paurelcio eJs J Jo sluaruolg (f'>t) g,, (x't) v + (r'r)c:(r'r)c ol
€r Jo A\oJ .ro u Jo uujnloll -I'l:)0IOC
'suo)
-rpp? ollss€ccns JoJ lr seredeld pne 13 o1 sao8 oreT o:0'I)J
c ro g Jo sulunloJ N.I:fOIO(I
J ro Y Jo ^\oll }T.I:IOIO(I
gr Jo sA\oJ to Y Jo suunloJ g :'I
J Jo g Jo suunloJ Z:N
c Jo y Jo s1r\ox z: tN
uognuoldxg staauatrys NYvJvol
17, sNolrvulldo xlurvn alall4lls
28 MATRIX OPERATIONS ON TI{E COMPUTER

c1 : AyBl Note that matrix C is also upper triangular.


cp: AlBp *" ArrBrz l7 t2 t2), The general formula for multiplication, therefore,
Cs:- A1|,8:6 * ArzBzt t AnBn C : lo rz 131 becomes, for n size matrices
C22: .y'22822 Loo6j Cii:2AiiB*i for i:lto n
C2x: A2282;1 + AnBsts k j:ito n
Css: A;esB3s k:itoj
FORTRAN statetnents Explanation
N:3 Rows or colttmns of A or .B or C
DOlOI:I,N
DOlOJ:[,N
c(I,J)-:o

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.

Exlupre 3. 14 An : (Cn - ArrBr, - An 8",]) f B;JB


A22 : C22f 822
There are 3 upper triangular matrices of size n : 3, Ar, -- (Cr, - A22 Bij.),i B,r.r
such that C : A B. Matrices ,B and C are as given in As: C3.1f B.jx
the previons Example 3.13. Find ,4. Thus the elements ol I carr be determined rov'll.'ise,
In the previous example we worked ottt the values of usiug the expressions
6 elements of C by using 6 eqlrations. An inspection At: CiiiBii for i: lton
Aii : (Cii-Z A* Brj).'Bij for i: ltorr-l
of those equations rvill reveal that they can be used to k j:i*ltort
determine the 6 elements of matrix ,{ also. The equa- k:i to7- 1
tions can be recast as : To translate these in FORTRAN is simple. Let the
A1 : Clf 81 , An : (Cr,'. - A:|,BP.tlB22 size ol the matrices be denoted by the usual symbol N.

FORTRAN slqlet,teilts Explanatiort


N:3
NI:N-I
DOI0I:1,N diagonal elements calculated.
l0 A(I,i): c(f, t)/B(l.h
DO20I:1.Nr
II:I+I
DO20J:II,N
suM:c(t,J)
JI:J-I
DO 15 K: I. JI
15 suM : suM - A (r. K) *B (K.J)
20 A (I, J) : SUM/B (J, J)
lsztt o ol sa,lr8 uorluloJ srql 'I: n X JeptsuoJ
lcr/r - ttc ol x '^\oleq ,(ltuepuadapur sdels eql
rgzlt tlt - e lt ) lno {ro^\ e,\\ asec luulrodur srql Jo Surpuels:apun e1e1
ttlt - : t.fl I "^n "x - : tax rtx -lllocJ ol Je^a,!\oH 'SI't puu y1 'g salduex3 snor,re:d
f
gzl t : L:ttn (t:?.n zlx 1,- 'trn trx)
- : r.rr s? por.rrslqo ,(Fsea eq uoql Kew I to3 suorsserdxa
Li
I - :ttn /ttn ttx - - i'tx
gzlL:"'nll:"x oql 'oraz sluourele leuoEerp-Jo sll 11e Sur,req g1'g
'LlT, : ,','n lI : ^"X 'alI : ttn ll : ttx eldurexg jo 3 ',(es 'xu1ur ruln8uerrl reddn u€ JO aset
ro .relncrlred e sp paleprslroo oq uuo xrlluru ,tlr1uapr uy
tr:n l:;x + ltr.n ai.x:0: t,.7
t:,.:n tt,y
x puu
* trp ar* -l .rrn ttx : : st1
0 I tlsz o ol lnn o ol
aan ?rX :S zrp try :
0 : zr1 I I |lL 0l . l'"n ""n '"n l:n
tt:n lt;x :zan zdx : rr2 tty : | : !!I I o r L) 'rt'tn ''n "n )
ro JI
[rool 'r"''n 0 1"",Y o ol 'xrJlBru r(1r1uapr Lre sr/ ajeq^\ '1 : x n : n x l?tll qcns
itdn ,rn0 0
,,,si 't: u azrs Jo sacrJleru relnSuerrl reddn g eJe eJoql
t3r?l Lt'tl "tn n, l:1I :7,
I n X gI '[ 3-rdv(vx3
(t't) v/runs : (f 'D s ot
(f ')) g*()'D v - t^{ns : htns oi,
['It= )Ozoc
(r't) I == I/{ns
N.II:fO'OC
I+I:II
.I-N:I
tN't -'I0[ oc
I_N:IN
'patulnolEr sluauelo Jeuo8erp IIv (t't) v/(t'r)c: (t't)g or
N't : I 0t oc
J ro g -ro Jo srzrs € =N
tuoltouoldxE ', stuatualws NYvJvol
'NVSIUOS ur papoJ oq feur srqa zaylza3 : zzg
^\ou ttYfz) : ttg
{ott+t-l
uorla.r:/' ry : s" uallrJ/hal 3q u?c
I ol I -tI : I roJ ttyl(:tg 'ttV tt3) -= {tg suotlunba sql 'oslu dr xulsr.u Jo slueuela 9 aql autruJolsp
r{olI :! -roJ = -!!Yl!D:!!g ol pasn oq ueJ feql leql lee^eJ IIIA\ suorlenbe
suorssardxe eqt Sursn osorll Jo uorlcadsuruV 'suortenba 9 Sursn ,{q 3 3o sluour
'osrl\ntol peuruJolep oq UBJ gr Jo slueuele eql snql -ole 9Jo sanlel oql tno palJo,\{ e.\\ tI'g elduexg u1
_
,t{l(rrg ttv t:dg dtY _ tI') : ttg 'g pulJ '91'g elduruxa ul
t Yl("rg z.tY _ dtc) : zag ua,u8 se eJs
J puu p' saJrJlBI [ 'g y :, lsql qcns
ttYrts : trg 't: t, ezrs Jo seJrJl€ru rulntuenl raddn g eJB aJer{I
urYl(rg tzY
_ tz'}) : ezg sI'€ afdr{Yxg
6Z sNolrYulldo xtutYr{ aldtrrrs
MATRIX OPERATIOI.IS ON THE CON{PUTER

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)

L:N_. 1 Last but one row - 2


DO20I:1,L
K: I+I
DO20J:K,N
20 C(I,J):0 Elements of C above the diagonal are now set to zero.
I-!ot{:1 az.YfzzC _ zd&
I-folI:.,l' !
-t ,.rvl(rg rzv _ tzc) _ rzT
tlOIZ:.? JOJ ryl(ng ,t!V3 - t5): tts trvfrt) _ ttg
11 olI:/ .toJ !!y I !!J:!!g
: sa u3llrJ.{eJ eq rr€c suotl
atuoceq ltg rc1 -enba eq1 'osle g xule{u Jo slueurala 9 eql eutu.ralop
oelnwJo1 1e;aue8 eql .osl? ,{11ur1rur pal€lnclBc eq o1 posll eq UBJ ,{aq1 tuqt lBaAeJ IIr,r suorlerrba esoql
Jolo^\oq few sluarueJe puo8erp aq1 .aloqe ecuanb .suorlenba
-go uorlcadsur uy 9 Etrrsn ,{q ;r 3o sluaru
-as Lrr rrellr.t^\ se .1q8r-r oi lJel ruo.rJ pue uolloq lno pe{Jo& o.{\ ./l .g elduexl tr1
-ola 9 Jo selllu^ eql
_eql
ol dot Luo.U osr^\,roJ peurluralap eq uec slu?rusJa erll
'g pu!.{ '11'g eldruux3 ur
tzv ?tg ttanr8
fte) _ se e.re J puu F/ secrJlehi .g v: J tsq:l qcns
t:thrf (rdg ?.t,Y _ ?.t,J) _ zttg '€ : r, ezlsJo seclJlerulup8uerrl Je,rrol € eJE oJoql
t:tyl(z.g xt,Y _ trg tt:v; _ rt,J) : l{tg 'f
6I 31dr4{vxa
oT.
(r'r) s1t\ns : (r'l) v
(t'x) B',()'I) v - I,{ns : wns sI
I'f[:xsIocl
(f't)f,:Iltns
I+f : ff
IAI -t:t
NI't:W0eoc
I-I:NI
l+f-N:I
IN .I :'I OZ O(t
(r'r) s/(r'l)J: (I'r)v or
pal"lncl"r sluaurela luuo8elp 11y
N.I:IOIOCI
Z: IN I-N:IN
) to g ro rJo ezrs €:N
sI.tDuta{ sluatualots
NyaLvoI
!o!l{!':t1 ttgftt,J : Eeh.
Iolt--r:/ r xag azY
!:tg )t!Y {5) : ttY :
ldzJ
z 07 u : ! roJ ttg il = -!!gl!!J: !!v ,t{ lrr3 : ,rn
I or rl .ro u o, I _'- , -,o1
: s3 ls?ceJ eq LISC sr.totl
autoceq [ty _toj ar?ll1t-rr.ro1 le;aua8 aq1 enba etJl 'oslp t, xrJleru Jo slrrautele 9 oqt eutuJolop
'eAoq? uollr-rA\ err:,(ar1l qcltl,r Llr Jopto eql Ut Jo,pJB,$ ol p3sl1 aq u33 ,(eq1 teql IEsAe.r lJr,r suollunbe esoql
-13a1 3uro3 '1r:uo8urp eql rllt^\ Surtlels puu spre,rdn go uorlcadsrrr uy 'srrorlenbe 9 Fursn ,{g A go sltraru
tuolloq est^\A\o-t peullu,talop oq ueo t/ lo sluotr.tsle snql -ale 9
Jo sanlu^ eql lno polJo^\ e^\ .4 .g efdmexg u1
'F, pulg.11'6 eldurexg
,tgl(t"g aav _ tzJ) : .zv rrr tre.,rr8 s€ ere pua €r seorJlel
J I .gy : J l"ql qcns
,tgl(tg $r _ lzg zqv _ tE}): ttrt 't: u ozrs Jo sacrJl€ru reln8uurrl Jal\ol € eJp eJaql
tEY
_ze)):atv
^rgl(rrg 8I'€ afdNvxg
I€ SNOIJVU:IdO xIuIvIf[ a'Idnus
32 MATRIX OPERATIONS ON THE COMPUTER

FORTRAN state,nents Explanation


N:3
DOl0I:l,N
l0 B(I,I): C(t,l)/A (I,I)
DO 20I: 2. N
IN:I-l
DO20J:l.lN
SUM:C(I,J)
DO 15 K: J, IN
15 SUM : SUM - A (l,K)j'B (K.J)
20 B (I. J) : SUM/A (l,l)

Exauplr 3.20 )-e: - - Ls. Y22! L,t,: : - 1 lt3

There are 2 lower triangular matrices of size n :3,


112 001
Y: L-I: - rl1 217 0l
slrch that LY : Y L : l- where 1 is an identity r126 l/13 7126)
matrix. If
Note that the valLre of Y; depends on that of Lii' Once
lL,, o 0l
L:1L.,, L.,., or
i2
ll 111
0 0t
oi the off-diagonal element Y4, where i > i' is determined'
the corresfonding element 14 is not required in further
ir' Ll,l. L*r.l i.o I 2617 )
calcr.rlations. This enables overwritirlC of
yt ot't' Lii'
find L Thus computer work separate matrix Y is not
lor
absolutely necessary' unless a problem requires both
An indentity matrix cal'I be considered as a particular t and Y ior further work. TI're rnathematical expressiott
case of a lower triangular matrix. say, C of Example lbr Y maY be wlitten as
3.17, having all its off-diagonal elements zero. The for i:lton
expressions for I may then be obtailled as in previous
Y":llLii
Exarnples 3.18. and 3.19 However to facilitate ttnder- )'ij : (- 2 Lit Y*.illLii for i : 2 to n

stauding of this important case we \\'ork otlt the steps


j:ltoi-l
independently belorv. : - Yii(>Lit Yti) /t - jto i - I
:
Verifl' that vector )/ does llot challge if rve solve Y L I
Consider L \' : 1. Expansiorr gives :
on the lines of Exanrple 3.18. Necessary FORTRAN
YI y' stands
L statelrents are given belorv. in lrhich lratrix
lL,, 0 ol (,Y,, 0 o [r o 0l fol rnatrix I.
L^ Lrz ol I v", Y.,,, o i0 r 0i
i.

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

Cr : An Bi + ALzBzr + A:.oBsr Exeuprs 3.23


Cri : At Br, * AB Psz A is a symmetric matrix of size 3 x 3. To conserve
cri : Ar" Br"
the memory space of the computer, advantage is taken
C,, -- AD 8", + A% Bsl f14 23 l8l
c;; : A* 8"" * A2s Bs2 c - lz: +r :ol of the symmetry of the matrix and only the elements
c;; : A"" B_"" lrs :o :eJ in the upper triangular portion are stored as a one-
ci, : Ar" Brr. dimensional arrary A. B is another matrix of size
Csz : Ar" B_tt
C;; : A",8", 3x3. Find the product C:AxB.
The general forrnula for multiplication, therefore, be- Let the symmetric matrix be

comes, for n : 3 size of matrices, IA r, .4'," l,rl


Cii :ZAit Bti for i: I to n,.i^- lto rt A: I Ar" A.r" A"rl
' k k:itonifi>j '1.'4,, Ar" A"")
k : 7to n if i .j The elements in the upper triangle are
FqRTRAN state,nents Al Ar2 Ar,,
N:, 3
A"" Ar"
Ar"
DO10I==l,N
DOlOJ:I,N They are stored as one dimensional array in the order
c(l,J):0 Ai Arz Ar" A"" A.r" A'r,
IF (I - J) 1,2,2
I L:J corresponding to its elements
GOTO3 I A, Ar At A1 A'. Au] resPectivelY.
2 L=:l Let Z denote the serial Ilumber of the term in the nerv
3 DOI0K:L,N one dimensional arraY A,
l0 C (I, J) : C (I, J) + A (I, K)'!B (K, J) 1 denote the rorv ntlmber of the san.re term in the
From the values of the elements of matrices A and B, original square matrix ,'tr,
it can also be noticed that ,B is the transpose of ,4, denote the colutnn number of the sanre term in
K
i.e. B:Ati in other words .Bk7 : Aik. If use is made
the original square matrix ,4,
of this fact then the last FORTRAN statement can be
written as N denote the size ol tlre symmetric matrix, i.e.
3 here.
l0 C (I, J) : C (I, J) + A (I,K) *A (J' K)
Then the relation betrveell these 4 variables can be
In this case C : A. At, is said to be obtained by taking easily verified as
the inner products among the rorvs of l.
:
L - Ix l/-(N-r() - I(I- l)12 rvhere K> I
Alternatively,A: Bt. Al B*i and we may rvrite For elements in the lorver triangle. 1 > K, and from
l0 c (I, J) : C (I, J)-FB (K,I)'FB(K,J) symmetry of the original square nratlix. u'e have l4; :
Thus C can also be obtained by taking the ituter pro' Air. So to obtain them, it is simply llecessary to ex-
ducts among the columns of B. achange the values of / and -/. Thtts rvhen an element
It may also be rroticed that C is symmetrical. Hence say A'" in the origir,al sqLlare matrix is needed, we
the computer work can be reduced to half. Only the search for elemerrt Arr.. i.e. elemcnt in the 2rrd rorv
elements in the upper triangle may be worked ont on the
and 3rd column.
computer. Elements belorv the diagonal may then Therr our formula gives,
be obtained by symmetry. L - 2 x 3 (3-3) 2(2 t\12: s
- - -
FORTRAN statements That is. the 5th term of the new otre-diinet-'siorral array
DO20I:l,N gives the value of the term A, of the original square
DO20J:I,N nraatrix. The rnatrix mtrltiplication formltla lllay now
c(I,J):0 be expressed as,
DOIOK:J,N Cii :2 At Bkj for i : I totr, i : I to n,
lo c (I, J) : C (I, J) + A (I, K)':'A (J, K) k k: I tort,
20 c(J,I): c(t,J) / as calculated above.
o Jo /(oJ Jo, Jo urunloJ (f "I) c,,.('I'))1* (>1) g+(f 'I) v : (f'I) v 0I
J Jo ^\oJ Jo gr Jo uunlo] z'l :'l0I oc
z'l:\0locl
o: (t't) v
Q ro Y Jo uunlo3 Z,I:fOIOQ
g ro Y Jo .4r\ou z'r: | 0t ocr
ruoltouoldxT stuaruatpts NYvJYo-I
'Z ol I ruorg 3ul,(re^ l'I'!''! ye '!tg Pt) 4!g 3: {tV qq'r qqq'$qq'Tqqq.r
-
s3 uellrJlt1, oq r\ou .(eru uq1uo31c aq1 paqcund oq U Jo slueluele pue
azo zicT,rg aro ri, i,t) ltg _F arQ u) ttg :
ty : J 'ay : g r.-l
+ +
"rg ""Q it - rzl it ol l'r- el
aiT alg ) irT trg : z,rvt is :
frrLli ti 'rz ,i - "Y'v tv
'ruJel auo .ro.; uorssardxa oql enr8 aan 'acuereJeJ Jol it ol ir- il ir- il
'o^oqu E Jo saurl eql uo pel"lnolec aq feur i/ Jo suJel lo Lj i., rj i, ,i-v'v:dv 'elPtiU
i""v "ol f t - €l
- tY'aV'V : ttV'V'Y : zY
1."'y "y ) 'tz t) - V Jl')ta'tY'V
s" peugep o-re xrJleur e.;o sre,rod eq1
ro 7s:a)s:r33ueH tz'€ 3'rdyivxg
7,zez zC t?e 77) -l- ,IO ra3 r!
+ zte Iz) :27.! -
zze ztJ + arq rrJ : 6? tae :"r) -t- lre tt) : tt-I ('r)v,:()'r)s * (r'r)f,: (r't)c c
zlfi - f) f - (> - z
ru) - N',f :'r
t'Jl :I'ICN\/IUI f,
1.""o "ol i"J l^"E t?l xaiao'I oI soNodsEduoJ JNSr^,t3'I3 )
irto ',rQ ) i.'J "JJ l-"s "a) IOIOD
uoql 'g 3 lenba Z><Z e4s Jo E xuleur le'J zlfi - >r)> - (r - ru) - N,:)r : "r
ssJtrlBru rra^rc
SICNVIUI f,
QC 8:Y uqlqo'ezrs zX 7 Jo ue a' J'g ugddn oI sctNodsllduof, t_N:il^t!I'I:I J
sz'E :rldi{vxE T,'z'r (t - r) ct
'p31ilI.uo sr llnseJ palurJd '.rapun se pe8ueqo I
aq ll!,n suorlrn.tlsur ralndtuoc aql 'lV 4!g 7 : ttC
CINE
e1rr,r {ulu e,r 't, xgr: J utulqo ol pe.ilsop sl ll .}I
(o'sgz) rvnuor z
(N 'I : I '(N'I : f '(f 'l) c)) 'z l-Nlxd ENNIINO) OI
(N't : I '(N't : r'(r't) O) 'z rNtud (r'>)s,,('r)v + (r'r)J - (r'r)c s
(N 'r : r '(N'r : r'(r'r)v)) 'z JNrud zlfi - ))) - (t - tt) - N,,) :'r z
(r'))
fl,*()'r) v -i- (r'r) r : (r'r) r 0z
A]DNVIUI J
N't--)0zocl U]A\O-I OI SCINOdSEUUOJ JN!IhI:I-IA f,
o .= (t'l) o €OIOD
N 't .--f 0z oc zi(t -r),rl -(x -ru)-N,:I - I r
N.I:IOZOCI :ITDNVIUJ c
(r'x)v*(>r't)v + (r't)g : ft 't) g ol uaddn oI scrNodsSuuoJ tNSr^3-IE f,
N'[:)0loc z'.'t (x
r) cr -
o -= (r'r) s N't:)0toc
N'I:IOIOCI o: (r'r)J
(o'sgr) rvhruol I N'I : f OI OCI
(N'I : I'(N'I : t'(t't)v) )'t clvru N.I:IOIOCI
(z'd c'(z'z) g'(z'T)Y NoISNaI IICI €:N
Z:N (e'g) c'(['€) g'(g) v NoIsNghiIC
rnotSotd TlyVJyOI sluatuatots NYvMr
s€ sNoll.vuado xluJ,w{
36 MATRIX OPERATIONS ON THE COMPUTER

Note that the expressiotr for term Arrcan also be rvritten as which may be verifled easily and expressed in symbols as

Arr: (B' C1 + Bp C"r) Dr, + (81 Cr, + BnCz)D"z


Qr:2AitBtt CRitc* i CIi* rvhere
indicating clearly that the product (BC) may be lormed 1 -- colttrnn of A : rorv of B
first, and then post-multiplied by D to yield the same
result. In other words, , CRi* : tO,, BRtt - AIit Blrtc
CIit -: ARlt BItt + .411t BRtt<
A:BCD:B(C'):(BC)D
Cornputel prograllls u'ritterl in FORTRAN IV lor com-
3.7 Multiplication of Conrplex N{atrices plex Inatrix operatiot-t do not differ from those for
Marry en,eineering and scientific problenrs itrvolre real matrices. except that a declaration statemertt is
complex rnatrix operatiorrs. They are based on the llecessary 1o irrlorm the computer that it has to deal
algebraic operations, viz. addition' strbtraction. lrrr-rltipli- rvitlr corttplex and not real nratrices. lt is rvritten as
cation and divisior.r ol complex trttt.trbers. These at'e TYPE COI\{PLEX A(..2,2) B (2.2), C (2'2) or as
similar to real tttttnber arithlnelic lvith the only
difference that the real and inraginary parts e-rf the co\l PLEX A (2,2), B (.2,2), c (2'2)
complex t.tuntber hal'e to be handled separately. Thirs Alternately we llla.y also '"vrite 2 separate statelrellts as

(2+ i)+(l +i):-(2+l)+(1 +i):3+2i TYPE COMPLEX A.B,C


(2 + 3r) - (l + i\: (2- l) + (3i - i): 1 + :t DIMENSION A(2,2). B(2.2), C(2,2)
(2 + i) (1 -F i) - (2) (l) + (2) (i ) + (r) (l) - (i )(i)
In FORTRAN ll, there is no sttch provision ibr cour-
1+3i as i2:-1. plex nr"rmbers, whose real and imaginary parts have'
l+3i (l+3i)(l -i) _4+2i 2+i iherefore, to be considered separately' We may thus
I+,'-it *if(l ,i---1- nse nratrices AR, BR, CR, AI, BI, and C1 instead of
,4, B and C. A simple complex matrix multiplication
Consider 2 complex tnutrices -4 and B given by
prograrrl segnlent in FORTRAN II is given below
A. l+i 2+i ' B l+i l+rl u,herein
A i 3*t; I^ r-i)
|l- ./-t N{ : total nltmber of rows of A or C
Then their addition is easily seen to be
N - total tttttnber of columns of B or C
a-
3+2i 3-lil
!t1_ NK : total uttmber of colttmtrs of A or rorvs ol B
u 21 6
l
I

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'I I lr cI- ( 2 rl NK:2


AI:I f I rj
ll',BI:
i_" oi DO l0J -: I, M
l-l [-r -t)
I

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

But (An) a-t A-1 : A(B B-t)A-L : AI A-L : A A-r : I


(A-t11t At (A-r) This result can be cxtended to more than two matrices.
giving Two ploperties are given below without proof.
15.
At (A-t)t : I a unitary, Hermitian, orthogonal, or
The inverse of
i.e. symmetric matrix is unitary, Hermitian, orthogonal
(At1-r (A-r1t or symmetric respectively.
Thus the inverse of the transposc of a tnatrix cquals The inverse of a diagonal, lower triangular, or upper
the transpose of its iuverse. trianguiar matrix is diagonal, lower triangular or
upper triangular rcspectively.
1.4. (AB)*L :IJ-L A-r
For furthel study lead References (14,15,16,19,21,
This follows from 22,24,25,34,36,41)
-J3tep Jo uoll?nl?^e oql 'sasBc rlcns 'sporpunq uI sr ?r3 su ereq peleuErsop ar7 lueusla;o JolceJ-oc eql snql
olur sunJ u surelqo:d cglluorcs puu Suuoaur8ue ,{uuur u1 .(tty jo rouru)
seqcuordde y 'a aErel rog
'8I; I
f +l(t -) .{q ue,u8 sr.4y luerualo u" Jo Jolc"J-ot oql
8I|I>Y>I pu8
rolr8J-oJ €'t
(t) (z) (s)' '(z u) (r r') u : i u
- -
oJoql\ tru€unuJolep Jepro - tltu uE JoJ suorl€cr1dr11nu ,Y
JO
i u v se^lo^ur uor]Enlp^o lcolrp qcns 'sEurql Europ 13ql uErl] ssol euo 'e'l'z sl Jouru stql Jo Japro eql
go {u,n epnJc ? sr eloq€ I't IJV ur srourluJo sruJol ur
passordxa su lusuruJelep u 8urlunl"^a Jo poqleu eql r"ql al'N'l::t Iil) e^oq€ oqr u\ ity
luculuralo(J Jo uollBnlBrg lrorJo s'7 "luuu^ulorop
luoruolo oql
Jo JourLu eql 'oldu"xo roC 'lu€utluJolep
*tJ'l
[*rJ r.J ttJl orll Jo utunloc ql.r eql pue 1r{oJ qU eql 1no 3ur1r.r1s dq
it'J "J : +Y pelnetqo lueulu.rolop eq1 sr .4y lueruele ,{rre 3o JoLIItrAI
LrrJ
t.J ,rJJ
rou!tr 1 z'F
ptlE
[rr.r"Vrrvl '\ttvT.tVttY) '1ro,tt .ralr,duoc
l*i a\L l"r, - V loJ poJJeJerd 'oro3a.rsq1 'lou sl puE suolleJrldrtlnru
trrv "r'V
r"V ",'Vl
uV) - f ,tt,ty "", '"rl
"ty lPj ,(ueru se,tlonur llr€ururJolep oql 3ut1en1e,re JoJ elnluJoJ
tra'I 'sJolceJ-oc e,rrlcodsoJ Jroql .,(q xrrleu ue,u8 eq1 3o 7H 3^oq8 orll 'peuuop ,{puprurs eru slapJo raqStq 3o
esodsuurl oql Jo slueruolo eql Surcelde.r ,(q peurelqo sr 'y xrJleur arenbs JoJ s1u?unuJelop eql 'xIJi€Iu eteubs
xrJl?ru e.runbs uezrrE e Jo '+y ,{q palouep 'lurofpu eq1 et{} Jo lsqt su orues sI lueullurelop erll Jo .lapJo aql
x;rlutr i u go 1u;o[py 7'7 ll:y,i.aY,fly zItylTyr.ty * tt:ynyzry i
-
(:tCtIy + dt:)zthr + te)tly r:tvtTvitv, tttv,zTyllv :
0: -ltv{1lyrry -
0: tz,tly 4 zz>zty + lz7tly
'a1rr,r .,(eru e,tr 'xuluru € x g eloqe oql JoJ 'snql ',t.yl* ,
'orez spnbe (uurnloc .ro) tror reqlo .{uu ur stuetuols lrrr * l;.tr ',:r1",, -
Surpuodsarroo arll Jo srolteJ-oo eql pu€ (urunloc ro) TvI
A\oJ e ur slueruala eql Jo slcnpord eql Jo Iulls eqL'Z l':,_, __vl*v t"v v
.'"Yl - l::tr ::tr ,,VI l:
'suorl€lnclBc srloruqilru orll l""r l',ty ",y
secnpeJ l€ql auo 'e'r 'luoruo^uoc sr 1€r{l lrunloJ ro 'dq ue,rr8
,tor ,(uu Jo slueruelo aql Jo sruJol ur passerdxe eq o1 sl lucruu.rJslep oql'€ ezrs Jo U xrJlELu erenbs e JoJ
lueuruJalap eql salq€uo srql 'sJolceJ-oc e,'rrlcad '.loqulnll ertrd e sl I p'l luuuituJalop slltll
-soJ Jreql pue (urunloc .ro) ,tro; ,{uD ut slueruale erll
atb,rzv _zz'v, ttY: lvl
go slcnpordoqlJo runs aql s;enba lueurtulolop aql'I
'solnJ Z Surno;1o3 eqt,{q d11ecr1oqru,{s Jo 'Z: t. xV - t ><Z
: lVl
pessardxe lsaq sr xrJl€ru erenbs B Jo lueururJelep orll pue ',(q ue,rr8 sl ' I F'I dq palouep
sluotuole egl Jo sJolc€J-oc eql uee,{\leq drqsuorluler eqa 'xriltLu srrll JoJ lu€Llllu.Iolep eql 'uolqs8J lueltlo^tloc uI
tr)t:Iy + 7.1)(IV _r- II)'uy/: lVl pe8ue,uu sJoqunu t Jo les 3 slnese:de.t Y aJaH
se rtelltJ^l eq l'"v '"v) ft btt:o
,ttou uec r xul€tu € x E o^oqu eql Jo lusurtuJetap aql 'r"tv "Y ) lt z) -'
t-^ xrJl€ru erenbs B JoPIsuo)
PrY l
tt '"Y t""v '"v
l-- I t"V .+t(I-):")
t*v '"v I l*rV luBululrolac Jo onIEA I't
xlrlutrAl alBnbs B Jo luuuFrrroloo
t usrdvH]
40 MATRIX OPERATIONS ON THE COT,IPU]ER

minant would involve such a huge number of multi- Nunterical solutiott


plications that even the fastest computer rvould have
L Let D denote the value of the determinant in the
to waste its many precious hours ! This rrethod it final stage.
not therefore used on the computer.
2. Set D : l, to begin with.
4.6 Pivotal Conrlensation
3. Find the largest element in the matrix, inspecting
Chio gave a very efficient method for computer use, sequentially along the rows, one by one. Elemerri
It involves less arithmetic and gives more accurate Az,t : 8 is the largest. No other element is larger
results. In this method, elements below the diagonal than this. We disregard element Aaz : 8.
are eliminated i.e. reduced to zero and the given matrix 4. As the biggest element is in row 2, interchange row
is transformed into an upper triangular one as explained 2 rvith row l, and get, a new matrix
presently. It makes use of the followirrg properties
of determinants. A: il48l
li s2)i 4i
l. If two rows or columns of a determinant are inter- l+
changed, the value of the determinant changes in 5. Row interchange changes the sigr-r of the detellninant,
sign only. hence make D : - I i.e. the deterrninant of the
given rnatrix is (-1) times the determinant of this
Exluplr nerv matrix.
2l
34 --l I il -l; 3l:' 6. As the biggest element is in column 3, intercharrge
column 3 with column I, and get. a new :natrix
2. If all the elements of a row or column of a deter- 18411
minant are multiplied by a constant /r, the value on A: l+t2i
the determinant is multiplied by k. lz84)
Exeuprr
7. Column interchange changes the sign of the deter-
minant, hence make D : l, now.
:

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

g. As 8 is factored out, the determinantofthe given


row or column, the value of the determinant remains
rnatrix is 8 times the determinant olthis uerv matrix.
unchanged.
HenceD:lx8:8.
Exeupr,n : 10. Multiply row I by 4, the leading coefficient of row
2lt 2, subtract the resulting elements of row I from the
12 I r l2l
4 3l*l+-zxz 3-2xrl lo tt,:"
a
corresponding elements of rorv 2, and get,
Azt :4-4 xl :0, Azz :l - 4x0.5 : -1,
Note how this property is used to eliminate the ele- An:2- 4x 0.125:1.5
ment in second row, the matrix is transformed into
11. Repeat step l0 similarly for row 3, i.e. multiply
an upper triangular form, the determinant of rvhich
is given by the product of the diagonal elements.
row I by 2, the leading coeffcient of rorv 3, and
subtract resulting elements of row I from the corres-
The method is best explained by an example.
ponding elements of row 3

Exeupre 4. I A:tt:2-2x l:0, Asz:8 - 2x 0.5:7,


Azs:4-2x0.125:3.75
Evaluate the determinant of the square matrix
12. The new matrix now appears as,
I 0.s 0.l2sl
A: lll0 -1.0 1.5
4')
4 8l I
s2) Lo 7.0 3.7s )
uotuotg .1yg) ,(y7)
SANIII I_N NOIJVNIIATI'I:I OO 3
I-N: IN sadg '(99) znry '(69'l aaurDg 'l9y) tltoog pBaU 'E
I : I IUIIICT 'Jalnduloc eql uo sllnssJ oJUJI't3C€ AJOIU
(N 't : t '(t'.t't - f '(f 't)v)) '26 JNlud seJnsua srql 'ouop sr ]J 1(Oleq uunlos aql ur
sluatuelo Jo uorluunuqe aroJeq luuo8erp oqt uo
N't -' I '(N 'I : f '(f 't )v) ) '16 ovllu tuorlrsod lonrd aql uJ lq8norg sr lllotuela lsaSatg'7
€: N 'poqlew sttll uJ pastlper ,(lquraptsuoc
(E'E) v NoISNgh{ta
oql A\oq ,(Fulrcrllud {Juhl
NOII 3 sr {-ro\\ srlatuq}tJe
-YSN:ICNOJ 'IVIOAId AS JNYNIWdAIAC C 'rlr f slunbe ,{pteu dran uotssotdxe siql ',/
a3.re1 f.ro,r .ro1 '(t t,t * ril ) ii oi lutlotue eulll
9't hlvuDoud c :elnduoc -
aqt Jo lsotu otullsuoJ t[ttt{,\\ 'sttotst,ttp
':t!y tty lcnbord eqr Jo
pul? suorlpJrldrllur.u'snq1 'xl.IJuru szrs-r/ LI€ JoJ
qnOOOti t u"q] ssa[ eq o] putloJ sl 1! .ll o-Iez ol l3s sr
suorsr^rp (1
ryry'lprse.r eqt 's:aqtuuu lenba lsotule -ro lunba - tt1 tt i
u Jo uorlcurlqns ol eup ,(culuore Jo ssol plo^B Ol ', suortr:rrldr]pru (9 * tt - i.tt 0 (t - tr) I
suorlJ?rlqns put: srroryppt (l + u7) (1+tt) tt f
N ot I+/ tuo.U 8ur,(re,r JeqLtlll[l ulull[oo : {
1\\o't : ! s3^lo^ur poqleu
aql't
1|1 o} I + i tuolJ 8rtt.(le,r icqtulltl
es?sslqlut'i o1 l -' I -r\ o] I : poutal,\ atil uo
tloll?tllLtllle Jo ieqLtlll[l lulJes :
palutrtrurle Sureq 'sa8uetlcxa uulllof, pult A\oJ .yo reqrunu
: d
==
puerl ol I =. r
ere luuo8etp A\oleq sluoltlala qJltl^\ Lll Llutlllor
euoP Sr.rraq oJar{,\\
sr slusltlela Jo uorlulllLu!{a tlJIl[^\ A\ol - !!y Ue 3o lcnpo.rd x dfi-): O
^\ol3q
Ittouela 1o'rrcl 3o ulllllioJ Jo i\\o.I : ! 'xr:letu aruubs ezti tt LIE JgJ .lO
eJ0q,\\ |styd (t) (s) - =- o srlql
:1!y' !!y tly : 1.f- s,to.r rouol reqtg (11) tII-:LSiO'Z,x99-:O
- 8ur,u8 ',tro.t
lty I lly - -Y,r,/ to^ld (l) 1se1
^\or g ,(1dr11nur '.(11uurg ';,1
st sdals ol\l ttI ttalllJ,\\ sl slL[I oq] ur lrreruale ltuoEerp aqr ,(q
!!yltty tty' t{Y : t{f, 9S- Lx8-: Q
-
sr ltr.ro8urp eql ,{\olaq tsto'z ol
I
sluolua[e Surleututtlo .ro1 tttq1r.ro81t .Io €IlltrltoJ eql '9 l.rsEs o IJ
'luuurru.rJlap 3r{}
'sr lprsag 'Z urullloo ui leuoSurp ,\tolaq lualuala
Jo enp^ aql sa,rr8 ,{11tug 1r i e,roqu aldurexa eql al€unurlo puu '1 ,(q 3 ,uo: 3pl^lg '8-: O pue
UI g oq} se}ouap I\IX:IICI 3lq€rre^ OqI '9
1oqtu,{s
.OIIVU l- s't I -l
er{] uI i.srE L )
anlel lecordrral srtll dq parldrtlnu uctlt alu
^\oJ pue 'Z
slueuale Jaqlo sql :OIIYU tlortl?col uI polols 1aB qll^\ € ,ro.r e8uuqc.ra1u1 'luetuala
^\oJ
pue po{n"lqo lsig sI lllettt3le 1o.trd eqt ;o 3:cordtcer 1se33rq oql q L 'Z ozrs Jo xrJlelu ,^AOu srql
^\ori
eril 'lrreutcle lonrd aLlt ,iq sluattrele srll oprlrp roJ ai o1 g dals uro{ a-rnpero.rd e1oq,n aqr leadag 'e I
^\o,i
ol 'oS 'uots!^tp uDW aatlt si^al sa4ol uottottldlllnyl 'g '1du
sr uorlusuepuoc p:1o,rrd orueu oql
'g'Z puu 1'6 saldtuexq -red A\or{ Jeelo sel?ru ernpacord aq1'pasuapuoc A\ou
s? euop oJ? srrrulllos pu!- s,4^or
;o sa8uzrlclelul oql '€ sr xrJl€ru lenlStro oql 'o'r 'azts .ra11utus Jo sI sIqI
'9'i aldrucrg
lst'r t l
3o sloqur,(s prrs einpa3ord aqt 3ur,r,ro11o3 ,{q punoS I s'r I -l
sr enie^ ailqL\sqD 1sa63rq eql 8r-rra,et1 luotuele eLlL'7
'sr xul?ru lAeu slqtr Jo luEulur
'pulloJ eq ol sr lul?ultuJolsp osotl^\ -Jelep eql l"ql olou oslv 'poqlotu uorlsurulle eql
tz xrJl?u orzubs aql Jo ozrs aql .roJ spuels E : A- 'l poll€c eroJeraql sr sql 'pal?urtuqe o.te luuo8etp
wptSotd aui tnoqD syrlod atuog eq] urullloc ur slrlsruals aql eloN
^\oleq I ^\oq
lv xrurYr{ auvnbs y dO INVNIhIUAIIC
42 MATRIX OPERATIONS ON THE COMPUTER

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

Exrupm 5.1 NRANK: i - l, when pivot element li; is found


zero during elimination.
Find the rank of thc 3 x 4 matrix
5. The algorithm for elirnination is thc salnc as in thc
{'l
l: j 3s 4rBi
2 rnethod of pivotal condensatiort, viz.
ll 6 et2) A1s : A1*
- A1i AitlAii
Steps where

1. Biggest elcment in row 3 soluntu 4. Makc it


is 12 I : row or column of pivot elcureut
pivot by exchanging row 3 with row I and columu
: serial nutnber of elirnination
: I to M -l : I to 2in thiscasc
4 with column I as 7 : row number varying from i * I to M
t26e3l /c : column number varying fronr i -l I to .lf
8 7 9 3i
6. I'reoaution fcrr preventing loss of accuracy in thc
4 2 3 lJ
subtraction of 2 uearly equal numbcrs is takcu as
2. Dividc row I by pivot, ucw An :12, and gct it as cxplaincd in the last chitptcr.
t I ll2 314 tl4l row I C PROGRAM 5.2
3. Multiply row I bY new .4
"r
: alld subtract frotn C MATRIX RANK
row 2 to get it as C I{OWS M COLUMNS N
t0 3 3 ll rowZ M:3
I lr, :4 MI:M-I
4. Multiply row bY new and subtract frour
row 3 to get it as
N:4
READ 91, ((A(l,J) J - l,N), I -- I, M)
t00001 row3
PRTNT 92,((A(t, J), J - l,N), I - l, M)
Further work is ullneoessary. The rank ol' the urtrtrix DO 50 l: I, Ml
2. The computer, howcvcr, executcs 2 morc
is clearly ll:t+l
steps and then stoPs. C FIND PIVOT ELEMENT
5. Pivot element is 3 : 1", itsclf. Excltangc of rows lRow : I
columns is unnecessary. Dividc row 2 by pivot ICOL :1
to get it as BIG:O
t0 I l r/3l row 2 DOIOJ:l,M
6. Multiply row 2 by A"": 0 and subtract frotn row DOlOK:I,N
3 to get it as AB : ABSF (A (J, K) )
tF (BIG - Ats) 2, 10,10
[0 0 0 0] rttw3
?. Corning to 3rd row, the pivot clcmcnt is low zero.
2 BIG:AB
IROW : J
Taking note of this fact, the computcr computes thc
rank as 3-l:2. ICOL : K
IO CONTINUE
Note tlrat if at thc ctrtl of stcp 6. art1, elemenl in 3r'd
tF (tRow - l) 21,21, ll
row happens to be llorl-zeto, the rauk would then be 3.
C EXCHANCE ROW IROW WITH t
Some poittts ubout tlrc prograt,t II DO20J:I,N
1. The prograln finds the rank of a 3 x 4 ntatrix L TEMP:A(I,J)
2. 11 stands for rows, 1{ columns, of 1.. A (I, J) : A (IROW, J)
3. The elimination of eletncnts in the coluurus has 20 A (lROW, J) : TEMP
obviously to be done only IV - I titnes. Variablc PRTNT 92, ((A (K, J), J : l, N), K : I, M)
Ml cquals this M - l. 2t lF(ICOL -l)31,31,22
4. Variable NRANK sl.aucls for the rank o1' the givcn C EXCHANGE COLUMN IC]OL WITH I

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

We now rewlite equations (1) and (2) as


A systern of 3'sirnultaneous equations is transforrned
to tire form given belo*.
AvX" + AiX, Br
Ar" X, + A! X, B2 x.r Bt (l)
x2 82 Q\
or, in matrix form as xl B?, (3)
lA,, t"l x), l4l A record ofthe subscripts ofvector Xis kept in an array
l.A* Arri
I
IXJ lr,j JCOL as JCOL (l) : 3. JCOL (2) : 2, JCOL (3) : 1.
oT,
(r'D v/nrns (D x
(r) x*0'I) v-wns := hrns ol
NI'i:fOtoct
I{nS te8 o} (l) g ruor
p3l3?Jlqns aq 01 suJel
Jo Jeqr.uuu aql JoJ sp{I"]s Nl I-I: NI
'wns au"u str{l Jepun paJols pue pal"Jtlcl€3
sr ? pue ,X toJ suorsserdxe erll
Jo ,L1er"*,rrl aq1 (r) s : rltns
'rX oj aX sutroulun Jo N ol 7 suorlenba JoprsuoJ
N'Z: l 0z oc
(r'r)v/(r)s: (r)x
(e) x '(E) g '(€'t) v NoIsNiII IICI
'g sr suorlenba Jo suA\ou{uirl
Jo Jaqu-ntN N
uotjout4dxT ':
strDtualDts NVYJVo-l
I-!olt: { '"vl(tx t"v*'g)
uolz: roJ T (tX tty "x
,X
"yItg
t'vltg : tx 'urelqo ol po^los ,{1rsue aq f,zru suorlenba esaql
(t) ,g tX zX ztv + ,X rry
sa Ll3llrl^\ eq "rV +
r(eru suorlznba a go ruals,{s ? roJ (z) zX z..h/
+ tX trv
X :o3 suorssardxe oql "g
tg
( r) tx rry
'uotllurlsqlls plu^\-roJJo poqlau eql pall"c sr
splJ 'gx a,rr8 .uorlenba pJe eql ur pallutjsqtls ueq^\ aq suorlunbe oql 1o-I
re$rlJ ',X FB o1 uorlenbe puooes aq] rlr pelnlrlsqlts Ozts
'E X t Jo xul?ru .relr8uzr.r1.re,ro1
ueql sr U 'uorlunbe ls.rg aril ruou polrr?lqo sr ry 1s.rrg ? sr z 3r3r.{,r 'g : xv sr-roliunba 3o ruals,{s eql a^los
zE ," _r
lt"x v- Y g.)
_r x
"rv " x z'9 aldwvxa
ANNIINOJ OI
'pelurrd eq
UIA\ ? Jo alll"^ eql {'6r .l: I JoJ srlql .str{} aloN
(r) a 'r 'z rNldd r
'1enbe e;u tlloq ueq^\ ,(1uo auop sl
X Jo
Eurlur-rd ! I r{tl,,,r pa:udruoc sl -IOJ1 Jo Luro} Jo enl?A
0r 'r '0r 0 - (r)'roJf) cl
'.I:fOIOCI
€.I:IOIOCI
troltouoldxE
stuatuatp$ NVaJYoI
Qr) uaruaSuotlV
(r'ozg 'otI) JVI trdot I
'rapJo lernl"u
Jrerll ul palurrd aiu gr pue -IOJ1
Jo srural er.{l Jo ssnl"A (D s '(t) ToJf 'r rNtdd or
E.I - IOI OCI
ttotlpuoldxg slualualots NYtrJYOI
(r) tuatuaBuot.ty
,X tx 'rl JepJo 3ql
,X "x
ux
'X 'l q X Jo sluaruele lulrd o1 relndruoc egl lcnJlsuJ
LN sNorrvnba snoaNyrrnrus
48 MATRIX OPERATIOS ON THE COMPUTER

Exeuprn 6.3 Substitution of X, and X, in equation (l) gives,

Solve the system of equations AX -- B, where ,4 is an X, : (8,- At X"- ApX") lArt


upper triangular matrix of size 3 x 3. The unknows Xy X2, X" are obtained in the reverse
Let the equations be order as Xs, X2, X, starting with the last equation and
ending wjth the first equation. This is called the method
A!X,* Ar"Xz+AnXs BL (1)
of backward substitution.
A""X" + A* Xs Bz (2)
A$X" 83 (3) The expressions for X of a system of n equations may
Equation (3) gives be written as

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

FORTRAN statements Remarks

N:3 Number of equations

DIMENSION A (3,3), B (3). X (3)


x (N) : B (NyA (N, N) x3: Bvf A33
Nl : N_I Nl : 2 : remaining equations or unknowns
DO20L: l,Nl L I 2
I:N-L I 2 I
II:I+I
II )
suM : B (l) J

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

tl 2 l3 (10) (c) For symmetric tlatrices, only the uon-zero ele-


ments in the upper triangle rnay be stored to forrn
Using the labels of elements as in the old 10 x l0 a rectangular matrix of size l0 x 3 as sho*rr
matrix A, the new arrangement maY be shown sche- columnwise below.
matically as under. Equation
old A Nev, A A B number
Old labels Ne$, lqbles Row 123
1l 12 13 13t415l 211 1 (l)
21 22 23 24 22 2324252 421 19 (2)

31 32 33 34 35 3l 32 3334353 621 34 (3)

42 43 44 45 46 4l 42 4344454 421 32 (4)

53 54 55 56 57 5l 52 5354555 621 34 (s)

64 65 66 67 68 6l 62 6364656 421 22 (6)

75 76 77 78 79 ',71 72 7314757 842 29 (7)

86 87 88 89 8,10 8l 82 8384858 621 28 (8)

97 98 99 9,10 9l q? 9394959 41 22 (e)

10,8 10,9 10,10 10,1 10,2 10.3 l0 2 13 (10)

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

A(J,K):A(J,K)-TERM where I : row of element of 2-dimensional array


DIF : 10000.':'ABSF(A (J,K))-ABSF(TERM) K : column of element of 2-dimensional array
IF @rF) 43, 43, 50 (K>I)
43 A (J,K) :0 N: size of the square coefficient matrix
50 CONTINUE
LF (I, K, N) : serial number of the
60 CONTINUE corresponding term in the orre-dimen-
PRINT 92, ( (A. (I, J), J : I, NN), I : l, N) sional array.
IF (A (N,N)) 61,96,6t (3) is norv treated indepen-
3. The constant vector B
C SOLVE BY BACK SUBSTITUTION dently.
6t Y (N) : A (N, NNyA (N,N)
4. The operations of finding the biggest elernent and
DO70L:1,NI bringing it in the pivot position are omitteci as they
I:N_L are usually for,rnd unnecessary for symmetric matrices.
II-I+I
Y(r):A(I,NN) 5. Whenever a term like A (J, K) is come across in the
DOTOJ:II,N FO RTRAN program for a rectangular matrix, it is
simply replaced by A (L) where
70 Y(r) : Y(r)-A(I, J)'r Y(J)
PRINT 94, ([, Y (t), I: I, N)
L : LF (J, K,N) if K>J
DO80I:l,N L:LF(K,J,N) if K<J
J : JCOL (r) Thus this program for one dimensional array A cor-
80 x(J) = v11; responds in all respects to that for the 2 dirnensional
PRINT 94, (1, X (I), I : l, N) array A.
STOP
C PROGRAM 6,6.2
9t FORMAT (l2F s.0) C SIMULTANEOUS EQUATIONS GAUSS
92 FORMAT (4Fr0.4) C METHOD
93 FORMAT (3110) C UPPER TRIANGLE OF SYNI\,,IETRIC
94 FORMAT (u0, FI0.4)
96 PRINT 97
C COEFFICIENT MATRIX STORED AS

97 FORMAT (t0 X, |2HMETHOD FArLS)


C ONE DIMENSIONAL ARRAY
DIMENSTON A (6), B (3). X (3)
END
LF (I. K, N) : I':'N (N-K)
6.6.2 Synmetric Coefficient Matrix Stored qs One- N:3 - -t'+G-1)i2

Dinrcnsiunl Arra)' Nl -N-l


READ 9I, A, B
Consider the system of 3 equation's given in Art 6.4.1.
PRINT 92, A. B
The main points about the rlodified progrant are as
under. DO 60I : l, Nl
IN:I+I
l. Elements upper triarrgle of the 3 x 3 square
of the II : LF (t, I, N)
symmetric coefficient matrix ma.y be stoled row-wise
in a one-dimeusional array A (6), as explained irr IF (A (ll)) I l, 96, ll
Art 6.4 I (b). r l RATIO : l./A (rr)
2. The corresporrdence betweelr the elements of the 2- C ELIMINATE ELEMENTS BETOW
dimensional square sytnmetric matrix and this one- C DIAGONAL IN COLUMN I
dimensional array is expressed by the arithnretic DO30J -IN,N
statement function as urrder.
tJ:LF(I,J,N)
: B (J) : B (J) * B (I)':'A (IJ)''RATIO
LF (I, K, N) 1r'61- (N
- K)-l't',$- l)12
'pollruo or3 a8€ssalu NoIJn'Ios oN 3 Eurluud -UeoJ pu"g oql 'Jalndruoc arll uo ,{rorueu aAEs oI'I
puu oraz sl (HS) 'I) V JI Surlsel roJ sluo{uoluts '8 'Jepull sB oJB uerSord eql JoJ ouop suorl€cgrpour eql
'pereprsuos oq ol peeu ,(|uo 16951 o1 't'n'9 'l.rv ul ue,rr8 suorlenbe 91 3o ruels,{s B Joprsuo]
g) : I i surunlo3 'ruerSord eql ruo4 pa.,!\olloJ xutow uralzgao) puog nln8uolcay )lualuurAsun t'g'g
eq uac uorlnlrlsqns >1ceq .{q X Jo uol}Bncl€c oql',
" eJoq (lN3
pollruo eJ? uorlsod 1o,r,td eql olur 1r Sut8urrq (otts) rvlntuog 86
pu" luoruale lseEErq eql Surpug ;o suotlzredo otll'9 (srtvg coHral^rH zt 'xot) rvhtuoc L6
(Hax 't) vrtr) s,,.(r't) v -- (r) fl - (r) s /6
rNldd 96
I+ f -HS):'Iorotl,tl &'ozt 'otI'xot)JVI luoc v6
(ngx't)v/(It'I)v*('I'f) v-(x't) v : ()'r) v G'ztsillvnuoJ a6
.ro3 urqlrro8le oql'9
seuoceq uol1eurulrle (t 'sgzt) lvl,\uoJ t6
dOIS
HgN+I01 I+I'\ro'I: f (N'r :
,\A8N ol B) : t'(r) x'r)'t6 rNrud
,tor HII oql ur luorualo :INNIINOJ 08
I SurpuodsoJ.roc aql Jo Jeqlunu tlullfoc : !\[ (u) vi(r) x : (r) x
oroq,^AI+f ) (r) x,,,(r)v-(rr)x : 0)x oL
-w:
elnr.uJoJ aql .{q uenrE (N'f 'D.{'I : fI
HgN+ I o1 I t 1 snor LII stuoruelo 3o surunloc (rrt) N.NI: f OTOCI
(S or I suutnloc 'e'D ,&SN ol gX : IAtr'e'l (r)a: (r)x
',nol ,{ue ur eJluoc aq} Jo lq8rr eql o1 surunloc (rr) (r.i 'l't) c"I : II
('pepegu oJ? s.4AoJ Z trxeu aqr ,{1uo 'a;druexe I+I:NI
slql uD N peecxe lorl seop Joqrunrlt\or IBI{I uou .I--N: I
-rpuor eql ol tcefqns HgN * I ot I + I: 1 s,ttor (r) IN'I:T08OCI
eql :
(xN) v/ 0.D s N) x Ie
sDeJe uorlBurlurle qll eql 1eql ,(3rre.L o1 ,(see sr lt uarll NOIINJIJSSNS )JVS AS AA'IOS
6OI I: I_NOII: ts's6'ts (N$ v) sr
olez (N'N 'N) cr : NN
01 psJnpeJ oJ? slueruelo qclrl^\ ,{\olog .^ oJ : s'v'z6lNtud
rrorluredo uorl€ururla Jo Jaqiunu lur.ras : I :INNIJNOJ 09
0I : suollEllba 3o .requrnu : N SNNIINOJ OE
v:l+€:I+Hs): a) gNNIINOf, OZ
Z: eJluoc o: ()r)v 6t
eql Jo eprs Jerllre uo suuJnlor Jo Joqrunu : HSN oz '6t '6t (gra) sr
'oreg € : I + Z/A\SN : qlpl^\ pueq JI"rt : HS) (nusr) JSav r
eJeqg: (,"rore - ((>r) v) JSBV,!'ooool : .{rcl
ur stueruele oraz-uou Jo) qlpl,h puuq Ietol : ,{AsN nxaJ--(xr)v: ()f)v
olJvu ,*(>l) v :
*(rr) v I^rusr 8I
t"-I'v (N 't'x) c'I : )f Lt
'sa8ueqc qcns pJocal ol polonrlsur lorr sr.ralnduoc eq1
8I OI OD
'ecrlcerd rno rod sy 'oJoz ol pecnpeJ ore srmnlloc Z (N')'f) c'I : )f 9t
lsJg eql ur sluJel luuoSelp-go 'uorleururle 6ur:nq '.9
Lt 'Lt '9t (: - r) st
'sonl"^ oraz peuElsse eJE slueulalo snorlrlcg eql'Z (N'x 't) .{T : )I
'(O g'l'g 'lrv ul pauruldxe se perots sr y xrrl?u tuarc N'NI: )0ZO(I
ss sNonvnOf, snoaNvrrnlrrs
56 MATRD( OPERATIONS ON THE COMPUTER

c PROGRAM 6.6.3 I:N-.-L


c SIMULTANEOUS EQUATIONS GAUSS x(r):B(D
c METHOD DO 50 M : KB, NBW
C UNSYMMETRIC BAND COEFFICIENT
K.-I+M_KBH
IF (K N) 41, 41, 50
c MATRIX
4r x (D -_'- x (r) A (r,M)"x (K)
DIMENSION A (10, 5), X (10) B (10)
50 CONTINUE -
N :10 60 CONTINUE
NBH :2 PRINT 93, (I, X (I), I : 1, N)
KBH :3 9t FPRMAT (6 Fs.O)
KB _4 92 FORMAT (6 F r0.4)
NBW:5 93 FORMAT (I10, F20.4)
DOIOI:I,N END
READ 91, (A (I, J), J : l, NBW), B (l)
PRINT 92. (A (I,J), J - l, NBW), B (I) 6.6.4 Syntrttetric Half Band Coefficiut tr[atrix
IO CONTINUE Consider again the system of 10 equations given in
Nl -N-l Art. 6.4.3. The main points about the modified pro-
DO 40I --1, Nl gram are as under.
IT :I + I 1. To save memory on the computer, the band coeffi-
RATrO - t.lA 0, KBH) I is stored as explaind in Art. 6. a. 3 (c).
cient matrix
B0):B(I)'*RATI6 2. The fictitious elements are assigned zero values.
IHR-I+NBH 3. Symbols I : serial number of elimination operation,
lF (rHR -- N) 14, 14, l3 N : number of equations, KBH : half band width.
13 IHR == N NBH : KBH l, have the same values as in Art'
6.6.3.
-
14 DO 15 M : KB, NBW
15 A (I, M) - a (r, M)'*RATIo 4. Ith elinination affects
DO 20 J : IT, IHR i. rows J :I + I to I + NBH provided row unm-
ber does not exceed N (in this example, only
L:KBH--J+I lhe next two rows are affected)
B (J) : B (J) -- A (J, L)*B (r)
ii.colurnnsK:ltoNBH.
DO 20 M :KB, NBW
for elimination becomes
5. The algorithm
K:M_J+I
IF (K NBW) 16, 16.20 A (J, K) : A (J,K) A (r,L) 'F A (I,M)/A(I, 1)
-
t6 TERM- : A (J, L)'r A G, M) where

A (J, K) : A (J. r) L:J_I + I


-iEnu
DIF : 10000-,!ABSF (A (J,K)- M:J_I+K>KBH
l ABSF (TERM) 6. The operations on or with fictitious elements are
avoided by taking care to see that J + K
IF (DIF) l',l, 17, 20
not exceed N.
-l does
l7 A(J,K):0
7. The operations of finding the biggest term and bring-
m CONTINUE ing it into the pivot position are omitted.
DO30J:I,N 8. The calculation of X (J) by back substitution needs
30 PRINT 92, (A (J, K), K : l, NBW)" B (J) consideration of terms lying in columns K :2
40 CONTINUE to KBH in row J only.
c SOLVE FOR X BY BACK SUBSTITUTION 9. In case, a term in the first column of .,{ is found to be
x (N) : B (NyA (N, KBH) zero, the method fails and the computer prints out a
DO60L: I,Nl message accordingly.
frul {sltr slet ol tt'96'w ((t 'N) v) gI
slvl
Ilsrttl t+t islv - sh ANNIINOJ O'
lslzzi L?J Is/e slz ?i
(N't:)t
sallE srql '0: t'Y': rcv ol : rrv luql os elg rodo 'Z
'(:) s '(Hgx 'I : 'I '('I ')) v)) 'zo rNlud
Ierl llxl lY € Il ANNIINOJ OE
tr{! t"x1 ir z tl ANNIINOf, OZ
l--l
ILL ) 1.,xJ l.e z s)
o:(x't)v 8l
1eE a,tr 'rrY
uotteool eql Sut8uug'l oz '8t '8t (JIc)JI
ul S: tt'y lusualc 1sa33rq
(wugr) JSsv I
'8urpuu1s;apun ur as?e JoJ A\oloq pecnpordar Ja^e,ll.oq 'r) v) JSSY,,'ooool : glct
'aru r(aq1'y'galdiuurE ut s?aulusouloJBZpuu 1 sdel5 -((x
htdar (x'f) v -= (x'r) v
-
sdatg
oIrYU,,(N'l) v',(r'l) v : hlugr 9l
'7'9 elduexg ur ua,rt8 sP eJ? 8r oz'gl'gt (Hax ru) rt
pue y erar.{A\ 'Er : XY suotltnba 3o ura1s,(s oql a^los -
)+l-f:hl sl
s'9 31dv{vx1 ou 'st'sI(ti-xr).{t
'palBultuIls eJe I-)+l:)t
ul.unloc ,(ue ttt sltlatusls oI{l sloJeq trotltsoci 1o,'rrd ro HSNI.I:)OZOCI
Surpeal aql ur lq8uo-lq st luauale tso8lel aql i ,(celtlccu cu-vu,,(r) { r,(t't) v - (r) s : (t) g
aJow urutqo ol auop sr eiueqr auo {1ug 'g raldeq3 I + l-t._-'I
'g1 'g elduuxa 'Z poqlaw -rad sB .{1lcuxa slueruale
dHr'il : t 0t oc vl
luuo8erp-go eql Surluururla dq xulr.ul /(luuepr ue ol
peuioJsusJl sr l' aql'poqleul slt[] uI
xrJlBLLr luer3luoo3 N: dHI TI
fI 'il 'tI (N uHt) .{I
asDJ lDDuag I'L'9 -
HgN + I.. UHI
poqtat\l uBprof ssnBc l'9 I NhIN'IO] NI -IVNODVICI f,
oN3 1t\O'I:lS SINahl:ll:I :IIVNII U-IS J
(uounros oNHII 'x ot) rvhtuol L6 (t'D vi 'I : otrvu II
/6lNIUd 96
tt'96' t t ((i 'tl v) .{t
(r' s t-l's tt) t.vlt'tuo: €6
" I+I-=II
(r'st*) lvruuoJ z6
IN.I - IO?OO
(t'otgttrvnuoJ I6
I-N: IN
dOIS EONIINOf, OI
(N 't =- t '(t) x 'l) 'E6 rNlud
(r) '(Hsx 't : f '(r 't) v) '26 JNIUd
s
anNtrNoJ 09
(l) g '(t{sx
I =- t '(f 't) v) '16 cIYSu
(t 'rl v/(t) x : (t) x
N.I:IOIOCI
:INNIINOf, OS
t- Hsx
(>)x,*(r,ri'i)v-(r)x - (t)x 9r
Hsl\i z:
'9t 'sr (Ni-x).{t
os OI: N
I -1,^{ + I: ) (ot) '(ot)
s x'(t'0I) v NotsNEI^IICI
Hg)'; - hl 0s oc HIOIlT\ c
(r)s: (r)x
CINVS C-IVH JO XIUIVW SIUIAWhIAS f,
T-N: I
INI.I : 'I 09 OCI OOHIIIW f,
(t'x) vi(x) s '= (NI) x tt ssnvo sr{orrvnbt snoaNVJ""InwIs J
NOIINIIISBOS )JVS AS AA-IOS f, t'9'9 I,{VUDOdd 3
LS sNorrYoog sno3Nvrlnwts
I
58 MATRIX OPERATIONS ON THE 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,

loo 'rx') [t]


8. Ifthe pivot element happens to be zero, obviously the
On the Method
methoa fails, no solution is obiained, and the com-
l. The method involves puter prints such a message.
n divisions PROGRAM 6.7.I
lrnB* n2-!n multiplications C SIMULTANEOUS EQUATIONS JORDAN
lrns-$n algebraic additions
C METHOD
It is not therefore as fast as the Gauss elimination DIMENSION A (3, 4), JCOL (3)
method for solving simultaneous cquations. N:3
2. The method involves same amount of arithmetic as NN:N+1
the Gauss method in finding matrix inverse (see - READ 91, (A (I, J), J : I, NN), I : I, N)
Chapter 7). Hence for solving multiple sets of PRINT 92, ((A (I, J), J : 1, NN), I : l, N)
equations by the matrix inversion method (see Art. DO l0r :1. N
6.11), any one method may be used.
l0 JCoL (r) : I
3. McCormic and Salvadori (72) contains an effcient DOTOI:T,N
Fortran program of this method that may be used II:I+1
for solving a system of equations, or obtaining a
matrix inverse or evaluating a determinant. C FIND PIVOT ELEMENT
IROW : I
4. Ralston and Wilf (80) deals with the method in detail
ICOL : I
and gives a flow chart.
BTG:O
5. Read also Booth (46), Faddeeva (52), Fox (55), Lance DO20J:I,N
(66), Scarborowgh (82) and Westlake (86).
DO20K:I,N
Sonte points qbout the program AB : ABSF (A (J, K))
l. n : 3. stands for the size of the square coefficient
IF (BIG - AB) 2,20,20
matrix.4. 2 BIG:AB
IROW : J
2. Array A (3,4) stands for the augmented matrix of
the system of equations, the constant vector being ICOL : K
accommodated in the (n + l)th, i.e. 4th column. 20 CONTINUE
rF (rRow r) 31. 31, 2t
-
3. Rows and columns are exchanged, if necessary, to
bring the biggest element in the pivot position. C EXCHANGE ROW IROW WITH I
Record of column exchanges only is kept up by 2I DO30J:1,NN
using the array JCOL as in the Gauss method. TEMP:A0,J)
EI poJols ,{Ferodtual pu? pear sI Jo lsrg eql .I ,6 INI'IId 96
^\oJ
') 1: J a1ilc 7s.r1g (r'otg 'orr) rvwuod n6
'uorlerado uorJeurrurle Jo .reqrtrnu l€rros oql (orre)
rvrruog t6
I
: (r'or st) rvr{uoi z6
'e.req g srror]€nbe Jo Jegr.unu eql iir (o's gzr) rvt^rdoi 16
'[ X E ezrs Jo xr]tenr llrarf,Ueor e-runbs orJi elouep
e, dOIS
'3.rer[ sru-r.r] [ Jo .ro1c0^ ]ull]slroJ eq] eq Br ANNIINOf, 08
'xr-rlulu E x E Otti -1o A\o.r e Jo sLrrisl erlt (Nu 'r) Y 'I'16 JNIUd rL
cuo c oq
,(1r.re-rodruel c.tols o);(r:l.r.u lur"rorsuollup lir 08'U. '08'(I - (t) rort) ct
'suorlc;edo,{;u 1uau-ra1a er11 3ur-rnp xt-r}ur!r N'r: t080c
lusrJlgeoc € x E aql -lo sLuJal lnJesn Jo laqLunu N.I:I08OC
Lllnlurlilui )tl] e-rol: o1,(e;-r.- rL-Uolsuarulp euo E oq r la-I "'r
X N,ANON)NN CINIJ
'suortunba g 1o ruals,(s p -roJ IrElop 3NNIINOJ OL
u! e-ritporo-rd oLll AroloJ slr la-I '(.rot[ralu ]o Eut\cs (N'I: ) '(NNi't : 'I'(-i')) yD'e6 JNlxd
leQJ; 1l oltir slllrsrj iJr.\ep srtl I 'seJr.rlurtr ol.ru1 .i.r:,r -rog :INNIINOf 09
'peJols ec1 ,,{r.}ru puo,(aq sttrullloo Lll stueLLtelo Jo salllll^
3NNIINO] 09
,(1ug 'c1e 'e1r,(c puz -lo puo etJ] 1r g 'e1c(c ts I Jo pur
eql lu I 'a'r urullloJ aq1 rn slueulalc yeuo8urp-go eql 0:()'r)Y t,
Jo sellluA o-rez eql prr€ lueLuela luiroiuip aq] Jo olrlu^ 0s 'tt'tt (lla) il
lrm1 oql 3ur-ro1s osll o[r sl ]r 11?r[] palurco.rdcie ac1 ,{1rsua (t^rluar)
csgy I
r(eur 11 enlel arLros .lo-l spuejs :{ eieq^\
'lrreurele sql Jo ((x 't) v) gsav,,'oooor crcr :
-
r 00l ix x 0 0l r\ x x 0l
niuar - (> 'r) v - () 'i) v
l-x :
lx 0 I 0l 0l
(>r -t)v,,,tt 'f) v HuEl- Ev
l.x 0 0 ll lx x | 0l lx x \
lx x 0 l) Lx x \ Ij [t'0s '[? (I - f) .{I
ttt pttt11 a1tt,t
Tsrrolag a1.ttc 1s.rrg N't- f 090c
lIS I,^[NWN
-IOJ AIVN I I^I I'I:I 3
'Jepurl su s-readdu suoripubO
aql Jo xrilerr patuetu8nu aqr 'e1c,(c rlcce Jo prra oql lV ollvu ,,()'t) V : (:'t) v
'euo pJ€ eqt rrr rinnlloJ prf er[] uo prru a1o,{c pu3 eq1 rrr IOAId AS 1Y\Od ACIAICI 3
ulunJoJ pr.rz aql lro euop o.ic srroi]utuJoJsuBJl Jelrurs - NN.II:)09OCI
'l ol los sr I ur.unJoJ rrr tuituola lriio8urp orll pue oraz 01 (I 'I) v,'' I : orrvd zn
pecnpoJ eJ€ slrrouele luuo8urp-go eqt 'a1c,{c ls.lu oql uI
zv '96"T.V ((t 't) v .{t
Suorl€llba g 3o urets,{:s I A\oU Ju.nlssu ';Jt.tOil.la^uoc JoJ
(t{ 'l : ) '())'Iof,t) '€6 JNIUd
'po]lru.lo aJoJeJaq] ol1? suorle.rodo qcug (N'l: x '(NN't : -t'{'r ')) v))'z6 rNlud w
'euop sr rrorJ€rnrurie ajoJeq uorllsod lo,rrd :o lurro8urp :
f (Tof,r)'rof,r
oql ur lJ 8ut.rq pue lueulole 1sa33rq eql prrg o1 alqrssod
lorr ,(lsnor,rqo sl '€urr l c lc p?eJ sr A\oJ €uo ,{1uo sy
(rol) -roJr: (r) rorr
(r)
rorr : r
'ees ,(lluesard
dhtar: (toct't)v oF
Il"qs ?^\ sB sr.'orlurado llcns -roJ pelrns ,(1]uenrua sr
poqtelu rrEpJof ssnuD erJI'suol]3rr.r-roJsuell,(lelueuale (rorr 'r) v: (r'r) v
alrsnlbe-r o1 palcelqns ,{lelerparurur ptrB fq ,to.r puar (l'f) v: dhraJ
oq ,{etu 1r ',i.roureru -ralndtuoc orlt ut^\or pel?porutuolc€ N.I:fO'O(I EE
eg'loutrpr puu e3-rcJ ,{.rarr sr xr.rJuur ll.totJgooc eql ueqlA HIIA\'IOf,I NWN'IOf, II9NVHJXII c
xlltol4l sat{lao3 a3n7 7' 7'g ZE,IN,WG-TOf,I)dI I€
ft.i 't : ) '(NN 't : 'I '('t 'x) 9)'76 JNtud
CINA dhtar : 0'noul) v OE
(Notrnros oNHII 'xor) lyhiuot L6 (r'rrroui) v: 0'I) v
6S sNorrvnol snoJNvJ.'rnnls
MATRIX OPERATIONS ON THE COMPUTER

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

5. Reduce Rr, the elemellt in the first column of C to


i.i:ltoi-l
zeto. To do this, rnultiply elements A, and A, At:At-ArrRk for li:2ton-l
by R. and subtract then from R, and R3 respec- t:(j-I)u-(i-l).i +k ij: ltoi-l
tively. Thus
m:(.i- l)n-(i - 1).i + i Lk: i +l ton
: R" RlAt, ftg : Ra RrAy SimilarlY (iv) Shifting elements
Rz
B, : Bz-
-
- R. Br. Now Rr, being zero, maY be Rr shifted to At, I : (, - l) rr * k - i2 for
ignored. i:lton
A':i+lto,?
6. Divide this pivot rorv by' diagorral element Rr.
Ignore its unit value. shifted to l/,
,,4r
R3 : R3/R2, and '8, : Br/Rt' r :(i- l)n-(i- t)j + k li :zton- I
l:(j-1)-ii +k for lj:ltoi-l
7. Now reduce the off-diagonal element in the second [/t:i*ltoz
column of first row of C, i.e. elemertt Arro zeto. To
do this, multiply second rolv, i.e. element R,, by ,4, and In the formulae under (i) and (iii) above term l/
subtract ftom A, to get it as A" : Az- RzAv corresponds to the term Ajk of the corresponding
fgnore again zeto value of At. Similarly, get. rectangular rnatrix ,4. Thus in the third cycle, i : 3,
:
Br Br- B, At i :2,ls obtained for .i : 2. k :3. n :3 ; tertn Ar
is forrnd located as Ar. Similarly the term {'i is
8. Now at this stage, the only useful elements are r4". Rt found located as ,4p1. The nrtmber of storage loca-
Hence shift,4z to,4. and R"to Ar. tions required for ,4 are nr - i2 at the end of ith cycle
Third cycle I as first i columtrs are not useful further. Thus the
-- 3
nraximunt uutlbeL works ottt to n2f4.
9. Third row of C is trorv read and stored in R. Thtrs
Crr, R, =: G.. R; : Crr' .8, is also read.
R, : Sonre poinls about the Progratlt
10. Reduce R, to zero and get l. The DIMENSION statement is for a systern of 3
Rs : R; R, Ar, B.t B,t- R, B , equations. Srze of A declared is bigger tharl
- to zero and=' get
ll. Reduce -R, nccessal'y.
n, : R, R"Az, Br, == B.;- RrB"
- 2. The symbols used in the progl'am are slightly
12. Divide this pivot rorv by diagorral elenrent Rr. different.
B,a : Br/R"
3. The table opposite the prograrn gives the values of
13. Reduce elements in the third column to zero, i.e. the constants indicating thereby the calculations or
elements A, and A". Only elements .81 and ,8" shifting of elements step by step.
zrre changed. 4. The indices J and K of the DO loops refer to row
B, : Br- B" At, B, : Br- BuA, and column numbers respectively of the correspond-
4. Shifting of elements is unnecessary. Vector B gives ing rectangular matrix. Compare with program
:
lthe values of X. Thus X, By X, Bz, Xr: : Bz. 6.7.1
SINflWA.I:I JCIHS J
lg"lg'llN-Dgt
ANNIINOJ O'
anNll-Nof, 0€
o: (r)Y LT,
ot'Lz'LT, (crc) .{r
(^uer) JSsv r
- ((t) v) cSflv;,'oooor : (r)crc
hrusr-(r)v: v
(x)u,,,(ru)v: mugr
)+)t_-I
N'rr: )Otoc 9z
o, '0, '92 (t't t) c t
(rru) v,,,(r) s - (i) s :- (i) s
Z
W I l- )t: I
I- )t f ,:, ll - N',(l -- f): )l
T,
f II't:totoc tr,
EAOSV I f,
Nt\ntoJ Nl srN3l,\313 glvNIt\l.Ig J
tz'ts'ts(tt)ct
(r)ui(>)u: (>)u oz
N'il : ) 0z ocl (.1
T,'l('(,1 (trt t) gt
(rlu/(t)s:- (t)s tt
l-o^ld 8 L\\ou ScllnIC
snNrrNoJ 0t
(t)Y,;.(r)u -(x)u: (>r)u 6
c rlo zlr -l 6'ot 'o[ (r) st
c rlz tlz ) )+)t:-i
N'ft'- ) 0l oc
)r (f)x,,$)s-(r)I:(r)e
ff f,:, Il - N;.(l - f) - )t-
f t+ i: fl
It't: t0i oc 9
/Y\O.1E8
li 3
Nl\ nlOJ N I S:l-NI,\:I-13 Al-VNI I'\ l-13 :)
9'il 'rr (il).{r
(t) I '(N't : r'(t) u)'z JNIdd
I L
(t)s'{N't : ['(l) ul't ctvSu
L 0
l+t:il
c I
l-l: Il
N'I : I OI OCI
T: N
sluslsuoJ Jo senluA (r) s'(t) u'(r) v NotsNet^{lc
xr ur-vhtr LN3 If, Il.{AOf, EDUV-I J
COHIIIN NVCUOf f,
SS OVD SNOTTYNOE SNO:INVI'I NI,\I IS J
z'r'9 hlvxDoxd f
t9 sNolrvnoa snoENvrrnnls
62 MATRIX OPERATIONS ON THE COMPUTER

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

6.8 Crout Method the product D U results in replacement of I's by Dii


along the diagoual of U. We now lrave trvo alterna-
The solution of a svstenl ol non-hourogelleolls equa-
tives. either to associate Z with D or D with U. Denot-
tions is ahvays obtained if the coefficient matrix is
irrg these nerv products ZD and DU by symbols 11 and
non-singular, i.e. has a noll-zero deterrninatrt. In the
Gauss method, the coefficient matrix I is first trans-
{/r respectively. rve may rvrite the trvo different ways
formed into an upper triangular ntatrix : using the of spliting up ,4 as under :
latter, the solution is then obtained by the back sub- 1. A: LL U where 11 is lower triangular, and U,
stitution method. In the Jordan n-rethod. the coeffi- unit upper triangular.
cient matrix is diagonalized. the corlstallt vector B,
giving the solution directly. We shall now study 2. A -- L Lr rvhere L is unit lorver triaugular aud Ur,
upper tliangular'.
methods that give the solution in a different way.
A
non-singular square coeflicient matrix .4 can be Herrce folth. let I stand lor I or 11. and [t for [.r or Ur.
represented uniquely as a product ol 3 squale matrices. The splitting up ol ,4 as above is useful either for solving
AS
a systenl cf cquations cr obtaining a matlix inverse.
The;- have given us 2 useful methods ; Crout, and
A:LDU Doolittle, that use the above 2 representations respec-
where l, is a unit lower trian_qr,rlar matrix, D a diagonal tively. As the matrix I is factored or decomposed in
matrix, and U. a unit upper triangular matrix, all of factors I and U, they are also sometimes referred to
the same size as ,4. For size n - 3, we may write as factorizatiou. methods or methods ol decomposition.
this symbolically as We shall rrow study them in detail.
lAr' 4,, Ar") The decomposition in the Crout method may be
I A,, A,, A""i written in expanded form, for ,4 of size n: 3 as
Ll', Azz A"")
lt 0 ol lD,,0oIllu:f- U,,,.'] IAr Ap A:s) Lr, o 0 I 1-l Un Urr-l
(,

: t,, I 0i lo Do, o i io I u""i iA^AnArri:iL1}_ Lr, 0 i lo t Unl I J


Izrt Laz 1J l-o o'- D,,) lo o t"" ) lAin lr, .ln) lzsl Lsz L"") l0 o
lt
may be noted that the product .L D results in replace- Expanding the right hand side we get
ment of I's by Dri along the diagonal of .L. Similarly A1 : L1, A^ : L21, Arr, -- Lr,
'pe8wgcun I uunloc dae;'1 'elrrlr [?ur e^\ 'g : I7 : Xn7 :;g y 'suo1l
sdatg -unbo snoou"lFrurs g-;o uelsfs eql 'ureEe 'Euueplsuo3
larn I ol g'9 aldruexg ur paureldxe 'zo.r3
lzl I n Ir 4lilNqns p.tol*lraq.lo poqleu eql Sursn 'suollenbe go
l;'o i z) uals,(s e 'I : X n uorlElal eql luo{X plrg ',(1purg 'g
xr.rluru pelueuEnu oql 'a'r
'g'9 oldruexE ur pauleldxa
lvl ol 'uorlnltlsqns pre^\JoJ Jo poqlou aql Sursrr 'suorlenba
Ir n lrl 3o ruats,{s u '5' : ,1 T uortuler eq} uror.; I pull 'U
Hrl lH l.ol
,(q uenr5 'g : X y 'suorlerrba yo ua1s,{s er[] e^los eM 'n pue 7
aelllruroJ e^oqu eqt.;_o uorlucrldde eql puelsJepun oI serrJle(u rz;n8uer;lenbrun aql ut€tqo putp, y dn lr1dg '1
'{ pus /' sidrrcsqn5 : sdels
etll Jo sJnlu^ errtrsocl to3 raludtuoc aql uo euop s{ € SoAloAul X -tolOal U/y\oul[tl] eql Jo uolleulruJAla(l
surJsl Jo uorler.uLunslurll aes ol uelst eq plnoqs e_lpJ g: I7
uotl + 2:t
roJ ll[ty7-l+u'!r':lX uaqrT: Xn ta7
I 01 I
- t] :l | +u.uv : uX s--xn7
'E
x.rot33A te8 am'uoueube a^oqe oql q n f : y 8ur1n1rlsqng
1-{ot1:{ g: XY
uot'V: f
I+&oil+/':l ro, ttvl(Hyla{v 7- [y) : {v suorlBnbe snoaupllllrurs Jo uotlnlos aq] /\\ou Jeprsuo3
l*uo17:1 r'J rrVl[tY : 11V
'areds .ralnduoJ olqcll[u,r, Surnus snrll 'y uo
s.lus[uelJ mod 'z u31tr.r/v\.lo^o 3q uuc puB 7 Jo slueulslo alrsrnba.r eql IIe
n
r-{ott:4 ? Jo leuoclp oq] ur s. slueur
I pltll n to 7.ia{te-go"
tu
ol?: l' I -alo o-raz furpnlcxe'ecuoH '-toql,nu pa.rrnber lorr sr
Irollr- I JoJ {ttV :qfi li--Iy : lty
tJ'Jo lueurJle SurpuodseJ.rof, 'pourluJelop sr n Jo 7 Jo
u01 l:/ roJ tlv : ,!V
luoLurla allslnbar orlt eJrro ll?r{l pa^resqo eq oslu ,(uur 11
sluarueJs urunloJ 'l 'uorr{sBJ alBu.rellu ur
Peulu.rel3p o_tu , Jo saor pLre 7
s? {-u.roJ lcedruor ul ualltJ/r\ eq fuur X Jolcel uortnlos Jo suurnloc ur slueutol:l '7 Jo nrullloJ pit ? Jo A\o.r
puE rlo sluotusla rvreu Sururure]ep loJ uq1r.ro81u erJl pLt(,'I Jo ulunloc pLt(,'n Jo A{o.r lsl '7 Jo ulunlor lsl
'f : Jop.io eql ur pelrrruJs]Op e.rB n puB 7 Jo s]ueruala
xrlletu palueru8nu 3o
osoli] .{0Ao ua}lrr,rJeno eq oslu fietu
oql 'srrorl€lllJiuc 3o alrenb:s eql fl.ruprn.rud eloyq
2 Jo sluoLuelo esaql
]urll puu 'larpue uelr8 ,,(pee.r1u n Jo sllteureJ3 .raqlo Jo 'n puu ? Jo uorl€trrur.relep aql sataldurot snll
asoql ol Jelruus .{ltcuxa o.re suorssaldxe esor{t A\oq oloN t:zn zttT Etn rtT tt7
11:7 ?t:v) : it n - ct:t:1
+ tzpztT -t:ty -
"7 I (,tr "r StrrnrF I t:r2rt7:r:tV
'",71 (tA t"7 :-tA?zn crrT -
-tzh) Itry : rrn 'n Jo z rtro.r seleldrnoJ slr.ll
se uolltJ/y\3J aq trn surrel ro3 suorssardxo 3r[i puz zz7 _ tzn
'{er.u l(t:tn tzT _ 'ti.V)
8a: re, .zA : tz[] .1I _ vr[7 fur1rf .tznz77 + ztnrz7 : tzrt
tg : fiV 'zg : rty .tg : trv 'p3l8ll1c
ueql 'sururlloc q17 etrtcadso_t rrallt trr / puc gr slolcon -[EJ ari2 7 Jo T !rnmlof, ur s)llauralJ Surtrreruo.r 'st-tt11
urur.lloo o)ppoururo3cE ol (palrrau8ne) papuudxa a.ru ztn ttT _z?v : zt.7 .zt/) tzT __TiV : iaT
/? pue p. JI'a'l 'n q!!n I pue U qll^\ g rrrolpe a,r,r -;1 Surnrfi ,487 + zLn tttT : z'iv 'zz7 * ztn .aT : zzy
,,r1 rr.7 _r^rc,I _tg) : ,A
I (rA 'try ,{e p, Jo sluawele Surpuodsar-roc eql 3u1
t"7 rI
"'7 l(I -"g): "I 'rr7yg: -pl^lp dq parrrptqo o-re n Jo I ,lno.I rrr t pue Z sluelualA
uorllrlos erll 3ur,u8 .n7fvrY : trn
,'T ,r7 ,t7'j
trll 'trTlztv: atp 6urrlr8 '8It rr7 : zt7/ <at1tr7 : zrV
0 ""7
lfl I'il 0 o "'I) 'F- -Io l€ql sa eu.res oql sr 7 Jo urulllo3 lsJU eql snql
€9 sNolrvnbe snoaNvrlnHrs
64 MATRIX oPERATIoNS ON THE COMPUTER

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.

12 tlz o 21 5. This is a very compact procedure. The elements of


,4 are obtained by accumulation. It is unnecessary
3. Replace other elements of column 2 by
to record any intermediate results' This reduces
Azz : Arr- A2lAn: 7f2 round-off errors.
Ar, -- A"r- A31Ap : I
6. This is also known as Banachiewicz method or
- 4. Replace other elements of 2nd row by General Cholesky method.
Ar, : (Arr- A2lAB)1A22 : 217
7. For further study refer Booth (46), Faddeeva (52),
Arn - (Arn- A2rAL4)1A22 : 2017 Fox (55), Fuller (22), Marcus (31), Forsythe and
5. Replace remaining element in column 3 by Moler (53).
Azz : Asz- A"t Ar"- A", Ar" : 2617 FORTRAN p:ogram for solving N : 3 simultaneous

6. Replace finally the last element in 3rd row by equations is given below.

A"n : (A*- AurArn- A32A2r)1A33 : 3 c PROGRAM 6.8


C CROUT METHOD FOR SOLVING
Now matrix .,4 aPPears as
C EQUATIONS
DTMENSION A (3, 4), X (3)
N:3
Nl :N-I
NN:N+1
READ 91, ((A ([,J), J : 1, NN), I - 1, N)
9l FORMAT (l2Fs.1)
135 PRINT 92, ((A (l,J), J : l, NN), I : 1, N)
The sequence of steps I to 6 is marked against the 92 FORMAT (4 F10.4)
columns and rows for clarity. Verify that --c CALCULATE ELEMENTS IN FIRST ROW
a (giten ) RATIO : l./A(1,1)
DO IO J :2, NN
(20oll'ltl2o2), 10 4l
l0 A (l,J) : A (1, J)*RATIO
lr 7t2 oi io ot 217 2ol7i:it12 4l t2i
fo r' zGlT) l.o I 3 ) Lo t4 t4) DO50J:2,N
c CALCULATE ELEMENTS IN COLUMNS
7. Soltrtion vector X is now obtained as
C 2ND ONWARDS
Xt-A"4-'3 JI:J_I
Xz : Azq- A6Xs:Z JJ:J + I
X, : Arq- ArrXs* AP X2:l DO20I:J,N
On the Method DO20K:l,Jl
A (t, J) : A (l,J) A 0,K)1'A (K,J)
1. This method involves the same amount of arithmetic -
as the Gauss elimination. c CALCULATE ELEMENTS IN ROWS 2ND
c ONWARDS
2. According to Forysythe and Moler (53)' "The Crout RATIO : 1./A (J,J)
algorithm has the smaller round-off error, providing
the machine (like IBM 7090) can easily store an
DO40I:JJ,NN
DO30K:1,JI
accumulating product in a double-length register and
round it off to single precision only when the flnal 30 A (J,I) : A (J,I)- A (J,K)j'A(K,I)
number is stored".
q A(J,I):A(J, I)*RATIO

The algorithm being simple, the method can be 50 CONTINUE


3.
PRINT 92, ((A, (K,L), L -- l, NN), K - i' N)
convenGntly used for hand calculation as well'
'suouEnba snoeu?l (tL6tlgZZ-Sn')s
-Inurs & EUrAlos JoJ sr[qlrJo8l" o^oqu 3ql SurleJodJooul 'a1trm .(eur alt ?: 17: Xn7 : X V
sluonl3l"ls NVuIuOd luslodur elrJ^l ,4l\ou olA suorlenba go uta1s,{s aql tuueprsuo3
'poqleu lnoJJ ur s8 eru?s slJeruell 'poqleru lnoJ3
poqtaw aw uo eql ur s8 r uo uallrJ./r\Je^o aq uEc ,teql raqung .2 ;o
.{\oJ pJg 'T Jo A\oJ pJ€ 'n Jo A\oJ puT, ,T Jo /y\oJ
'poqlour lnoJ3 er{l Jo n i3E e/h 'luoru puz,'n Jo ,r\oJ lsl 'Jo ? Jo ,&oJ pJE ,7 Jo uulnloo puz
-olo puo88rp slr .{q .popr^rp sr e^oqB n Jo qc€e JI ? Jo ,{oJ pEz '7 Jo ulunloJ tsl ? Jo AioJ isl : ropro
^\oreredtuoJ
'poqleur 1nor3 oql Jo esoqt qll/h /l puE 7 sseql oql ur p3unuJalep oq us3 1? puB 7 Jo sluauele 3ql snql
le I tlz ol
ltlst tlgz zlt t2/7 xtT _ $n reT _ $7. =: etlT
lzl i.I or r
LIi r o r zltlzi *tn + t:zI) zE7 + tr(1 ttT .-= et'V
XY zET
""nl(tnrE7 _zEY):
I tltt Llsz o ol l'r Llz ol ?,7,1) zt7
rztL oi rzh! + zln ttZ : zEy
il0r O Id io LO O IJ ttn t?,7 _eah, : t;21)
' n7 ,tn tz7 : tzhl
"rn +
selrE eelnruJoJ a^oqe oql Jo uorlecllddy .elcrlJ€ zrn rz7 _zzY _ z7.n
snor,rord eql Jo suorlenbe 3o ura1s,(s orll JeprsuoJ
'Apo 4 1dr:csqns : zzVz rz7
Jo sonl€^ elrlsod roJ ouop sq pFoqs ""n * "tn
sruJol Jo uorleruuns ,rollrus pe{J€rueJ fpeerp sV lrnltllY : rt7 <un rET : 11:Y
uoll+!: I rt1 : rz7 .trn taz : nY
t ftzy
tatt-u: toj !!Yl(tx{tv7-t+u'!7): ty Gtn : try .ztn : zry ( trn : rtv
,ayll+u,!y: uX
x Jolce^ uorlnlos .E
rl ttTl fgu,Y zltv t!.V
-!oll: "t7 o ol lt "'r t"7 : zzv lzv
uott: !' 'zn zzn oi io I I lEzy,
uolz: 1 JoJ lttY tttV li ltY : tty "n "'n t'n ) io o l) It;ty zth, tt]|l
-
sA\oJ ur sluorueJe Surureurea .g sE ruJoJ papuucixa ur
uollrJ,{.\ eq feru uorlsodtuocep eql ,suorlenbo g- a
-{ott:4 go ure1s,(s e urc?e Surraprsuo3 .xrJl€tu reln8uerrl
-tol I: /'
uol JoJ raddneql2 pue xrJleru relnEuer.rl Je^\ol lrun eql ?
7:., {!yl({tty'trf 7- {ty) : tty
uolI:./ ro3 lty : {ty 'xrrleu luercgeoJ orll sr p/ oJorllr\ n 7 : y uolllsodruocep
aql sesn poqlour srql'g'9 'tJV ur peuorlueu fpeerle sy
Juuo8urp eql ol Uel s,roJ ur sluourelg .I
poqtotr tr olllrlooo 6'9
ur uerlrJ^\ eq fiew y Jorce^ ilrrffi?
f Jo sluerusls ^\ouEurunurolep JoJ sruqluo8p"#;;
^\ou eqa CNA
.g '9 e;duexlJ
ur peur€1dxe se uotlnlrlsqns fu'ozt 'otD rvwuoc €6
qcuq 'go poqleu eql ,tq peurruJelop sr
X Jolce1 N 't : i '(t) x't) '€6 JNIud
.r uo uellrr^r (r)x*(r'l) y-(Dx : (D x oe
-Jo^o og osl? uec osegl .poqlau lnoJJ or{l ur sV
? Jo
slueuole Jer{lo Jo esoql o} Jslrturs suorsserdxa Bulleq N.II: I09O(l
ezn 7,e7
_ otn ,*7 _ ttv : ,,.n (NN'l)v:0)x
,l)ruT rzlT .rty : I+I:]I
-rny - 'tn .I-N: I
eJeqA{
li-,-v:,;al lnrn - '/l tt ,,'7 ttzl IN.I:T09OO
i'1v-isi i";i:ii lo i (NN'N) v: N) x
lntV: rs) : i;) "71
lrfn t0 b NolrnJrrssns )cvs J.s (r) x c
s9 sNotlynba snoaNyrlnnls
MATRIX OPERATIONS ON THE COMPUTER

FORTRAN statements A : Tt x T. The method is therefore also aptly


called factorization method or tlre' rnethod of
the
C KEEP ROWI UNCHANGED decomposition. Fora3 x 3 square symmetric matrix
C CALCULATE ELEMENTS IN ROWS 2 A, we may then rvrite.
C TON (,Ar Atz 4t,\ i-f,, 0 0 Tr, 'fr- fr.l
DO60I -2.N iA, A* A"ri, - ',7* 7". o o 'f", 'l't,,i
IN{:T--1 !Ar., 1r, 4r" ' \ Irr Tn Tr,' 0 0 7-rr j
C CALCULATE ELEN'IENT A (T, J) Because of symmetry, it is necessary to ctusider only
DO50J:1,NN 6 efements, viz. Arr, Arr, ,4t", ,42r. A13, A,y, in the
upper triangle of A. The relation between .4 and l"
suM - A(1, J) takes the iorm of the following equations.
JM:J-I
IF (J l) 5, 35, 35 ^4r : Tt' Tt, =- \/Au -
- Tn: An lr11
C ELEMENT LEFT OF DIAGONAL Ap -- Tl.Tp
s IF (JM) 2s.2s,1s As : Ty.Tp T1-3:A6fTr1
C COLUMN 2 TO I --- 1 A"z : * Trr"
Trz2 722:1/1u-7;
15 DO20K:l,JM Az, - Trz.l$ + T2z.T2i T2s:(A2s-T1r.Tt")lT*
20 suM : suM -- A (l,K)'rA (K.J) A"" : Trr' i Trr" * Ts,r2 T#:'Vhr-71;r-T\;)
C COLUIV1N I TO I-I
Hence thc u-lements ol ttratlix Z can be determined by
2s A (I,J) : SLIrU/A (J,J)
the general fortrluale :
GO TO 50
T'i : {U;--* >Tkiz'; for i '= I to n,lt --l to i*-l
C COLUN,TN I TO N
35 DO40K-l,IM f;1 : $i1 - >Tki. Ts1) lTiifor 7 : i to n,lc:l toi-l
40 SUM .= SUN,I - A (I.K)',FA (K' J) Ti1 :O for l>i
A (I,J) : SUNI Surnmation of terms is carried only for positive vaiues
50 CONTINUE of k. Because of the presence of the square root term
in rhs tbrmrrla for the diagonal elenents of I, the
60 CONTINUE
methocl is also callcd the square root method.
C CALCULATE VECTOR X
Consider now the soltrtion of simtrltaneous eqttatiotrs
x (N) : A (N,NN)/A (N,N) AX : B. Substituting A : Tt ?", in the above eqtiation,
DO100L:2,N we get. TtT X : B. Let Y :TX- Then l"rY : B'
I:N-L+1 The nrcthocl ol deternrining 1he utrknowns X consists
C I VARIES N-I TO I thercfore of the following steps :
SUM: A{I,NN) l. Determirre the ttiarlgular rnatrix I from the qiven
matrix l. using the above forrnulae.
II:I+1
DO80J: II,N 2. Get fr. the lranspose ol Z, usi',g the relation Tiit : T1i'
80 suM == suM-A(I,J)'FX(J) 3. Fincl )'. from the relation Tt Y ''= -B (a system of
cquations).
100 x(I): suM/A(I,D
4. Find X, from the relation y *- T X (a system of
6.10 Cholesky Nllethorl lor Symmetric Matrices equations).
6.10.1 General Case For asystem of 3 simultaneous equations, the
steps may be written as below.
The method aims at factoring or decomposing the given
symmetric, non-singular coefficient matrix A, i'e' ex' Given
pressing A as a product of 2 factors, a lower triangular (An 42 A$l ix,l : tBrl
matrix-Tt multiplied by an upper triangular matrix T,
cach one being the transpos€ of the other, as
tl:il:tx::j if;j 13:j
'po11dde flluaruo,ruoc eq uec ssn"D uotl+!:1
Jo pog]our ]uellscxe
uB uag,rr {nI \guoa eg 'ralelroq 1ou .(eur goge Iota- I roJ llYlery4!Y=-!x):tx
aqJ, 'Xul?tu culotutu,(s € olul il SuruerruoJ puB uorlnlrlsqns pJ€/t\)lcBq .{q uonnloS 'rrr
esodsuerl u^\o slr [q 11 Eur,{1dl}lnu }sru ,(q pelpuuq
aq oslu u?r xrJlrru luercgeoo orrlaurru,(sun uV 'g l*! ot l: I
uol!: I
'(gg) ayopsa4'(1g) snanTJ pEoU 'sorrrlcr.u uertnu.roH
u: i roJ rvl(btY t'tv3-
ot I ts) : lx
elpueq oq paldu pe ,{yrsee aq u€c porlleru aqL'L
uorlnlrtrsqns prB/r\JoJ ,(q uorlnlog 'lt
'(9g) a7opsa21 '(gS) xo,{ '(gg) ta1o1,y puo aqkktog pead .9
I-101 1:z
'poqleu elilrlooc ssneD uol!: {
Jo uorl€ururrla ssnug esn 'relndruoc eql uo Gunl a ol I : r roJ !!yl(bth, PtV 7* ttyl : lty
orou ,{ppun seurnsuoJ loor erenbs fo uollcetlxa uorlrsodwoceq 'r
y ro 'e1qe1re^€ tou sr .,(1r1rle3 slql Jl .roindruoc aq1 ',rrolag sB ruJoJ lcedruoc ur uolJrr,{\ eq ,(eu
uo alqElre^€ eq lsriu crleu{lrre xaldr-uoc 1o ,{1rllcug
surqlrroSle pe8ueqc eqa 'd1e,u1cedser ,1 pue g 'y vo
'{cerncce Surrnsua roy .{.russareu oq oslu 11ini3ur1o,tr6
'xelduroc eq ,{eur L[ slueruaye aql 'olrugop-e,trlrsod uellJr,rJe^o eq deur X pu€ 1 J ecueg 'pelnduroc
ere fle,rrlcedseJ 1X pue ltr '[t1 aB uoos su suorlulncl€c
lou lnq crrleunu,(s l8er sr xlrleur luerJrJoos cql JI..s Jer{lJnJ ul perinbcr lou eJB Il pu€ '!g '[ly s]uaurelo
'secrJluru alruqep-elrllsod cul ler{l suqlrJo8le eirogu erl} tuo{ po^Josqo eq fuur 11
-:ruufs JeeJ JoJ poqleru loo;-elnbs (>1se1oq3 eqt ut uotl +
pepeou 1ou sr Surlonld lng .,(cerncce eltsue ol pasn
!: !
Ioll-ll:l roJ llJlgx,ilJ<-U): lX
sen Sullo,ud 'poqteru uorlaururlo sslteD er{l q.l uuJlr^ : ,X
'elugap-elrlrsod lo{.r tnq cr:teunu.(s lual ril
te8 e,11 'g'9 elduexE
lr ueql '(!!!) rou tnq '(ll) pue (l) sal}Sues xrJiBru E Ji '.
ur peureldxe uorllqusqns pJul(IJeq Jo poqleur oqi Sursn
I ttv !tv.
rz;/;troJ0<l l';r, fixt, ['.:-r -- o o]
It'v "Y i",t loxI i'Y "J oi
'o,ttilsod sr Lt{ ltx, lt,-/ "tJ ,rJ)
srueurslrotep pueq-Usi .reddn slr ile Jo onle^ ogl (ll!) uloU pourulqo sr X rolce^ trorlnlos,eql .,(llBIrrC
Ity : tlV'e'r 'crr1eruru.,(s sr xr:leur 'e.teq elSuerrl reddn etll ur poJols su
aql (il)
'laer are sluoruels aql J Jo sluoruele aql Sursn e.te e^\ esn?coq sl spIJ .Z.g
l1y (l) eiduruxE ur legl uro{ lr.ro.roJrp sr urqlrro8le erll
eloN
: saqredord luul.rodur 3ur,vro1yo3 aql Bur,req sacrrleru ^\oq
'e'r'seculBur luorclgaoc elntgep-olrlrsod clrleurur,{s I-JO}I: 1
uolZ: I roJ tulQtf, ltJ=- !S) : t.tr
IEaJ JoJ luorclge lsolu pu€ ]selse.J 3ql sr por{13ru slqJ.t
.',,ftoureur Surnes snql 'tl
uo ue]]rJ,r\rs,to eq uec ,teql "Jltg: tI
Jeqlmg 'sllnsal al?tpetuJelur .;o e8etols Surrrnber ,{11ucr1oqu,{s r6
,rJl(,|,'"J _ ,tr trJ _ *g) : ,,1
noglllri uorlulncl?c eurqceu e18urs {q peulrrrjalep
eJe xrJlerrr reyn8ueul ;eddn eqt Jo slusr.rreJe erlJ_ 'Z uli(I "J -"9) - ,,1
luoqrppe cru;qe81e u?*zutrut "Jlt{ : t^
suorlecrldrlpru u++*8*ra? se 1( JOICeA UA1OU{Un
suorsrArp u eql saarS '7'9 alduexg ur peuruldxe uorlnlrlsqlts pJs,rloJ
sJ^lo^ur poqlau rlll. 'l Jo porilolu aq1 Sursn 'suorlunbe e ssoql Jo rrorlnlos oql
poqpw a41 uo l'g-',: ["A lrrL rrJ ttJl
'Jl8q o] Jneulqllls t"g | iu.r i o "li
egl secnpal srql 'lJel ur suruuroJ e13uul:1 Je,&\ol ei{I
I'gI ['.t i o "-to''zl
'e"FIuJoJ eqt ur'flJo el3uer_rl raddn eql ur .{1uo siuatuele uaqr
i""J o 0l ,"J ,rJ it'tn ti., t:ty)
oql 8urcn oJe 01( leql ,{pepcrl:ud paiou aq ,{eur 1y "uJ I
\""J ""-1, 0l
ttLi o ."J "rJi - t!.y tEy zryi
fttJ t
'u<4 ro 0>7 JoJ psllruo ^'J. 00 ul ) ),tty, d.V utl
sr srrrJel
Jo uorleuuns 'elenruro; e^oqE er{l JIB uI J il laT
L9 sNorrYnDg snoENvrtnli{Is
MATRIX OPERATIONS ON THE COMPUTER

Some points about the program 20 x (ti : suM*A (I, I)


l. N:3 stands for the size of A, B, and ,K, as C SOLVE BY BACK SUBSTITUTION
usual. DO30L:l,N
2. Variable SUM stores the summations
I:N-L+I
suM ,: x (r)
Aii
- 2Ati A*j II-I+1
For diagonal elements. i :.i. Hence square root of rF (rr
- N) 21, 21, 26
SUM gives diagonal elements only for i -7. But 2t DO25 K:lr.N
division by Aii is very often required in the further 25 SUM : SUM A (I,K)*X (K)
program. So. to save time on the computer, reci- -
procal of lrr is stored in location lii, multiplication
26 X (r) - SUM*A (r,r)
by this term is done in further work. The variable 30 CONTINUE
TEMP stores the value llAii until all the elements PRINT 93, (I, X (t),I : 1, N)
Aii are computed. 9l FORMAT (4Fs.0)
C PROGRAM,6.IO.1
92 FORMAT (3F10.4)
C SIMULTANOUS EQUATIANS CHOLESKY 93 FORMAT (r 10, Fr0.4)
C METHOD 94 FORMAT (4Fr0.4)
C SYMMETRIC COFFICIENT MATRIX END
N:3
DIMENSTON A (3,3), X (3), B (3) 6.10.2 Symmetric Coefllcient Malrix Stored as One-
C DECOMPOSE MATRIX Dimensional Array
DOI0I-l,N Consider the system of 3 equations given in Art.6.4.1.
READ 91, (A (r,J), J : l, N), B (r) The main points about the modified program are as
PRINT 94, (A (I,J), J .= 1, N), B 0) under.
IN:I'.-I
DO 10J == I, N l. The augmented rnatrix of the 3 simultaneous equa-

suM _.- A (I, J)


tions is punched one row per card.
rF (r 1)6,6,4 2. The elements of the augmented matrix are read one
-
4 DO5K:1,tN row at a time and stored temporarily in array R
5 SUM : SUM - A (K, I)*A (K, J) of 3 terms. After the operation of decomposition.
6 rF(J-r)7,8,7 the useful term of R (i.e. term corrcsponding to the
7 A(I,J):SUM*TEMP upper triangle of the symmetric matrix T)
GO TO l0 is stored in array A of 6 terms.
8 TEMP : 1./SQRTF (SUM)
3. Thc correspondence between the elements of the
A (r,D - TEMP
two dirnensional symmetric coefficient matrix
IO CONTINUE and this one dimensional array is expressed by the
PRINT 92, ((A (I, J), J : l, N), I : l, N) arithmetic statement function
C SOLVE BY FORWARD SUBSTITUTION
(N-
LF (I, K, N) -- r*N
- l* - l)/2
K) (I
DO20I:I,N -
suM '_- B (r) exactly as in Art. 6.4,1 (b) and Art. 6.6.2.
IF G l) 20,20, tt 4. ,B stands for the cotrstant vector as usual.
-
ll IN.=l-l
DO15K:I,IN 5. ln all other respects, the program corresponds to that
r5 suM : suM -A (K,I)*X (K) of Article 6.10.1.
l' trzl (N'I'D d'I - n
l*t 'uJl
ttJ) I +.I_N: I
l"J N'I:T0€OO
s? J xrJl"ru ,{q paceldsr pue
Notrnrlrsgns ))vg ,\{ lIA'Ios
'uqlroE1e pegryotn ? 'esJnoc;o 'Eursn ,I'0I'9 elJIlrV (rr)v*nrns:(t)x 0z
ut peureJdxa se posoduocep uoqt sr f xrJlern aeu sg1, (x) x*(rx)v-nns: rros 9I
'sarnEtg ploq ,(q polscrpur se uralled repEuelcer oq1 ur (N'I')) g'I : I)
Jepp?l ro puoEerp B uo suorl"col ,{dncco t\ou 'xrJtrBru NI.I:)SIOA
erenbs plo eql ur uunloc ? ur sluetuele ,luetueEuelresr
I-I:NI II
o{t o} on61 'suor}Blncpc oql Eurmp ,{1a1o1duroc tt '02'oz (t D gt
perouEl aq Jo oJaz sp peleeJl aq Jeqlre feu acueq puu -
(N 'I'D gf : II
tslxe loul seop xruteud aqtr ul lty u.rel (Z) pu" (Dg : I/linS
^rou
tno lJel ore xrrluru plo or{l Jo srure} reqlo (1) legl atoN
N'I : I0Z Oq
| *vl I rl | t"vi NOIrnurSgns c
i"Y '"rl lrui i"ov '"y) (ruvA\uog ,\s sNorrvnbg ir^'Ios 3
L"Y "Y) Lt z) l"ty ,tyj (fi 'I : x '(x) v)'z6 rNlud
Y xurou plo Y xutDut aaN ANNIINOC OI
sB ruJoJ rep8uepar B ul poJols dhrar : 0D v
ag feru alEuuul reddn eql ur struoruale oJoz-uou eq1 ,(po (rrns) srubs/'r : dr rsr
'.rslnduroc er{tr uo eceds ,fuouraur olJasuoc oI .7, Jo 0I or o9
qlp!.tr pu"q JIBII ? ssrl 1l 'O: r"y : erY slueuala dhlilJ,*hi0s : ftD V L
sll s" xrJlertr pueq esteds B se peJeprsuoc aq osle ,{uu L 'g' 'L'(l- r) gt 9
Z'01'9 pup I'0I'9 lelcllrv g snonerd eqlgo suorlenbe ftx) v*0x) v wns .: r ins s
snoeualelntuls € eql Jo xrJleu luetclsaoc cr:leuurfs sq1 -
(N 'f '){) g'I : r)
xlltory rua1cg{ao7 pwg tlpg nt4aww{g g.0I'9 (N'I'>I) cr : t)
'vt 'n 'I '0 NI.I:X9O(I
'zt 'I 'V 'I v'g'g(l-DgI
0)u: wns
't '0 'r 'z (N'f 'D cr : fI
sprD? plo(J N'I:fOIOq
(INa
I--I:NI
(D g '(N 'I : ) '(:,I) u) 't6 rNIlId
(l'orgl) JVr iuoc v6 (D g '(N 'I : x '(>) u) '16 cvgu
(t'otg'oID rvwuod €6 N.I:IOIOC
(l'orse) rvhiuo{ 7,6 g:N
(o'ssr) rvhiuo.{ 16 elfi *t) *I-(:*N)-N* r : N)r'r) c.r
(N'I : I'ft) x'D '96 JNIt{d (c) u '(e) x'(e)g'(g) v NolsNirhuc
IINNIINOS Og XIUIVW ASOdhIOJ!Iq c
(rD v*runs : (D x sz ,LUV c
(x)x*(xO v-hrns : r rns sz 'IVNOISNIIhIICI ANO SY CSUOIS XIuIVI^I c
(N')'I) cr : ){I INgIJIddOJ c
N'II:)SZOO tZ ]IUJAhIWAS .{O 3.IDNVruI UiIddN c
9Z'tZ'rZN-tr)st CIOHIlThI 3
I + I: II I)SiTTOHf, SNOIIVObiI SNOANVNNhIIS c
(r) x : rtns e'01'9 hrYuDoud J
69 sNorrynoa sno irNvr'Ionrs
MATRIX OPERATIONS ON THE COMPUTER

This is then used to determine veclor X by a combina- i j k p TtpY*


tion of forward and backrvard substitrrtions as outlined I
in Article 6. l0. l. 2 ll2TnYr
The reader may also study the example of the storage J I 2 2 722Y2
of a larger symmetric band coelficient matrix on the Note that the products Tt p Yt, are not formed if t-l <j'
above pattern given in Articlc 6.4.3 (c). Finally the formulae for vector X become
Let r, : llumber of equations : 3 above Xs : Y3lTr1, Xz : (Y" - Ts2X3)lTzt,
ft : lulf band width : 2 above
xr:(Yr-TpX)lTr
The lbrmulae for elements of 7 given in Art 6.10.1 or symbolically
get modified to Xi : (Yi -lTip Xr,)l Tir
t-
Tn: lArt,Tp: ApfTlo Tzt: \/T;-f;7;
722 : A"2lT2t, Tgr : {Z;=T;:7; where ivaries from n lo l, k : i + I toj' .i :n the
number of equations or i + h-l whichever is less.
or symbolically, p : k * i + 1. The vah.res assumed by them are tabu-
Tit == \/ Air > fr, '10' lated belorv.
- It
i k p TipX*
Tii : (Aii Tp, Tp)lTir for 3-
-2 k
2 3 2 Tx2X3
i:1ton 1 2 2 Tt2X2
;: I to n- i I I or /r rvhichevcr is less ifj < t + l.
Note that rhc products Tip Xt are not formed
k : I to h- j or i- I rvhichever isless (k < 0)
Some points aboul the Program
P : i- lc .:
r:k+1 l. The program preserrted is lor solving N 10 eqtra-
tions.
5:;+/c
2. The half banci rvidth of symmetric sparse coefljc-ient
The values assumed by these variables and the terms matrix is KBH :3.
obtained are given in the following table.
3. The subscripts p, r, s etc. used in the above explana-
;.i kpr s Tpr T.sp tion are replaced by other permissible FORTRAN
ll vari ables.
7) 4. Variation ol i : N to I is obtair"red by using another
2tll2 t '^ r,, variable L AsI valiesfrom l to N, I : N- L + |
22 varies from N to l,
31r22 2 722 7122 5. lvlatrix 7 is overwritten on ,,1,' similarly X is used
in place of I as rvell as X itself.
Note that the products Tpr Tps are not obtained if
the upper lirnit of /c is less than 1. As before Zis over- C PROGRAM 6.10.3
written on l, and reciprocal of Zlr is stored in C SIMULTANEOUS EQUATIONS
location lir. C CHOLESKY N4ETHOD
The formulae for vector Ybecome C SYMMETRIC COEFFICIENT MATRIX OF
y : B1l Tp Y, : (8, Tp Y ) | T14,' Y 3 : (B 3- T2' Yr)I T
C HALF BAND WIDTH
1
- ", DIMENSIONA(10,3), X (10), B (10)
or symbolically,
N:10
k: i-l KBH :3
Yi : (Bi-2 Ttp Y1)lh1
k:j READ 991,((A(I, J),J: I,KBH), B(I),I: l,N)
where i: I to n, j:l if t + l<ror else j:i-h+1 PRINT 991, ((A (I, J), J : I, KBH), B ([),
providedj>i-1, k:jtoi- I and p:i-k +1. 1I:l,N)
The values assumed by them are tabulated below. C DECOMPOSEBAND
uortlrrgep eql uo^rE p?g e^\ ,87.2 epqrv <z roldBqc uI
0) x: yrns z6
poq|au uolsra^u! xlrfBtr^tr II.g
N: f 16
'(g1) losaag puo Suag pea4 16 '7,6 '26 (N - f) dI
'pe;rnber ueqi, pu" sp pEoJ I-Hg)+I:f
pu€ tnnrpotu ,{rerpxne rre uo papJocoJ eq oqe feru
f,t.It o^rluuJoll€ eql ur la8erols eJoJ ul 1de>1 eq . eru I+'I_N:I
x JOlceA uorlnlos oql pu€ Br .rolco^ luusuoc aql lsoru N.I:'IOZIO(I
eql lV 'parrrrurotsp sq ,{eu .tX s}uoruolo agl 'll rro IINNINOJ 06
Eurleredo pue .roJ e Sutluraueg .xr.rll?r.u luercgeor aql (r) x 'r 't66 rNlud
Surrols 3o ,{lsseceu ou sr aJorll .sosec rlJlls uI .IJoA\
18
(t'D v*irtns : (t) x
,(ppee.l sporllotu uorleJal eql leql (elrugep elrlrsod
cu1eutu,,(s 1ee.t fllensn) qcns sr xrJluru eql JeqlJnd .,,\ro.r
(>)x*(xr')) v- hrns : wns oL
,{q no: xrJ}uru lrrercgaoc eql elureue8 ol luerueluoc l+)-I:)r
ellnb si 1r sruolqo.rd 8ur;eour8ue pu€ curluolcs .{ueu u1 Nl 'I: ) oL oa
'pelelnol"c sr X rolce^ .7 puu 99 '99 't8 (f - Nr) cl
J Jo stueuola Eumn '.t11eurg .{stp uo Jo peJs eJoc I_I: NI
ut perols eq ,(uru ; .paurruJelop sl (I.01 '9 elctlrv (r) s : wns 79
eas) 7 Jolca^ pue puar eJB J Jo sluauelo ueql 'J
I:f I9
Jo sluetuoJo ,,{q peculder pue pslepdluer.u .pBeJ uerll JJe *
sluer[ols sU '.{es .1srp € uo popJocal oq lsJU Aeu y z9 't9 '19 (HB) rr)cr
xrJleru puuq eqt 'poqlau ,(4sapq3 eql ur ,eldruexe rog l*l-1t
',{ressaceu Jl slql o)rl peor puu poprocaJ l+Hs) - I: f
oq osle {er.u sllnser elptpatuJolul .sllnseJ ulBlqo 01 N.I:I06OCI
uodn pelu-rodo pue poJtsep JopJo oql ur ,,{resseceu ueq,tr ANVSAA"IOS f,
pu" su pBoJ ueql ere sluetuels ellsrnber aq1 'ade1 :o 't : I '(HB)'t: f '(f'I) v)) 'zoo JNIud
Islp e{ll tunrpaw ;(rerpxne oql uo pepJocer lsrg sl lr IINNIINO3 09
'ospc ,(ue u1 'elq€lre^" .{11er1rur eq ,(eru 1l ,srualgord
elrtos JoC 11es1r rqndruoo eql uo pal€Jeue8 ,(1;ensn dhrar: (t'I) v
sr xrJl?tu luerJqJeoo leJnEuulcer eql ,sueyqord Ful (wns) sJubs/'r : dhri[ vs
-rssulEue puu cgtluetcs uI .uo os pue ,srun:p crleu8uur 09 0J oo
'sJsrllo eruos 'sade1 crletr8eu ,s.roqlo atuos ,s>lstp Jo dhtrllJ,rhtrOS: (f ,l) V tS
esn eql llurJed srelndruoc auog .telrrduoc qcua qlra\
t9 'v9 'es (I f) gI IS
olq"lt?Ae ,(1mdec a8e;o1s ,(rer;rxnu osn ol sr uerll Uol (yr 'tx) ()) 'I))
,(ean lueruezruoc iluo eq1 .-ralnduroc erll uo .{1p; pelep
v* v - wns :- htns os
-oluuolJ? aq lorrusc qlpt& prr?q Jl€q Jo xlJler.u luorc )+f:)f
-Igooc reln8uulce.r oql ua^a qcJq^\ uJ /r\eJ lou cre saseJ )_I:I)
sactuon[ Tuapt$aop puug r7ta,uuttg a&toT ,.0I .9 I+):)X
fB)'t:)090c tv
AN:I
(t'ozc 'ott) w 'tb 'rs (r -.fsx) sT
tvhtuol 166 (r'r)
(u'ot.ae) v: wos LT,
J-vr,^tuog 266
(o'ot.It) rvhtuoJ r66
Nt: fs>I 9E
OT,I
JINNIINO) Lt 'Lt 'gt (rgx - NI) gI
(r) x 'l '166 I - HB): fS)
(t 'D v*ntns :JNrud
(D x lol iN'I : I09 0q ZE
())x*u)'t)v- L{ns: r ns oor HS): IN I'
I + t-): )) zt'at 'tt (tN - Hs)) gI
f'tI:)00ioc 96 I_I:NI
lot '96"96 (f - il) ir I+I-N:IN
I+I:II N.I == I 09 OCI
sNolrvnot snosNvt'Inxls
MATRIX OPERATIONS ON THE COTIPUTER

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

obtain more correct results. As explained in the next


Chapter, a suff.iciently .Iccurtr.te inverse carr be obtained, C: - 0 .3410 (-0. 3668) +0 .3224 (0.29s0) :0.2231

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

6.14.2 Symmetric Cofficient l[atrix Stored as One- 30 x0):suM*u(D


Dimensiortal Array
PRrNT 92, (X (r), I : 1,
Consider the system ol3 equations given in Art. 6.4.1. 50 CONTTNUE
The main points about the modified program are as 9I FORMAT (9Fs.0)
under-:
92 FORMAT (3F10.4)
1. The elements of the upper triangle of 3 x 3 square END
symmetric coefficient matrix are stored rorv-wise
in one-dimensional arral' ,{ containing 6 terms. exactl;. Data Card
as in Articles 6.4.1,6.6.2 and 6.10.2. 2. l. 0. 4. 1. 4, 4. 12. 14.
2. The correspondence betu,een the elenents of the twc
dimensional square symmetric coeflicient matrix and
6.14.3 Bond Cofficient Matric.es
the corlesponding one-dimensional array is expresscd Consider the ser of r or A' : l0 equaiions given in
by the arithrnetic statement function Art. 6.4.3. The coefficienr matrix A is of lO x tO
LF (I, K,1rq : I*N-(N-f)-t* (-t)tz size. It is sparse, having ftrll band width ru or
NBW : 5. and half band width ir or KBH : 3. Also
exactly as in Articles 6.4.1(b), 6.6.2 and d.10.2; NBH:KBH_\:2.
3. B is the constant vector.
6.14.3.1 Square Sparse Matrix
4. Vector [/ stands for the reciprocals of the diagonal
elements, i.e.
When the size of the coefficient matr.ix z{ is not very
large and can conl'enientli, be accommodated on
Ut: llAt, Ur: llAo' and {/,, : 1lA,
the
computer, it is dealt rvith as it is on the lines of the
general case studied earlier in Art. 6.14.t.
C PROGRAIvI 6.14.2 But the
matrix I is spars.'. We may therefore reduce the time
C STMULTANEUS EQUATTONS GAUSS ol execution of the problem by avoiding multiplication
C SEIDEL METHOD by zero elements. Thus, omitting terms involving
C UPPER TRIANGLE OF SYMMETRIC multiplications b,r' zero, equarion (7) of Art. 6.4.3
C COEFFICIENT MATRIX STORED AS ONE gives
C DIMENSIONAL ARRAY x? : (29 _ I x, _ 2 Xo _ 4 X, _ 2 I 6
DIMENSTON A (6), B (3), X (3), Lr (3) Or in symbols, ^.r)
LF (I, K,N) : I*N
- (N
- K) _ I*0_l)/2 : _ _ Aro xu _
N:3 . xz @, Aru X, Aru x, _ Arc X")lAn
t.e ..
READ 91, (A 0t, I =. 1.6), (B (t), r _ 1. 3t Xi:(81-ZAq X1;lAii foi i: lron
DOl0I:l.N i: i-2to i + 2
L:LF(f,r.N) providedT l i,
M:LF(r,N.N)
PRINT 92. (d, (J,,, J : j>0,
L. M), B (r)
u (I) =- 1.,/A (L)
jb n
It may be noted that the right hand side involves coem_
lo x(r): o
cients ol X oniy in NBH :i2.columns on each side ol
DO 50NC: I, IO the diagonai coiumn 7. Hencc for an1, row I, wc
DO30r: l,N restrict column .I within IL:I-NBH to IR:I + NBH
SUM : B (T) provided ILis positive, IR) N andJ#I. The FORTRAN
DO20J:I,N program needs little explanation and ,is presented
rFo-I)fi,20,12 below.
ll L:LF(r,J,N) C PROGRAIVI 6.14.3.1
GO TO 13 C SIMULTANEOUS EQUATIONS GAUSS
t2 L : LF (J,I, N) C SEIDEL METHOD
13 SUM:SUM-A(L)*X(J) C SQUARE SPARSE COEFFICIENT MATRIX
20 CONTTNUE DIMENSION A (10, 10), x (10), B (10),u(10)
SNNIJNOJ OV s?
(l) x 'r 'e6 rNlud uees ,{Jruelc snql sr X Jo uorl€uil.uJelep ;og urqtrroEle oqa
(r) eLy 8x uty ex zLy ex tly Lg) : Lx
n,.wns: (t) x "vl(ux - - - -
ANNIINOJ O€ 's1oqu,(s ul .ro
(f 't) v,,(>) x-runs: nns ET, gl(o xz
-'xt - "x z- ? t - 6T): Lx
tz'ot't(,
$-t) JI zz sa,u8 (1) uorlenbe
ot'zz'zz(N->)sr tz 'sloJeq sv 'e^oqi? sp saltll?A etuus erll o^l?1[ qlpl,r\
rz 'oE 'or ()) cr pu€q Jlur,l : HgX ,r() ry pue 'qlpl^\ puuq IInJ : /l{N
f+ H8)-t: ) Jo dt 'slrorlunba .;o Jaqllur.r : N .to u s1oqu,{5 'azrs
1\\BN
.I : T OT OCI ! x 0l lo sr r l.toN '(q) C'l's 'uV ur peuruldxe
sP pcjols oq xr.rll?rrr lucrJrgeoo pucq oql Jo slueursle
(r)s : nns oioz-uou eqt ,{1uo la1 ,{.rourau ralnduroc alJesuoc oI
N't : t 0t ocl xuluIAI
0t'[: 3N 0S OCI
lu€rlgooJ pueg reln8uulcaX culaurru{sun C t'bl'9
s3t\tI0l NolIVuSIt oct 3
SNNIINOJ OZ OI{E
(nsx'r) v/'t (r) n: (?'ozJ '0il) rvh{uoj t6
0 - (r) x
(o' 8r r r) lVrN z8 uoi
(t)fl '(A\ax 'r: f '(t'l)v) '16 rNtud (t 's.r u ) lvruUor L6
(t) g '(1Y\BN 't : f '(r't) vt'16 ctvgu (ot 't : I '(l) x 't) '16 iNtud
N'I: t0zoG ENNIINOJ OL
s: A\8N ANNIINOJ 09
t: H8) (t) x 't 'er, -LNtua
OI: N (r) n,,lrns (r) x :
(ot) n '(ot) x '(or) s '(s 'ot) v NolsNtriitc 3NNIINOJ 09
SrNat Eta ougz-NoN to xtul_vN J i)v ''ill;:)ff *
JNEllIJilllOl CINVB dVlnDNVIJ3tl J ' - T,i:
CIOHI:I'^{ ISCII3S J ut 't[: f 0s oc zv
ssnvD sNorrvnO3 snoENyt tnr^{ts J N: UI t,
7't'vl '9 r\ivuDoud :) t, '1, 'zt (x ut) ct T,€
-
I : '1r IT
'oJoz lorr elu ( xr.rluur asluds e;enbs
zt 're 'rr (rr).{r
0l X 0l eql Jo lurroSerp aql uo oJa,\\ qorrl,tr) t.ty H8N + I: Ul
sluoruolo ler{l pounss" sr 1[ 'p del-ru ur pf,.ro]s elu -IT
(ttS)'I) v 'e'r tttV slllouale 1o sluro.rdrcc.r eql .t H8N - : I:
(r) s Nns
'suollenba Jo Jequnu .re3,ru1 -ro3 pesuoJJrrr rel ,rutu
N'[: l 09 oc
suorl€Jelr Jo Jeqrlrnu lelol aql 'Srrrlouep 0l : JN.Z
0t'r:JN0roc
'ruu.rSord snor.,re;d aql ur se sonlul pu€ (r'r)v1'r : (r) n
Suruuew slues elJt o^€rl ABN 'Hg) 't'J'51 sloqu{g'1
N't:I0toc
un,tSo.tcl drlt JtrcqD sptod autog (N't : I '(t) g '(N '[ : f '(f't) v))'z6 rNlud
.{ (r) :
a '(or 'r r '(t'D v) '16 cveu 0e
Jo
senl€A elrlrsod ro.; ,{1uo per-ueJ sr su.i.la} Jo uor}Br-uulns 0r't-r0zoc
u4z '!+I'0< I o: (Dx or
peprrordt!-{+l :)t T{.I: IOI OCI
htoll- [ Z: HSN
ro| l:.r roJ qlvl(rtxIf <-- !g): lX OI: N
LL SNOIIYnOg SnoaNvJ.InNIs
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

2. Program, however, ref-ers to the solutiort of 3 equa-


C ITEDUCE LARGEST RESIDLJAL'TO ZERO
tions, like other programs, for the system AX : B. IF (tslc) 41, s|,4l
4r DX (IROW) : -- R (IROW)1' U (IROW)
3. Constants ,B are included in the (n + I ) th coltirnn
ol matrix ,4 ,' thus .4 is a 3 x 4 augmentecl nlalrix X (tRow) : X (rRow) + DX (lRow)
PRTNT 93, (I,X (t), R (I), I : i, N)
4. Ihe augrnetttecl matrix is read as usltal. The sign
of the constants iu the (z * i)th column is changed 50 CONTINUE
dr-rring tire plogram io satisfy lhe equation of R;' 5I STOP
5. As the reciprocals of diagonal elements, i.e. Aii, 9l FORMAT (12F5.1)
the coefficietrts of Xi are required in each. cycle of 92 FORMAT (4F10.4)
iteration, they itre calcLLlated once only ernd stored 93 FORMAT (110,2F10.4)
in array [/. END
6. The absolute value ol Ri is taken while findirrg the 6.16 Multiple sets
biggest ol them. Consider the systems of equations :

7. NC denotes the serial number ol iteration. Its rnaxi-


mum value is limited to l0 in this program. In {:I{t, - i .) X1+X2
Xt+2X2 - )
-l rzl

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
|

determined uniquely. Thus urrique solution does not


'rx"t
Similarly the solution of the homogeneous set of the
exist. first type
First type
Xt* Xr:0
xr+x2:2 2X2 + zxz: O
Herer:r':l<m<n. may be written as
The solution may be writterr as Xz: k,
X': 2-k' l&l _-
Third type lx'i i:l--l-ll
Xt+X2+Xi:3 This procedure is adopted because it is found very con-
zxr+zxz+2XB:8 venient for computer work. Note also the similarity
Here r:l<m. r'-2: nx<n of solutions of the homogeneous and corresponding
non-homogeneous sets. This similarity is made use
The systern is rnconsistent. of later.
The criteria for the solution of non-homogeneous
systems may therefore be summarised as under :
In the above solutions k is arbitrary and may have
any sign. So we may also write the solutions as
l. The system has no solution it' the rank of the
under :
augmented matrix r' is greater than the rank of the
coefficient matrix r. fx'l - 'tzttj * o l' ll una
2.If the rank of the coefficient matrix equals the rank 'txr) .0 i -l J

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

2. In a general case if M is less than N, coefficient BIG:O


matrix ,4 is still considered as having a size of NxN, DO30J:I,M
the rows M + I to N being filled with zero elements.
As usual the
DO30K:I,N
augmented matrix is N x (N + l)
size.
AB : ABSF (A (J, K))
rF (BIG
3. Elimination is done M : N times followine the - AB) 27,30,30
Jordan method.
2] BIG: AB
IROW : J
4. For I less than M, if A (I, I), the pivot element is ICOL : K
found to be zero, then obviously rows I to N contain
at this stage zero elements. Hence the diagonal 30 CONTINUE
elements in rows I to N are assigned the {alue of EXCHANGE ROW IROW WITH I
-1. IF (IROW-I) 41,41,31
5. Rows I to N contain zero elements, i.e. N-I+l
rows contain zero elements. Il elements B (I) 3I DO40J:I,NN
to B (N) are zero, the system is consistent, otherwise, TEMP:A(I,J)
not. Vector ,B is in the (N +l)th column of L A (I, J) : A (IROW, J)
Hence elements A (I,NN) to A (N,NN) are scanned 40 A (IROW, J) - TEMP
and the number of zero elenrents is counted for 4t IF(ICOL D 51, 51, 42
comparison purposes. -
EXCHANGE COLUMN ICOL WITH I
6. If no pivot element is found to be zero till I :M, 42 DO60J--1,M
steps 4 and 5 above are bypassed.
TEMP : A (J,I)
7. Columns I to NN are theu rearranged and printed A(J,I): A(J,ICOL)
to give the general solution.
60 A (J, ICOL) : TEMP
8. For M greater than N, steps are same upto N elimina- J : JCOL (D
tions. After that elimination is discontinued and JCOL (r) : rCOL
step 7 above is follorved.
JCOL (rCOL) : J
c PROGRAM 6.17 5l PRINT 91, (JCOL (J), J : I, N)
c M SIMULTANEOUS EQUATIONS IN N DOTOJ:1,M
C UNKNOWNS GAUSS JORDAN METHOD 70 PRINT 94, (A (J,K), K: l, NN)
DTMENSION A (4,5), X (4), JCOL (4) IF (A (I,D 52, 104, 52
c READ 91, M, MM, N, Nl, NN s2 RATrO: LiA(r,D
READ 92, ((A (I,J), J : t, NN), I : 1, M) TI:I+I
DOIOI:1,M ELIMINATE COLUMNWISE
PRINT 93, (A (I,J), J: 1, NN) DOSOK:II,NN
10 CONTINUE DIVIDE ROW BY PIVOT
DO20I:I,N A (I, K) : A (I, K)* RATIO
20 JCOL (r) : r DO80J:I,M
tF (M-N) 21,26,26 IF (J
2I M:N -I) 53, 80, 53
53 TERM : A (J,I)*A (I,K)
DO 25I : MM, N A (J, K) : A (J,K) TERM
-
DO25J:1,NN DIF : 10000.,:.ABSF (A (J, K)
25 A(I, J) : o -
I ABSF (TERM)
C DO ELIMINATION N TIMES IF (DIF) 54, 54, 80
26 DO100r:l,N s4 A(J,K):0
C FIND PIVOT ELEMENT 80 CONTINUE
IROW: I DO90J:I,M
ICOL : I 90 PRINT 94, (A (J, K), K : t, Nlg
puo lclut,tocrw ur ru"rEord II NVUJUOC euo 'fe,r truerueluoc pu" luercge lsotu egl sr srql trsql
e€s pue x sJolce^ uorlnlos eqt urclqo ol Euilus lnogtrlrr seoE 11 .tueruotels
,{puspuedepur pe^los eq XATdI IOC iId,1I
"x snql deru ur"ts,{, qc"g Sursn ,{q xelduroc er" secrJleru eql legl relndruoc eq1
'sluorclueoc I"eJ
Iecrluepr Bunuq suorlunbe snoouullnurs rrrJoJur o1 ,{resseceu ,(ldruls sl 11 .suorlenbe xelduroc
'1r 3o smelsfs o&l luesordsr trou (E) pue (p) suorlenbg Eunlos roy e8ueqc eplrl glr^\ posn eq uec solcrue
G) E ry - ,g ,-(,y) : ,x l,,y ry -l y A,flJ Smpacerd eql q uerlrE surer8ord pyglgoC tru"^
-eleJ
rllr^\ Euop spoqletu .relndruoc B uo elqeJre^€ sl AI
se,rt3
srql .(g) ruorg (Z) lcertqns pue r_(,2)
,(q (g) uorlunbe pue r_v fq e) uortenbe ,(1drr1n6 NVUIUOd Jo osn pu" crteuqtrre xelduroc 3o ,(1111ceg 31
G) ,g ,*v + g ,-\,y) : x l,y ,-y -l v ,J,v)l suopenbtr ;oruels,{g xe1iftuo3 91 .9
seltE srqa .ppe pue
(€) uortunbe ,A,y) CINA
ry tj Kq (7) uorlenbe ,{1da1n6
'.rl.oloq s? peaco.rd oqe {eur e.tr .relndruoc eql uo (Norrnros oNHIr 'xo;) JVWuoc L6
ure1s.(s N e x NZ slql eleporuuocce o1 elqrssod (s'orsE) Jvhruos v6
lou sr 1r esec uI .ure1s,{s slgl OAIOS 01 pesn (o'orss) JVrAruoJ
aq Aorr uec surerEord .ezrs t6
U UVUTUOC ei{I N Z, (r'Essr) Jvhruod z6
JI
s€q suorlenbe leer go rualsfs sgl 1.r ozrs Jo sl ].
" (srs) rvlNuog I6
l,s\, l,x) lv ,vl /6 INIUd ISI
l"j l"J y)
l,v - dors
EB ruJoJ xrJluru ur uellrJ^\ eq ,{eur (g) pue (7) suorlenbg (NN'xf :
.secrJleru ) '()'f) y)'v6 rNll{d 0sl
esodsuerl ereq lueso.rder 1ou
IrrI 'I : f 0SI O(I
oP seqssp lsecrrluur oJe tg,g,,X,X,/I,,.f, leql eloN
(t) ANNIJNOJ gNI
,{ : X,Y +,Xy IINNIJNOJ O'I
Q) s: ,x,y-xy fi) rocr : 0) rocr
se,rr8 eprs pu€q Uel er{l Jo uo4ecgrldurg
AONIINOf, OgI
(t),{!*g : (x!+x)(,vt+y) dI IAT : (X.t) v
e suorlenbe xelduroc go les aql o1rr1r\ u€c en lereue8 u1 (x't)v: (x,Dv
',"x pue 'ax ',rx 'rx (x'D v : dI Igr
su^\ou{un JnoJ egl sarr6 rueqlJo uorlnlos egl ecueq puB NN .)t : ){ 0€I o(t gT,t
I?eJ eJB suorlenbe.rnoJ esaqtr ur slueruele eql il" leql aloN f taou HrIA\ I .t\OU ACNVHJXA c
l,"g) l,"x) l""y ,"y ,""y ,r"y) Otr '9(,1'otl (I 0t rocr) sl
-
l,'g I l,tx I l"'y "y ,"'y ,tryi N.I:IO'IO(I
t,gj i1il [,,21i_
,,::,7_ """,7 iitr) N.I:IS'IOq t7,t
sB rrrJoJ xrJleru ur ueql elrrm .,(eru e6
x )IoJ,ctt^ ltgNVUUVgU
t7,t
-If) cI
,"9! + (,"x1+ zx) (,"2v! +""y) tst 'tzr 'EzI (Wr -
"g: ANNIJNOf, 07t
+ (,'x t +'x) (,t"y ! + rzy)
,tg! + rg : (,zx !+ ax)! + (,zrY
I+'II:Tf 9II
"tY) gtt '\tt '9II ((NN.DV) CI
+ (,'x !
+,x) (,rtyt + rry)
: suorlenbe xelduroc
IAI'Xf : I0zI o(I €II
o^\tr JeprsuoJ
I I
ter 'Ett '€ (W * )f) cI
-Ise eroru sr r poqleu trBqr eleq
hlf : .If
f.ffnH ilt;#"l;
.U
uorsJe^ur xul€ru Jo poqlel/{
I + Xf -hI : I If III
'flsnolrre;d ueiu8 suerEord
I-: (f .f)v
eq1 Eursn ureql e^los prre N
.)f : f OII OCI OII
s0I
sursls,(s Iuer o/\\tr olul urels,(s xelduroc eq1 dn
ilds .I .SOI .SOI (N*>If)CI
: spoqlou om1 8ur,to11og eql
III
Jo euo fuu ,(q pe^los aq uec I:){f r0I
ure1s,(s'elqeluire 1ou sr ,,(lrpcey qcns .lenolrroq .esec u1
ANNIJNOJ 00I
sNo[vnoa snoirNvr]o]rrs
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

A4 : A"r: o' It is needless to state that, now, B : ,4-1. However,


verify that
The result is
[1 tl4 tl4) l2 r ll ,i 1r -3 -2,, (r 0 0'l
lo ty4 3t4l itx.-:] |.00 tl4\, Yt: il 3 ri x:i-3 i io I ol
7),
x^:z i - io r-u4i y": l0
[o 3:t4 iF) Lx,.- I J Lr o-t't4: v, rsj
i

Ir t 4: ttl-2 -l -tlsJ l.o o rJ

The valnes of the rows of AX now are 15 14, 2sl4 Note :


and l3l4 respectively. Note that they correspond 1. Vector Y remains unaffected during the procedure. It
to those of BY. was introducted just to help clear understanding.
3. Inspection of rows 2 and.3 show that ,4r, is the big- For computer work it is unnecessary.
gest. It being in the pivot position, interchanges of
2. Itis essential to keep a record of changes in arrangc-
rows and columns are not necessary. Operate so
ment of vector X, i.e. cotumn changes in matrix l,
that A"r: l, and Arr:0, and get
exactly as in the case of solution of simultaneous
rl lA U4 ) lx..-3) equations by Gauss method. See Art. 6.6.1,
io t' :irrl lxi-zl
[o o 17'ln) lx,--r) 3. For purposes of ur"rderstanding, B was taken as an
identity matrix. For computer work it is unneces-
: f0 0 tl4 I ly,- 7l
i0 4111 -tln | ; y,- lOi sary to treat it as a separate entity. It can conve-
f l -3lrt -ztll ) [r,:rsj niently be adjoined to ,4 forming part of it.
Verify that the values of the three rows of either AX
On tlte Metlnd
or BY are l5f4,25lll and, l7/11 respectively.
4. Operate so that Azs : l, At : Azz: 0 and get
l. The method involves

ltt14 0l Ix, - 3l n divisions


io 1 oi ix,-zi _1i
tt3-l multiplicatiorrs
100 t) i.&-rj n3-2 nz + n algebraic additions
l'-11/68 3/68 lel68] lY,:
:i-3117
7
2. The alithmetic work involved is thus nearly thrice
7lt7 -U17i iy":l0i
,

t, ttln -3117 - z.1n) l.r,* rs.1


that required for solving a system of simultaneous
equations. The inverse should therefore never be
Verify that the values of rows of AX corresporrd to found for solving a single system of equations.
those of ,BI.
3. Gauss Jordan method explained in the next Article
5. Finally operate so that Arz : 0, and get
involves the same amount of arithmetic as this one,
- 32-t 5l Yr:7)
7-ti
[6 ; l] lii=i\,: t
r": l0 4. For large n, the inverse obtained may not be very
- tt-3-2) vi:rs)
i
accurate. Its accuracy may however be improved as
Note that ,4 is reduced to an identity matrix, B Y : X. explained in Art. 7.10.
During the elimination we changed the rows of ,4 5. The inverse of a sparse matrix is not necessarily sparse.
and B, and columns of l. Hence .B is not in the Hence advantage of sparseness may not be available
proper form. This is clear from the comparison for computer work.
(N 'I: x '(zN 'I : f 'ft'x) v)) 'goo rNlud IN.I: IOl,Oq
ANNIINOJ 09 TNNIINOJ OC
o : (;'t)v 89 r : fi)'Ioor
09 '89 'gs (gtc) gt t : (nq'l)v
(wusr) cssv I I+N:IN
- (l'r) v) gssv* 'ooool : dlct N'I:I0ZOO
wugr - (t 'r) v : (t'r) v o:(t'Dv ol
.NN ==
(> 't) v''fi'f) v : hlu[IJ ZN f OI OCI
N.II: f 09 O(I N.I:IOIO(I
olrvdx() 'D v : (>t 'l) v (N'I: I'(N'I: r'(r'D) v))'266 rNI)Id
TOAId AS A\OU ACUU(I J (N 't:I '(N 'I : f '(f 'L v)) 'too cvau
ZN.II:)09OC N*Z: ZN
asl/(.o^TliJ'#'#i1i I +N: NN
.,' I-N: IN
zs '96 'zs (t't) v) gt €:N
(N 't : >I '(zN 'I : f '(f ')) v)) 'Eoo JNIUd I9 (E) rocr'(9'€) v NoISNaI IIcI
r - (ro:r)'Iof,r CIOHIAW SSNVC NOISX.AANI XIUIVW J
ToJI : (t) rocr €'t hrvucor{d J
(r) tocr : r
dnar:(rocr't)v os flSurprocce e8esseru qcns slurrd rolnduoc erll pu"
(roct 'f) v : (t 't) v relnSurs flqeqord sI xrrlelu eq.L 'pllnoJ oq louu"c
osJenur 'orez puno; sr lueulola 1o,rrd erJl 'es€c uI '0I
(t't) v : dhtar
'pe8ueqcxe uarll eJe V Jo 9 01 sutullloc ut pautulgo
t
N'I:f0soc zn xrrler.u osJOAUr stll Jo sA\oJ eqJ 'TOJ1 ferre eql
I HJIAI, 'IOJI NNIN'IO3 SDNVH)XA 3 lrr paproceJ sl 'I '9'9 'lJV ul pauteldxa sB i' Jolce^
zt'ts 'ts (t rocD gl w go lueure8urrr€ 'e'r y ur seEutqcxe urunloJJo {JUJI '6
-
(N 'I : ) '(zN 'I : f '(f ')) v)) 'eoe rNldd 'l'9'9 'lrv uI ss
dI IEIT : (r'tnour) v ot orues aql sr uorl?urturlo roJ slntuJoJ ro ruqlrroSle aql '8
0 'nouD v : (t'r) v 'uorlsurrurle eJoJeq
(t't) v : dhtal
lueruelo lolrd eql fq paprltp e-IE sluotuole A\oU 'l
ZN.I:fO'O(I I€ 'uotleutIutle
I HIIA\ AIOdI \OU IICNVHf,XA 3 aroJeq '!l-y" uorlrsod 1o,trd eql ur lueuele 1se3
rE 'w 'tr (t-ttout) st -8rq eql 8ur.rq o1 pe8ueqcxe o.r€ suunloo puu sA\oU '9
IINNIINOJ O€ '1uerue1e lorrrd
) : .IOJI Jo Jeqr.unu uunloc Jo Jaqunu AroJ 3ql osls pu?
f : A\ouI uorlerado srql Jo Jaqunu leuas eql selouep I xapul
.salurl 's
sv:crs z z: I-N - IN ouop sruorluredouortsurrurlg
oE'ot'z (av ctg) ut 'YJo90t
-
((x'r) v) gssv : sv t surunlof, ur paleraue8 uoql sr xrJl€ru ,{1l1uepr eI{I 't
N'I:)0toc 'F'Jo sutunlot eaJql lsJU eql ur seceld redord peuErsse
N'l:f0goc puB peeJ lsJg oJ8 xrr]€ru uerrrS eql Jo sluetuelg '€
0 -- cI8 'xuleru,{11uapr gx6 Sururofpe eq1
I _--'IOJr pu€ xrrl"ru € x E u3^r3 arll qloq alBpolllIuoccB ol
(g'g) V ,{e-rru leuorsuaurrp oAU eql sesn urerEo;d eql 'Z
I : /KOUI
INiIhIg'IA JOAId (INIC 'xrrleru erenbs ua,rr3 eql Jo ezrs €rll JoJ spuels€: N 'I
3
I+I:IT wp.rSotd aqt tnoqD srulod auos
t6 XIUIV'II ASUAANI
92 MATRIX OPERATIONS ON THE COMPUTER

70 CONTINUE 3. Element ,4r, is alreadythe biggest. It being in the


PRINT 994, (JCOL (I), r : 1, N) pivot position, interchanges of rows and columns
IF A (N,N) 7t,96,7t are not necessary. Operate so that A22:1, Ap:
Atz - 0, and get
7T DO 8OJ : NN, N2
itoznr iix"-2i: ,0-r/tl
3/rll Yr: 7)
80 A (N, J) : A (N, JyA (N, N) i0 l 3/ll lix.==3 i0 4trr -Utti y": l0l
PRINT 993, ((A (K, J), J : l, N2), K : l, N) fo o tzTrtJfx, =rl lr Yt: tSJ
DO90L:1, Nl
-3't,r -2tnj
4. Finally operate so that A", : 1, A* : Azz :0and
I:N-L get
u:I+1 il 0ioi
0l lx,--3, ri-2 5r I Yr: 7)
DO90K:II,N lo rj 'rxi--)l +l-l -lt-ii iv":tol
DO90J:NN,N2 [o o lx,:rj "l n -3 -z) I rr: rsJ
90 A (r, J) - A (I, J) -.- A (I, K)*A (K, J) 5. Exchange row I with row 3 of matrix B to make
: : vector X correspond to vector )z and get
PRINT 993, ((A (K, J), J 1, N2), K l,.N)
DO 1l0I : l, N B: A_I
DOIlOJ:I,N l.x, 1l r [1] -3 -2)
IF (JCOL (J) -- I) I10, 91, 110 ix"-zi -*-1-i-3 7 -rl
91 DO 100 K : NN, N2 lx,::j " l- 2 s)
-r
Exchange Method
TEMP:A(I,K)
A(I,K): A(J,K) It willbe observed from the above procedure that it is
possible to save memory of the computer by retaining
100 A (J, K) : TEMP
only the essential columns of matrices A and B. The
JCOL (J) : JCOL (I) eliminated column in I contains only I in the diagonal
1IO CONTINUE position and zeros in others serving no useful purpose
PRINT 992, ((A (I, J), J : NN, N2), I: 1, N) in further work. At the same time one additional
STOP column of B, that contained only zeros and one uptill
96 PRINT 97 now, gets transforrned, along with others, and becomes
(10X, IsHMATRIX SINGULAR) useful in further work. These two columns, one of ,{
97 FORMAT
and one of B, can therefore be exchanged. In other
991 FORMAT (9Fs.1)
words, the eliminated column of ;4 can straight away be
992 FORMAT (3F12.4) replaced by the corresponding column of B. We
993 FORMAT (6Ft2.4) may thus do away with ,B altogether. This involves
994 FORMAT (3Ir0) exchange of columns of I first, then superimposition of
END
B on A. The resulting ,4 is A-t in a modified form.
Both row and column exchanges are then necessary
to bring it into a proper form. To understand this,
7.4 Gauss Jordan Method
we again rewrite the steps.
This method makes use of the identity matrix as in the Steps
Gauss method, but aims at transforming the given
matrix ,4 directly into an identity matrix omitting l. At the end of elimination of column I of A, the
matrices appear as
the intermediate triangular form altogether. Taking
the previous example, the steps appear as under. AXB Y
114 114) l&:31 f0 0 tl4) lY,:7)
{r trl+
Steps
io zl+l ix,:2i : r -rl4i lr,:roi
I and 2 are same as those in the previous example.
fo
+7: i't4) [x,:r j lo
lr o -r7+j Lyl:iil
At this stage the matrices appear as
First column of I is now of no use. Only tbe third
AXBY column of .B is transformed to contain useful ele-
rl4 l/41 l'x3:31 f0 0 l/4') ( Y'- 7) ments. Exchange column 3 with colurnn I of 8.
iA rrl4 3l4lix,:zi: lo | -tl4l ir,:roi This needs rearrangement of vector Y. Matrices ,{
lo 314 714) |x|:t ) ll o -rl4) L
y3: l5J and X need no change. We get
: 'r{ Pue X
(I) rnOUr r
0€
sJolool go slueurs8ueJJe 'o'I'suurnloc se Ilell s€ st\oJ
dl rar : (r'ru.onD v
(r'anouDv: fu'I)v 3o se8ueqclalur Jo pJooeJ deol o1 I€Iluesse sl 1I
'slueruola eletrdordde .,(q 'euo ,(q euo
(t'l)v:dIlgr
'pecelder oq plno,{\ sutunloc slr'uotleututqe Sutrnq
IZ
.I: f OE OCI
N '.{1uo u ezrs
Jo eq ,{eru qclqa'U o1 peurolpe oq lou
I HIIA A\OUI A\OU IICNVHJXA peou 1r ',{iesseceuut-t sr gr xrJ}€tu poqleu slrl} LII snql
tz 'rE 'te ft-a,ouD gr 'rrorle ururrlo 3o sdels ollsseccrts oq] uI utunloc dq urun 1
gNNIINO:) OZ -oc X uo pesodruued'.rs uooq e^€q plnoc g l€q] flitu
X : TOJI -olec eloN 'rY - 8r ,&ou 1€ql alels 01 sselpe3u sl ll
f : 1!\oul z--'tu
Olg BV - 'tz:uxl
Ir:lxl -- :! 14' :f l-
oz'oz'z (av - cls) cI It:'xj 2' itr: ,l: (-
t- i'-iT . I
((x'r) v) cssv : flY [E:'xl I
t :'.t 't(' t
I tr >
N'r:)0zoc \z:"xi : lor:z
I
gt:t,t
Ir-- L r-l+ I
N'r:f0zoo Ir:'x, frr r- .-)
1e3 a16 'g Jo t urutlloJ
0:cla qtll'r I Lrnrllloc e8ueqcxe uoql puu g ,ttor qll,tr I A\or
I :'IOJI e8uuqcxe rap,ro yern8rro .IIot{} olul ,1 pull X Suuq o1 'g
I - /$.OUI
INAI^IS-IA IOAId CNII J tL ]rl l'tt t-.1,, ,t't-x 'l9gl
I+I:II j
lgl=;l t :- f- l-j?- ii=:i7" i3 ; ?i
NI
.I : I 09 OCI
It -!,ti 't IIt- II.-l
r: (r) Tof,r oI l0l:"ll 0 lll IIrl-l:
t : (r),^[ouf lgr=',t-' Lo II'l- ll€ )
N.I:IOIOCI Ir !x, itt'it o ol
:7-'X II/t I 0l
(N'I : I '(N 'I : f '(f 't) v)) '26 rNldd [e-'x \tt,a o IJ
(N'I : I '(N 'I : f '(f 'I) v)) 't6 clvau su -ieedde sdels e,trssacJlls trr secul€Iu
€:N oql 'pa3ueqouu ur€ura.r ,1 plrt? X s-Iolcel 'snrunloc
(e) mour '(g) tolr '(E'E) v NoISNgNrc Jo s.ro.r jo se8ueqc,relur JoqlJl.U otr o.ru eJe ql sV 'Z
CIOHIAI^{ J 'onc)p a.ru suorleredo Surloa.rd o[I ueq,{r os?c
ACNVHJXA NOISUAANI XIUIVhI J or{:i sr sE palcaf}u uoaq 0A3rJ plno^\ €r Jo ulunioc }sig
t', t^lvxcoxd J eql ,(yrro 'y rrr e3ue rlJ.rolrrr A\oJ Jo ecrrJsqu aLIl LrI 'I
ur idel sr p-roJal u pr.rr; rrrEqc eqlsaleldruor BrJo E pu"
'A\OlIf I strrurlloc 3o e8lreqcxe rrrolq 7 icogl] lou prp srql
ferre dn 3ur1oo1 ,{q se8ueqcxo uurnloc pue '1631 1ug 'g Jo I rrlunlo3 Jo peslsur 'E r.irunloc polco.ue
,(eue dn 3ur1oo1 ,{q euop e.ru se8ueqcxa ,tro.r 'uorl v Jo I rirullloc Lri Llorll?r-uLurio ocuoH 'g ur se8ueqc
-surr.urle Jo puo eql ]v ',(11errrur u ' ' ''z 'l .rep.ro eril -.ralr-u o.{\} lroleJrssecou 7 ur a8rreqc.re}irr ,{\oJ eql'sdels
ur er? qcrq,\r Jo sluoutele '-1OJf puu l[OHf s.{e;;e or[] oJ€.rlc.r oi 'log 'l .rolJol ,{;Jporu y ur sa8ueqo
ur 1de1 sr sa8iieqcrelur ulunloc puu 1(o,r Jo p.roJOU '[ -Jotril orJt ^,(11un1cy 'l lrr ]coua-r g ur seSueqc
^\o.r ',f
.r_I/ roJ uurnloc A\oN roloe^ 3o luaureSueJJ€oJ oql ur lcogoJ
p' ur so8uuqc ulullloc aqt leql uees ,(pte.r1u oleg el6
spuels l1 'puo aqt tV 'xrrlelr ua,rr8 eqi sr y ,{11er1nr1 '1 'puo crl.t ln ]l op e.ra. ',{1re1c ao sasodrnd ro3
'rlJo ezrs JoJ splrsis E - N 'l
r1g 'tr Jo urullllo3 is.rg uo pasodwrradns eq plnoc
uro.tSo.td aql lnoqD slutod awog grJo ururlloc ls.rll /(oN 'r(g Jo rtror SurpuodseJJoc oql
'(99) arypsa14 'GB) ptaLtcs '(Og) lttA pun Jo teql slenbe;y Jo ,{\o-r ,(ue
3o onlc,\ oq} tu q1 ,{3rren
uotslDv '(77) sad14 '(71 uopnalog puD lrtut,toJrltl puoy
'E' L'lJv 'poqlaru snolrrerd oql rrr se alrres eJB sry€ruog I t :',1, lr o r/r-l lt:lxl lvlt vlt ol
I or:',r l0 I vit- : tz:"xt tvlE vllt ol
polltaw aql u0 lst :',r ro o t/t i iE:Yi b/t nfi IJ
€,6 XIUIYru ASUIIANI
94 MATRIX OPERATIONS ON THE COMPUTER

JROW 0) : rROW TEMP: A (K, J)


JROW ([ROW) : J A(K,J): A(K,t)
PRINT 93, (JROW (K), K: I, N) A (K,l) : TEMP
31 IF (ICOL 41, 4t, 32 10 CONTINUE
c -t)
EXCHANGE COLUMN ICOL WITH I JROW (J) : JROW (t)
32 DO40J =: l. N JROW (r) : r
TEMP:A(J,r) 80 CONTiNUE
A (J, r) .= A (J, tCOi_) PRTNT 92, ((A (K,L), L: i, N), K : l, N)
40 A(J,ICOL) - TEI\{P C INTERCHANGE ROWS
J : JCOL (t; DO 100 I : l, N
JCOL (l) == ICOL DO100J:t,N
JCOL (rCOL) : J (JCoL (J)
4l PRINT 92,((A (K,L), L: I, NJ, K:l,N)
1F
- t) 100,81.100
8l DO90K:t,N
PRINT 93, (jCOL (K), K : l, N) TEMP:A(J,K)
c CHECK IF DIAGONAL ELEMENT IS ZERO A(J,K):A(t,K)
IF (A (r, r\) 42. e4.42 90 A (r, K) : TEMP
42 RATIO : l.iA(r, I) JCOL (J) -= JCOL (l)
A (r, r) : RATIO JCOL (r) : r
C DIVIDE ROW BY PIVOT IOO CONTINUE
DO45K:1,N PRTNT 92, ((A(K,L), L: l, N), K: l, N)
Itr(K- t) 43" 4s. 43 9t FORMAT (9F5 .2)
43 A (r, K) : A (r, K)*RA.TrO e2 FORMAT (3F12.4)
45 CONTINUE 93 FORMAT (3110)
DO50J: I.N STOP
IF (J t) 46, s0, 16 94 PRINT 95
DO49K:-
46 I.N 95 FORMAT (10X, I2HN,IETHOD FAILS)
IF (r!
- I) 47, 49, 4l END
47 TERM : A (J, I)1'A (t, K)
A (J,K) : A (J, K) rERM 7.5 Crout Method
-
DrF: 10000.'! ABSF(A (J,K))_ABSF (TERM) Irr the methods of decomposition, viz. Crout, Doolittle
rF (DrF) 48, 48, 49 and Cholesky square root, for solving simultarreous
48 A(J,K): o eqrrations siven in Chapter 6, the given coefficient
49 CONTINUE matlix I rvas expressed as a product of a lower trian_
50 CONTINUE gular matrix multiplied, on the right side, by an upper
triangular rnatrix as a preliminary step. The triangular
DO55J:I,N matfices were subsequently used to solve the system
IF (J _-_ I) 53, 55, 53 of equations. Irr findir-rg the inverse, too, the given
53 A(J,I): ...-A(J, r),',RATIO rnatrix ,4 is decomposed as above. Let
55 CONTINUE
A: LU
PRINT 92, ((A (K,L), L: I, N), K : l, N
60 CONTINUE where,4 is the given matrix, L, alower triangular matrix,
C INTERCHANGE COLUMNS
ard U, an all being of the
Llpper trian_eular matrix,
same size t.Then by definition of an inverse matrix,
DO80I:1,N A A-r : d where 1 is an identity matrix of the same
DO80J:I,N size as A or A-1. Similarly
IF (JROW (J) I) 80, 61, 80 (LU) (U-lL'):L (Utt-r1tr-t: LIL-r:LL-r: I
61 DO70K:1.N -
Hence
'I : r'X roJ Bc.,(
tlll :8erJf66tr By _ :
1trnocce 01 suorl?cgrpour 1q8r1s ql;.rrl. 77- t eldutexg gzll : zeT
ur stueual?1s Eumn poruJoJ st .4X lcnpo.rd flleurg .9 "rTl(",tr -il/. ttz * 1 : rt,
'97'g eldruexg Jo Lll_:zzTfttrrz7_:r6tr
sluoruolels Sursn punoS uaoq uaq] s€rl 'Z 3o esrelul .,1 .g
gzlt: et,t 'Llz : zz^ ,zlr : rt,tr
'I : !!X t€ql lcEJ oql Jo otou olBt ol ecueH
paJ31l3 ,(1tq8gs ueeq e^€q 91'g eldruuxa .Jo strrour
r-r ot !- - 4
I-t ol :
I .r (t>\ trtT )=!ry :
-al€ls eql 'lsJg palenle^o sr ll ocueH ..{1tun o1
u otZ :
-
pnbe slueuele leuo8erp slr IIe seq '72 3o esre,tu t ,X .V I roJ ttTl (!r\'IZ7- ) : {t,f.
'euo? x E B Jo eceld ur xul?ru € x € € roJ pog uotl:I JoJ llTll:!!I
-lpour ,(1np '8'9 'lJV ruo4 uelel ere t pu€ Z sJoiceJ : e:e ,{eq1 '97'g eldruuxg ur ue,tr8 suorsserdxo
olul y Sursodruocop roJ str.rolrretets .E Xq
NIV1I5OC paulelqo sr d'tq : { eroq,{\'I : IZ lel,r\oN
')ro.r ',? uo rrallrr,rrelo eq uvc X luqy fFulncrped e1o;1
rolnduoc ro3 pe"unbar lou erp A 'X 'n 'Z socril€W .Z
'pella^Irr eqolY xrJl€ruJo ezrs er{l JoJ spuels g: N .I [r o ol
lLtz- I :rC:X
ruo"tSold aryl noqD slurotl awog i.rir zn- 0lri
'ereq pJliluo cle'Xcelnccu Jo
Eurunsue ro3 ,{,ressecou q8noq} 'suorle;edo 8ur1o,tlg'g LIZ_ _ tznzzx _ :gzx
'peJols aq pceu ,(po a ezrs Jo V xr.rtary ',{1e1erud LiI - ,rn "rX - trn rIX - : ,tX
-3s peJols oq loli peeu ,teqr ocueH zll-:ztntrx-:zrx
",{leatlcedsar
.v
n pue Z uo uelltJ^{Je^o oJB ,1 puc ; ,(1:eprur5 |:tLX-zzx :rtx
uo uellrJ,rJeno ore n pue 7 'elnpecord eql Suung .7
ecueH
'8'9 'uV 'suot1 t-!o].! -4
-enbe 8ur,r1os Jo poqlou lnoJJ Jepun sl.rurue.l oos.I kotl+l:/
potttaw
uo aryt I-t1 otl:l ({tp ttSl=-):{!X
L I llotI:.r JoJ I-!!X
It
8 v- w:
i:
I n- SI I : eru ,{eq1 '91 'g oldu:ex:I Jo espc lercads ur pauoilueru
suorssardxa ,{qualS sr;6 'leuo8erp erJl ur s.I sBq n sV
sT.n I
lszlt rr/l-
'|{iiliJ rool .I : NX I{I
LtT.- r 0l rv
i""'f LIT T.II-- IJ it o ol Lls. r 0l ,r r ol
r. X I L,IZ I ol 'o zlL r, irc tl
io zlt rl ,o o z' .o I T,l
rcE ax' '77'2
alduexg ur peureldxe se suorlecridrlnru eql 1no 3ur,{ue3 n 7Y
{>t JI u ot !:tt '8 9 'irv 'poqleru lnolJ ur socrrleru eql JeprsuoJ
{<t Jt u ot l:I .,(1e1e.redes
uraql
uolI:!' qll,n 'arojaraqi lal6 'spoqlew uorlrsodruocep agl
Js-1p
a ol I : t roj t,/a lly {!S
Jo qJEa ut ieglpZ pue,( iuql alor4 polou aq ,(eu 11
=:
91'g elduexg uorj ro 7,y : €r ueql .r-y- { F1 'r-p, slenba srql 'ZZ'E
'ruu,rSord u Surpoc e1n1,v' , psea Jo alec rrolpl aldurexE ur p:ureldxa sp r-Z ,-i2 lcnpord ar{l ruJog .t
cq uec tcEJ srql pup 's.I fyuo e.re Jolul oql tnq : X 'g7 g alduexA ur paureldxa se r_Z pulC .t
JO Sluatuole leuoSelp eql erfl uo deFe^o I Jo slueuislo '91'g eldurexg ur paureldre se rA pVJ,.Z
puo8urp eqt ler{l putu ur 1de1 eq ol ro^o^.oq seq
1I '7 tro uel.lrri Ja^o eq uer l€q] osle areq eloN n 7 tcnpord e su y sserdxg .1
: atv ,-l' Surpug ro3 sdels ar{l snql ',{1e,rr1ced
€r,'I-^ gzit -sar tI'€ pue g1'g saldruexg ur peureldxa se peurur
iiszlt
o Llz Llt- -r 7 : ,
-Jolap oq ,{1rses uec r-7 pue r-n saculuru esJalur osaql
i o 0 zlt
JO t4 rD : '-(n7): rY
s6 XIXIVI{ INUIIANI
96 MATRIX OPERATIONS ON THE COMPUTER

C PROGRAM 7.5 70 A (r, J) :


suM
C MATRIX INVERSTON BY CROUT C FIND Y INVERSE OF L EXAMPLE 3.20
C METHOD C A (T, I) : I.iU (I, I)
DIMENSION A(3, 3)
DOg0I:l,N
N:3 80 A (r, r) : 1./A(r, r)
NI : N- I
DO 100I : 2, N
READ 9t, ((A (r,J), J: l, N), I: I, N) IN:I-1
91 FORMAT (9F5.1)
DOIOOJ:1,IN
PRINT 92,((A(t,J),J:1,N), I: l, N) SUM: I
FORTUAT (3FI0.4)
DO90K:J,IN
C FIND FACTORS L AND U 90 suM : suM
- A (I, K)* A (K, J)
C CALCULATE ELEMENTS IN FIRST ROW 100 A(t,J): SUM*ArI,D
RATIO : 1./A(r. l) c FORM XY EXAMPLE 3.22 X (I, I) :
DOlOJ:2,N C X UPPER TRIANGULAR Y LOWER
1

10 A(r. J) : A(1, J)*RATTO


DO 120I : t, N
DO 5OJ:2, N
JI : J - i
DO120J:l,N
SUN,{ : O
JJ:Jt-l rF (t-J) l0l. 102, 102
C CALCULATE ELEMENTS IN COLUMNS lOI L:J
C 2ND ONWARDS
GO TO 103
DO20I:J,N 102 L:I
DO20K:l,Jl 103 DOIIOK:L,N
A (I, J) : A (r, J) A (r, K)*A (K, J)
- IF(I-K) 106. 107, 106
c CALCULATE ELEMENTS IN ROWS 2ND
C ONWARDS
106 AIK_A(I,K)
GO TO 108
RATIO: t./A(J,J)
DO40I:JJ,N 107 AIK: I.
DO30K:1,Jl 108 SUM:SUM+ATK*A(K,J)
110 CONTINUE
30 A(J, I) : A (J, I) _ A(J, K)* A(K, I)
A (I, J) : SUM
40 A (J,I) : A (J, I) * RATIO
120 CONTINUE
50 CONTINUE
C FIND X INVERSE OF U EXAMPLE 3.16
PRINT 92, ((A (I, J), J : l, N), I : l, N)
C x(r,r):1 END
DO 70I : l, Nl
II:l+1 7.6 Doolittle Method
DOTOJ:II,N Following the general procedure explairred in the pre_
SUM: O vious Article 7.5, the steps for finding A-r in the Doo-
little method may be written as :
JI : J- I
DO60K:I,JI l. ExpressA as a product L(J, as done in Art. 6.9,
IF (tK) 52, 54, 52 Doolittle method for solving simultaneous equations.
-
AIK:A(I,K)
52 2. Find I-1 as explained in Example 3.20.
GO TO 56 3. Find U-r as explained in Example 3.16.
54 AIK: i. 4. Form the product U-t L-r as explained in
56 suM : suM - A(I, K) * A (K, J) 3.22. This gives l-t.
Art
60 CONTINUE Consider the matrices in Art. 6.9 referred to above.
(Jtstlgzt-sv't t
N'I:f09oct 1at em 'suorlecr1dr11nw pel€crpur eql lno tur,fu.ru3
ft'l) v rNal^ralg grvrncrvc !>!JI!tot[:4
I-I:I^II {<tltuot! I
uoll -- [
N'Z:I090(I u ot
I -: ., roJ !>ry ztX Z: ltg
N OI Z SA\,OU NI SINIII^ISTII AIVTNCTVJ c '77'g eldwexg uou.ro ',{.X : r7 r[) : ry : A pl
cgcNVHJNn I Id.OU dga) c uerSord e Eurpoc epqrrr ,{1rsee 3o
N (INV'I SUOJJVC CINId J eJpc uc{B} oq uec tc€J srql pue 's.I lsnl ere rel}Bl eql trnq
(r'otsE) rvwt{oc : ,t Jo sluerualo leuoEerp eql uo depe,r.o X Jo sluour
(N'I : I'(N'I : r'(f 'D v))'26 JNrud -e1e leuo8erp oqt l"rll putru ur 1de1 eq ol Ja^o./doq s?g
(t'sso) rvwuod t6 1I 'r? uO uellrJ,^dJa^o 0q u€c x wLll osls ereq eloN
(N 'I : I '(N'I:f '(f 'l) v))'16 ovau gZlL 0 0
I_N:IN ttll- Llz o -: r17 -- X
9T,I
I LII_ ZII
t:N
(g'E)v NoISNgI^rIcI ro
CIOHITIhI 'J Elll - == t'nl'aDzzy- : tzy
STITITOOCI AS NOISdSANI XIUJYI^I 3 gzll .= "'nl('"n"tx €rn rrx-) :'rx
- rrx-
9'' htvuDoud J Lll- :"" nl"n - zrx
gzlL - *rx
'Llz - "x'zlt : "x
'l- !!,tr t€ql tcsJ aqt Jo lunocce el?l
ol suorl€curpour 1q8r1s \1ltt' 'ZZ'g eldruuxg uorg scueH
sluawel?ls Eursn peurroJ s1 ,{X lcnpord ,{11eurg'9 t--[oj! - 4 r
u ot I * t : [ \ 1t,t,1 tty3){tX :
'91'g elduexg ruo{ slretu
'g
-e1e1s Eulsn punoJ ueoq uoql ssq ',2 3o esra,url 'X
t-u ot t - I roJ t, t!21@2 t!X=) -- : ttx
'loll=-r roJ llnll:!!X
'l : !!I l€rll to€J oql Jo etou
: are ,{eq1 '91'g elduexg Jo es€c lercads ur suors
oIBt 01 poretl" ,{pq8gls ueeq e^€q '97'g eldruexg 3o
-serdxe fq ue,tr8 sr. X 'r/7 : X 'e'l'I : I) X lel
slueluel"ls aql 'lsJg pol€nl?^e sr ll ocuoH o1 ^\oN
"rltun 'Z uo uollu,&Ja^o eq Lr€c { }eql ,{1re1ncr1red e1o;1
lenba slueurola leuo8erp slr Il€ s€q'7 3o esre.tul',L n
'euo t X € eceld ur xulsru t x € B f t Llz- Llt
JoJ pegrpotuf,lnp '6'9"3o
'lrv ruo{ ue>l?} ere n pua 7 !0 t zlt- :r7--tr
i0 0 I
sJolcBJ olury Sulsodruocep JoJ sluetuol?ls NVUJXOd t
ro
'{JO,4d,
LlT, 0) zztrztT :
relndtuoc rog pe;lnber lou eJ" ,tr 'X 'n '7 secr.r1e141 '3 - : (tl)- - "'.tr
'paue^ur aq ol v xrJl?ru Jo azrs eql JoJ spuels t : N 'I Lll : ,"^zt7 _rlf, r8-I : IE1(
utotSotd aW lnoqD syulod atuog
zll _ : tL/' tz,7 -_ : rzr{.
'S'/ pue 6'9 '8'9 'lJV Jepun slreruar oes I .- 8rl :7.7tr:lt/I
asuoH
poqtal,l[ a4t uo
l-!ot[:)t
'spoqtrou 3l]1rloo(I puB I-l 01 I : .r
lnoJJ ur ragrp rJ pue r-11 aog .{J-relnorlred alop uolz-I roJ ttq ttqT- : tt,t
'poqloru lnoJ] ur sB uoll:l .loJ |: !!.tr
L' I
: ere feqa 'OZ'e
z-8 t- eJ_ eldruexg Jo os€c lerceds ur pouorluour suorssardxe .{g
lr- SI t ue,rr8 st;
'1euo8erp oql ur s.I seq Z sV 'r7 : I 1€-l
fr Llz- Llt I lszlt o ol Itlsz o ol ir Llz ol n t 0l
t0 t T,lt- l l€t/r- Llz 0l-r-H l I zlL 0r l0 7,lt I I
t v rl
lo 0 r j 'rgzlt Llt- zlt ) l.o t z) ioo IJ 0rz)
t{, X n7
L6 xiuJvN asuaANI
98 MATRD( op[RATIoNS oN THE coMPUTER

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

DO40J:II,N 4. Let S: (>Vj Aji)+ Ai; for i: l: firstcyc{e


suvi : 0 .i:lton
JN:J-1 :1xl+4x3+l:14
DO 35 K:I,JN 5. Obtain new matrix C, using the relation
35 SUM : SUM-A(I, K) *A(K,J) Ci* : Ci* - U1 VtclS where 7 : I to n, k : I to n
A (I, J) : SUM*A (J, J) C.o: Cs-U1 VrlS:l-l x lll4 : l3ll4
40 CONTINUE Cp: Cn- UtVzlS : 0 - | x 4ll4 : - 4ll4
PRINT 92, ((A (I, J), J : l, N), I : l, N) Crr - Crr- Uznls.-- 0- 3 x I lI4: -3114
DO50I:l,N Cr, == Crr- U2I,'zlS : I 3 x 4ll4 : 2ll4
DO50J:I,N -
, I 13
SUM-O or C:+lt+l r
-41
rl
,

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

7. E Matrix Inversion by Rank Annihilation Second cycle


The method is illustrated by a simple example.
7. Using the formuale given above obtain new values
Ex,lMprn of U, V, S, C. They are :
Obtain the inverse of the square matrix A of size
n: 2 below by rank annihilation.
rt t l--4] , 8l
v*'t4 !* [ 32]

(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

r tl Thus it is not as effrcient as the Gauss orJordanmethod.


i.". u: f
""'''-l.o rj itl
L:J 2. For symmetric matrices U : V. The amount of
Yr -- AnCr, + ArrC* : 7 x 1 + 4x 0 : I arithmetic is reduced by half.
Yz : ArrCp * A12Cr, : I x 0 + 4x I : 4 3. Read Pipes (77), Ralston and Wilf (80), I4testlake (86).
Some points about the program
i.e. v: Il 4l
'l0ljfl :l l. The size of the square matrix r4 is 3 x 3.
I
pV:8t4rY: 0: (x'f)v zv
8 r(Yg) : gt-(v - D : s("'+ .u + y + 1) 09 'zt 'zt (dlc) dI
osueH (wusr) dssv r
"""rzu*y+1 -- (x'r) v) gssvx'ooool : drc
'-(u-/):
'I: ("'+ Bu + v + 1) (u -z) WUgr - (x 'r) v : (x 'f) v
(r 'D v/(x 'I) v*(r 'f) v : Ilrugr
sV .lueEraauoc sl ... + z)I * y * 1
serJes xrJl?ur oql l?ql eruncsv 'eldurrs sr goord eq1 N'II:)0SO(I
g Jo y s? ezrs eru?s eql Jo xrJl?ru dlpuepl : N 'II : f.0S O(I
I I+I:II I'
Yg_I: U
r-f etr?urxo:dde : g t9't9'tvN-Dst
hrns/$) Ax(r) n-()'f)J:(x'r)c 09
eJeu^\
N'I:)0goc
g("'+eu*au+u+ I):ry N'I : I09 0(t
uorlsloJ eql uo pas"q sr poqisur eql (r'Dv+Wns:IIns
'esJe^ur el€J (t't)v*(r)n+ wns: IIns on
-ncce eJoru e Eururelqo Jo poqpru olrl€rolr u" sr eJeH N'I:f0toc
'f,le suorl?lncl€c lucrlewqlrre fueur 'sf,orre go-puno,r : 0 IAInS
'relndwoc eqtr uo fce;ncce Jo ssol se qcns 'sesnec (r'>r)c*$'Dv + (r)A: ft)A os
le]eles o] snp psJrsop s€ elsrncc€ s? oq lolr feur srq; (l'>)v*$'r)c + ft)ln: fu)n
'slsrxe lr yr 'xrrluru ualrS e Jo esJoAUr aq1 Sururelqo tog
spoqletu lueJo.gry aql ureydxs solcrll" SuloSe.rog eq1 N'I:)I0€O(I
osJeAnI ue ;o ,(cernccy Jo luaue,rordrul 61 '1,
o: (r)l
'e.req pelroldxe fylng oq louu€c sseuesreds s1r
0:0)n
ecueq pue osreds 'lereue8 ul '1ou sr xrJl€ru esreds e go
N'I : f 0€ oo
asJeAuI eql lBql pelou eq Je^e^\oq plnoqs lI 'uellrr^\ oq
N.I:I08O(I
,tlrsee ,{rel uec ,(erre leuorsuourp-euo s€ peJols xrJ:}€tu
'r - ft'Dv: G'Dv oz
cr:1eurur.(s e Surlrelur rog urerSo.rd eql 'elduuxe rog N'I:I0ZOO
'our1 relnduroc pu" luerue.rrnbe.r e8e;o1s Surzrurrunu ro IINNIINOJ OI
socrJl?ur lerceds Jo esuc ul 9 raldeq3 ur sure;8o-rd Jo saurl I : ft.DJ L
agl uo pegryour eq .{eu reldeg3 srqt ur sure.r8o.rd eql
OI OI OD
srcglutr tr 1u;cailg 6'; o: ft'l)c g
g'L'g 0 - l)gl
(INg N.I:IOIO(t
(t'orso) Jvhrdod z6 (N 'I : f '(f'D v) 'z,6 rNlud
SNNIINO) 08 N.I:I OI O(I
(N 'I : r'0) ,,t)'z6
rNlud (o'sgo) Jrrr ruod 16
(N 'I : r '(r) n) '26 JNIUd (N 'I : I '(N 'I :f 'ft'D v)) '16 ovgu
(N't:)t g-N
'(x'.t) v) '(N 'I : )'() 'f) J)'ze rNlltd OL
(g 'e) c '(g) l '(e) n '(€'€) v NolsNiu^uc
N.I:{OTOCI I9 NOIIV'IIHINNV 3
o : ()'il) v 99 )NVT{ AS NOISUAANI XIUIVhI 3
I'I:)gSOA 8't I IVdDOI{d c
o:G'r)v 9S
'qelrduc fq sra11e1 asec Jenol eql ,esrnoc go
N.I:)S9OCI 'Eulcelde.r 'NV)IIUOg ul perdoc ollrp ora eelnruJoJ
I.I:fSgOCI egl pu" eldurexe ogl ur s1oqur,ft Jeglo U" leaoqe
itnNIINOC 09 S: elouep 01 WnS elqErJBA eql sesn ueJEord e\L.C,
IOI XIU.I,YI^I ASUIIANI
102 MATRIX oPBnATIoNS THE COMPUTER

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)

accurate. For further study read Scheid (83).


N:3
READ 9I, ((A (I,J), J: I, N), I:1, N),
Exar'nre 1 ((B (I, J), J:1, N), I: l, N)
Obtain a more accttrate inverse, given PRINT 92, ((A (t, J), J : l, N), I : 1, N)
. lz 4l '1-':B: - 2-4s 2.051 PRINT 92, ((B (I, J), J : 1, N), I : I' N)
o:t; 5j I t.or -oesj
t
CALL MATMUL (B, A, BA, N, N' N)
PRINT 92, ((BA (I, J), J:1, N), I: l, N)
Steps
l0I: I,N
DO
2.osl 12 4l : [r.2s 0.451
r' B A: (-2.4s
I t.ot - o.e5j l: sj i.o.os r.o5j
DOlOJ:I,N
IF(I-Jr6,7,6
2. R :I_BA 6 R(I,J): BA(I,J)
[1 0l fr 2s 0.451 :_ l- 0.2s -- 0.45] GO TO l0
- [o rJ - l.o.os 1.05j L- o.os - 0.0sj 7 R(I,J)-1.-BA(I,J)
3' R'B-
r- 0.04 - o.ot5l 10 CONTINUE
L o.os -o.ossj CALL MATMUL (R, B, RB, N, N, N)
CALL MATMUL (R, RB, RRB, N' N, N)
4. RrB: R(RB): i- 0'0125 o4:e5l
o.ooos 9o.oo7ooj DO20I:I,N
l.-
5. More accurate values of the inverse arc DO20J:1,N
(-2.49 20 C (I, J) : B(I, J) + RB(I,J) + RRB(I'J)
PRINT 92, ((R (I, J), J : l, N), I : l, N)
1.965]
B+RB: i i.to -l.oosi PRINT 92, (RB (I, J), J : l, N),I - l, N)
10119 2'0l0e5l
: f- 2l.4eeso PRrNT 92, ((RRB (I, J), J : 1, N), I : I' N)
+ R,B + a
.B Rs
t -o.eesooj PRINT 92, ((c (I, J), J - l, N), I : l, N)
Compare thesc with the exact inverse el FORMAT (3F10.0)
,_1
la-: {- 2.5 2l s2 FORMAT (3Fls.8)
I t.t -lJ END
Some points about lhe Program SUBROUTINE MATMUL (A, B, C, M, L, N)
1. N - 3 denotes the sizes of the matrices A and B C MATRIX MULTIPLICATION
C ASIZE M BY L, B SIZE L BY N
2. The FORTRAN array B A stands for the matrix CSIZEMBYN
product B A, R for R : I - B/, RBB for R28' C
DIMENSION A (3, 3), B (3, 3), C (3' 3)
3. Multiplication of matirices is required several times' DOlOI:I,M
Hence a SUBROUTINE MATMUL is used' DO10J:1,N
4. It is unnecessary to use the identity matrix' The c (I, J) -o
subtraction I - B -,4 affects only the diagonal ele- DOlOK:I,L
ments, which are simply subtracted from 1' 10 c (I, J) : c (I, J) + A (I, K)*B (K' J)
RETURN
5. In case, still rnore accurate results are wanted' END
form Ra B and add to the result' This will nced
'0I'z 'uy uI peuqlno '((, 'z) J '(z'z) g'(z'z) v NOISNSIAIIC
poqleu aql Eulsn dcemcce s1r elo:drm ol elg"JeJ
-o.rd sy 11 'sesec qcns uI .elermxordde eq ol ,ieryi NOISUITANI XIUIVW XA'IdIAIOJ J
8r paurqqo osJelut eql .saJrrletu e8.reJ JoC .posn rI', hrvucor{d c
eq feu poqleu elil11ooq Jo ,ese1oq3 secrrl?ur
clrlarurufs lereueE .rog
.secrJl?u crrlauurds ellugep
errppod JoJ posn $ pogleu d4se1oq3 .scrlsuslcBr€qc xrrr?ru toJ v'L eirrlrv Jo poqreu .rr"u"*ruLli:tH ,
lelceds ou Eurauq esJeaur xrJlsru e Eurpugt JoJ porllarrJ
u"pJof smBD egl moABJ sJeryo t gcJueseJ p.reueE u1 '(t 'D C 1aB o1 (1,D V o1
llnseJ er{l ppe pue ur.ta1 .,(q urrc1 ,g1g ,e.l ,gry{
.Surpualsrepun Jleql
lcnpord pug '€ relduq3 Jo gZ. g eldurexg Bul,nollog .y
JoJ lerluesse sr euo sFIl s" IIo t se 9 reldeq3 go {pn1s
V 'esJeAur uu Eurpug JoJ ro suorlenbe Eulalos rog 'tY:J
uounuoc oJ"'clo'uep:o1 .ssnug e{rl ureqlJo euros l€q} snqJ 'Jlesll J ur 1r srols pue J Jo esre^ur pug
e oqe spoqleu eql go {pn1s B ruo{ pe^resqo eq III/,I lI 'IUAANI iINIJnOUSng,(es'ure:Sordqns e Eursn'g
uoJsnlruoJ zI'1, 'v : J xrJlstu e_lenbs .(.rurlxne uE eLe:H.Z
'z - N Jzrs Jo secrJletu etenbs eg, cI ,c ,g ,y !e-I.I
cNlt : oru sdels eq1 ,1 esec rog .perede.rd
(l'orgz) rvr/{uoc r,6 aq ,{psue lrt.ou uEO
sosac o^rl eseql Jo euo ,{ue rog urer8o"rd
(o'ssr) rvwuoc t6 NVUJUOg V
(N 'I : I '(N 'I : ,t'ft'D cD)'z6 rNl'l{d * y r{ y) - : cI
'-(g
wugr-:0'Do 09 se,rr8 uorlec
-gqdurs pue (d uorlenbe rrr anl?^ stgt Jo uorlnlrlsqns
ft'D c*(t )) g*() 'I) r + nual : Iltugr o,
N'I:a0toc eyr{-:J
1eB pue,{grldurrs ,rB fg (g) uorlenbe,{1d4p4
N'I:>I0too
O : IAII{AI slsrxer_€r:zes?c
N.I:fOgOCT
N.I:I09OCT '-({'-Ys+Y):c
leE a,t
(N'I : I'(N'I : f '(f 'D c)) 'z6 rNlud 8ur,(grlduns pu€ (Z) uorlenbe ul anle^ srql Burtnlrlsqng
0'Dv+wugr:ft'l)c og ){try-:A
0't) g I 3A?q
*(1.x)r*(x'Ds + wugr: Iluilr oz e,tr 3ur,(3qdrurs pLre ry fq (g) uorlenbe aur,(ldpFhl
N'I : 'I0Z OCI sisrxa esuJ
N.I:>IOZOCT r_u: I
(e) 0:cg+QY
0 : I/{UflI
k) I:Og_JY
N.I:fO€OCI
EA?TI
N'I:I0gOC a.tr 's1:ed ,(ruur8zul pue leoJ eql Eulleredas pue (1)
(N'r) ruitaNl l'IvO '
(t'Dv:0'Dl uorlenbe 8ur,{3r1drurg 'xrJleru flrluepl oql sr 1 eJaq^t
oI
N'I : .t 0I OCI (r) r:(ar+))@t+v)
N.I:IOIO(t a^sg
(N'I : I'(N 'I : f '(f 'I) {)) '26 rNlud e.u 'xrrleru esJelur ue Jo uolltugep aql .{g 'asJolur sll
(N'I : I'(N'I : f '(f 'I) v))'z6 rNlud 'G ! + J puu xrrlzurxaldruocue, rB eql eq g I + y lq
(N'I : I'(N'I : f 'ft'D g))'te (tviru '/rtoI3q
(N't : I'(N'I : f '(f 'D v)) '16 (Ivau palrrap aelnuJoJ .etal B pu" secrJlulu per Eurlreaur .rog
spoglotu eq1 Sulsn ,(q peyelur oq u"c seJrJleru xelduo3
Z:N
Q'z) J,'(z'z) o, I seclrfctrAtr xaliluo3 Jo uo!$e utr II'Z
g0r XIU,IYN gSUIIANI
CHeprnn 8

Eigenvalue Problems

8.1 Nature of Problems characteristic determinant of the system. We havc


already seen that such a system has a non-zero solu
Eigenvalue problems occur in many scientific and tion only if the determinant of the coeffi.cient matrix ir
engineering phenomena. Let us consider one coll- zero.
crete case.
Hence, to obtain the solution, we Put
The 2nd moment or the moment of inertia of an
I 4-A -2.lt:
(
elementalareadAabout anaxisis given byJ r2dA, where 0
r is the shortest distance of the area from the axis i-2 4-^)
It is obvious that the moment of inertia of a given. Expansion ol the determinant gives,
plane figure will vary according to the direction of the
axis chosen. The maximum and minimum values of or,
(4-)) (4
- )) - (- 2) (-2) - t)

the moment of inertia are called the principal moments )2-81 + 12 :0


of inertia and directions of axes corresponding to them
are called the principal directions. Let
This equation in l is called the characteristic equation.
The polynomial in tr is called the characteristic poly-
H'- 5 y'dA : moment of inertia of a given nomial of the matrix I{. The values of .l are obViously
figure about the x-axis: 4 the roots of this equation. They are therefore variously
: called as, characteristic roots, latent roots, eigenvalues,
Hy - JxzdA rnoment of inertia of the figure
proper values of the matrix .1L As each eigenvector is
about the y-axis : 4
associated with a particular eigenvalue, the eigenvectors
Hxy -- Hy, : J x Y dA Product of inertia : 2 are also referred to as characteristic vectors, latent
Then the principal moments of inertia and the direc- vectors or proper vectors.
tions of the principal axes are obtained by solving The charactistic equation can be factorized as
the system of equations.
HX-AX (l- 6) (^-2) : 0
where Hence )r - 6 and ), : 2 ate the roots of the equation,
or the required or the principal

":: [ _T., -r;):


eigenvalues moments
_?l
-l of inertia.
l_: 4)
The associated directions of the principal axes are
) eigenvalues of the matrix equation : principal obtained by substituting the values of ) in the matrix
moments of inertia equation (l). Substitution of lr : 6 gives,
X: eigenvector giving the clirections of the principal 14_6 _2] [ &. :
In expa nded
axes
form, the equation rnay be written as of,
i-, o--ut i i,)
o

(-) --tl r v'l


l4 lx'l :) i^'i :
l_r -2)
o
l-x'l i-2 Xr)
4) t,xrl ttXri -2) 'r
Ithas clearly the solution Xr: i.e., the vect0r
or as, t' ll is a solution. This principal-Xz
-2 I i",l :o I - jI axis associated with
[4-r (r) l-r
t
-z4-A) 1.x,, X, is inclined at an angle of -45' to the co-ordinate
This is a of homogeneous equations. The
system axis x. Note that the coefficient matrix has rank l.
determinant of the coefrcient matrix is called the Hence the system of two equations represents, not two
x14?ur
serq'rJe^ Jo vy xrJl*ru ,{;er'xne ," "'r".rt'"f, .t € X € eql 3o lerurou,{1od crlslralcu:uqc eq} ourr.uJoleq
Jeqlre solouep sruJel € Jo UI felre "u,
leuorsrrourp euo A'IdI^tVXg
'r{;oruaru 'aldruexe lecrJorunu e .(q peuruldxe lsoq sr poqleu srql
relndruoc 3o Surrres oql ur sllnser srql /r\oq eloN
',v Jo ev to zy to ry elouep ol pesn sr lr tue.rSord lugruou,{1o4 ol}sfrel
.Z
curuq3 u Supureua.g Jo poqlal l^aeppuf,-ratrJe^eT .Z'g
aql Eurrnq '€ ozrs
Jo xuteur X.rurlrxne up st VV
'xull?ur ua,,rr8 eql 3o lerurouflod crlsrralce.reqc
erenbs eqr Jo ezrs oqr :o3 dlueurru ,punrX eqt SurlereuaS .ro3 poqlaur luercrJe ,{.ral e ,to1eq olr8
ltTil t
.{\ou e,r 'elr1eura11e u€ sV 'esn ralnduoc JoJ truerc
tuotSold aqt itnqo synod awog -ge ,,{re,a, tou sr poqlou slql }eq} uaes ,{pee:1e p€q el11
'(79) oraappog pu.at 'xul?trl eql Jo slrreruole oql Jo uorlucrldrllnru lcarrp ,(q
poqleu eql Jo uorssnostp pue lunoccu poo8 e JoC'Z pel€nJe^o s€,r Jrr€ulurtolop oql 'eldurexe oloqz aql ul
+
'suorlecrldriynur (Z u * zuZ- #Z) 0
- u) i 'suorlunba snoauaE
lnoqe so^lo^ul poqlau oql'l -ouoq Jo las stqt Jo r.rorlnlos eq1 ruo.rJ srolca,tuaEle
poqtaw aql uo peturcosse ogl ur€lqo pu€ O - X OU-V) uoll
.xr.rleur -enbe eqt ur euo fq euo senlerrue8ra oseql etn]rtsqns't
letro?erp e sr. ty truql eloN
'xrJl€rrr erl] Jo ozrs orll Jo uorlenba eq] Jo ea.r8ap
'u Jo sonlB^ or{i ol Jequlnu lri lenbe f,"ql 'ssnle,ruo8ra eql
-uetre aql enr8 uotlunbo crqnc srrll Jo sloo-t eorq] oql a,u8 .{eq1 'uorlenba srq} Jo slool eqt eulr.uJalec['€
0==g + Y0I + aY 8- sY 'y ur uollenba leuluou,{1od eq} ure}qo pue oloz ol
sB uellJlt oq snql uec rrorlurrbe crlsrJolceteqc aql .g
QU- f) xuluru luorcsaoo or{} Jo }ueutluratop aqt los 'Z
g + YOI*aY 8-eY ro tZ- V"J- ? - ey 'xrrlaru ,(1r1ucpr ue sr 1
eraq.t 'g : X Oy- v) 'a'l
"y
,{q uerrr8 uoql st leru:oudlod ctlstJelcgleqc eq;-.L 'XY-X y uollenbe ue urJoJ'y fes 'xrr1€t-u ua,nr3 e JoC 'I
(€-r-r-)
€- : €.6 (E/r) : : oJ€ xrJletu ua,lr8 e Jo sJoloeA
(V Jo acerl) (g/1) - urulqo ,(11eurg .9 -ueEre pue senlurr.ueSre Jo uorlurrrruJotop aql ur sdals eq;
'Q7) to11o2 pup uDcun( 'uzDtg puer fpnls regpnJ JoC
|.e-o o l ir'-o r tv z t),
l0 €-o l- lo r e- lz r z\:'v 'sluelsuoc er[os eJe
"l p:oe rrJ ereqal
lO 0 t-i tt 9-8 rl Z I)
se ,Y Y : ey elepcpc pue zy.;o sllrourolo leuo8e rp eql
uo4 0l - : zJ Eurlcerlqns tq ,V xrrleu ulelqo .S
ir "'t
LI [;-]'
se uellrJ^\ aq osJB .,(eur uorlnlos aq1 'sruJal lu?lsuoc
0r- : fit-t-z-) (zl0 : (,v so ecerl) (zl0 : "t ,(q srolcal e^oqe oql 3o seldrllnru ,(q pagsrles osle
zy
lol pu€ jo .t
ecv4 eql et€FlcluJ
e;u suorlenbe egl snqJ 'snoeuaSouroq pue luapuadap
,(yreeuq sr suorlenbe Jo les eq] esnecaq 6peurelqo lou
|tt-o r I lv--z tl lvzl,
L- e-l:lz ete zy pue I; Jo senle^ enblun leqt polou eq ,(uru 11
lo e-z-) s- z I lz t zl--zv 'srxg -r'ol elEue ue t? peurlcur sr
Lt lr z L-i i.rzLi f r'l "gt+Jo
se ,y y : zy eleprcleJ'y Ja stueuole yeuoEerp
':olce,rueEre aqr ecuag '!; :tx sr uorlnlos aql
.E
eql tuor3 8 : rJ Eurlcutlqns fq ,V xrrt€r.u ulelqo I ;l (z .--\
'g:tl-s+l*rJ IL L I
t.)rl
acueH 'slueruele puoEelp eql Jo runs eql s? pougep 0- lxj t__i
tc-()
sr ec?Jl oqJ
'xrrlsru srql Jo r; eczrl aql alelncleJ .Z 'lo
lvzt)t zl: rv fx) fz-v z-)
lz I'xj fr- T,-r)
[tzr)
y : ry xrJletu B a{sl .I sairrE uorl
sdaTg -enba xuluur eql ul 'Z - "y Jo uorlnlrlsqns ,(peyrurg
rl 'sql qlrl\ luoprcuroo sr 'eJdqpu e Sureq 'rolcal
lv zE zl
lz -*v puoces eql 'uorlnlos Jolco^ luepuedopur fgeeuq
ftzr) suo ,{1uo seq uralsfs aqt ieuo fpo tnq seurl }gAIBJ}s
s0I sn&nsoud gn'Iv^Ne9re
106 MArRrx opERATroNs ON THE COMPUTER

4. One dimensional array TEMP of size 3 is used to DO 50I: I, N


store temporarily the elements in a column of the
auxiliary matrix AA. This faciliatates the formation
AA(I,J):0
of the products, row ol A into column ol AA an<l DO50K:I,N
storing the result again in the column of AA. New 50 AA (I, J) : AA (I, J) + A (I, K)*TEMP (K)
matrix AA is formed column by column. To store PRINT 92, ((AA G, J), J : 1, N), r - l, N)
the cumulative products of matrix multiplication 60 CONTINUE
elements in column of AA are immediately set to DO70I:1,N
zero after they are transferred to location TEMP
i.e. after their values are assigned and stored in'
70 TR (N) : TR (N) + AA (r, r)
array TEMP.
rR (N) : rR (N)/FN
PRINT 92, (TR (K), K: l, N)
5. It is necessary to form A' only twice, i.e. N-l times.
.,4' is generated in the loop DO 60 L : 1, Nl . . . . 9t FORMAT (9Fs.0)
60 CONTINUE. 92 FORMAT (4F10.2)
6. The elements of TR are printed without changing END
their sign as required in the formation of the poly-
nomial. 8.3 Largest Eigenvalue of a Symmetric Matrix by
Iteration
7. Using symbols of the above numerical problem,
we get the following algorithms for further use in The largest eigenvalue and the associated eigenvector
the program. for symmetric matrices can very conveniently be deter-
Tr : (ftace of matrix A, ) Ir mined by the method of iteratior-r. We solve one
A, : A(Ar-l - Tr-t I) example below to illustrate it.
where r : I to 3, and I is the unit matrix. ExlruprE
Determine the largest eigenvalue and the correspon-
C PROGRAM 8.2 ding eigenvector for the symmetric matrix
C CHARACTERISTIC POLYNOMTAL OF
C MATRIX A: tt
I 2)
I

DIMENSION A (3, 3), AA (3, 3), TR (3), 12 4)


Steps
I TEMP (3)
N:3 1. Take the sum of elements in each row. It is 3 for
FN: N row I and 6 for row 2. As the sum of elemerts in
READ 91, (A (I, J), J : t, N), I : I, N) row 2 is greater, we choose the initial eigenvector as
i0l
DOIOI:I,N tl_
^-
|
lrlI

rR(I): o IrJ
DO lOJ: I, N 2. Write the equatiort A X : .B and calculate B as

10 AA (I, J) : A (I, J) il 2.r iOl l2.l


NI:N-I l.z 4j irI i.+j
DO60L:1,Nl We find B, : 2, B, : 4. .8, is larger; we divide
DO20I:1,N ,B by this larger value and get
20 TR (L) : TR (L) + AA (I, I)
FL: L 4 f05l
il l
rR (L) : rR (LyFL
i. :llr
Here 4 denotes the larger eigenvalue a better
DO30I:I,N "rO [o
30 AA (r, r) : AA (I, r)
- TR (L) approximation to the eigenvector X. We improve on
DO50J:1,N them in the next cycle.
DO40I:1,N
40 TEMP(r) : AA(r, J) 3 l: i) ['i] - [3'] : [']
'poq lcru s.rqocuf Sutsn
I- A\OUI
fv r0l (r)s:orq rr
v tl :Y 0z 'rr 'n ((t) s - (clo dI
ll tz) 0:(I)x
xtJletu
crJlelurufs oql JoJ slolcenuo8ro pu€ sonlpaua8re uru1q6 N't:I0uoc
srdyrYXE
0:clg
((r'D v) cssy + (r) s : (D s or
'olduexa Surrnol;oj aql ut pelullsnllr sp soor.uuul uorluloJ N't:fOIoo
'pa11ec ar? 1Br{^\ 'Eursn .(g orez ol pacnpoJ or? stuau., 0:(l){
-ele leuoSutp-go aqt 'e1c,{c trorleralr qcee uJ 'uorl
-?Jolr Jo poqloru eql ,{q puno1 eru e pLtE U secutl?l N'I : l0I OC
.V
(N't : I'(N'I: t'(t't) r'))'z rNlud
JO (N'r : t'(N'r f '(r'r) qvgu
sJolooluo8re eql luese.rdal U xlrleur Jo surullloc otlJ 't
- v))'r
'y J0 sauls,rueSre €:N
eqt luesa.rde.r O xrileuJ eql Jo slrroruala leuo8urp oql 't
s
(s) '(e) x '(r 't) v NoISNah{Io
NOIIYUAII AS XIUIVhI C
rU : r-U lut[] oloN 'xl-lJ€ul luuo8erp e lluJ-Anhl,i.S V .:lO A0IVANADI:I JSACUY'I J
'( : y n ,-y tutli rlcns lr xuluur 1crro8oq1:o leet u
pug ol eyqrssod sl tl 'y xr.rlELU culauu.{s l€er ?.lol 'Z €'8INVUCOdd 3
'senlu,r.ue8ra 1ee"r ,{1uo surl xulBLLr cr.rlauu,{s luoJ V'l 'uorl€Jolt
'xrJl€r-lJ cr.rlaurtu,{s u 1o qcea Sur.rnp (mOUt) X ot ainl?^ 1un Jo lueurrErssu
sarl,redo.rd luulrodu-lr 3urmol1o; orit uo pasBq st lI .,(1uo oqt p!o^B ot paurporu {psue eq truc ruelSord eql .}
socrrl?u clrleurur,(s lgar ol clqecrldde sr porllaur stql 'xtJleru eql Jo ozts eql qlr^\ fuen 11rnr
enlu^ s1l
'suorlBrolr Jo Joqullu orll JoJ spu?ls JN .e
poqtetrAl srrqoruf t'g 'paddols st llo^\ uorlurolr,l.g u"rfl
(lNA aJou lou sr a8uurlc eqt .y lporudnroo or? sanlul
a^rssec)ns sll 'efrle^ue8rc 1sa3.re1 JoJ spupis NiIDIg .z
(l'orsr) ryNuog c 'Jolcal luelsuoc e se esodrnd er.ues ar.{l solJos
'.rolcaa.ua8ra eql;'xul?Lucr;laurur.isE X
(o sce)rYNuoJ I S E€slf .I
dOIS Ig wotSotd aLlt fioqo s|u1od awog
AONIINOS 09 ('pg) uotuotg oslu p?ad .uorl?relr eql
.Z
N:ICIE INIdd Surrnp 'a,ro; fq aro,r 'palzraua8 eq uuc sllrelcgooo
sv: Ngcla tv esoq^{ sasrrl?u culauu,(s e8_le1 loJ luolJscxo
It'IS 't9 (SA)Ct sr poqlaru aq1 'rue:3ord NV1IUOJ tuerolgo
uz sur?lrroc ll '(Zt) tropD^lps puD lrtwtoDcry
r'o-(Bv-Nacrs) cssv : sg peau 'sosuc I{€ ur )i.ro/n
lou feul poqtau eql .Z
(tmoul) s) ssav
: sv .trorle:alt rad
(N 't : I '(t) x) '(N 't : t '.(r) g) 'z JNIud
(./Y\oxt)a/(r)s - (r)x
suorlrppu zu
suorsr^rp u
N'l:I0toa strorlucrldrlprur zu
(r)x *(t'r) v + (t) s : (r)s so^lo^rrr poqleu oql .I
N.I: f OEOCi
poqpw ew uo
o:(r)B 'srxg
N't:I0to(tr
,I :
OI JNI OS OCI -x eql ot {S O/l) ruot Joeclols u sur.i qcnt& r,
O : NADIA [, ;]
:olca,ruaSre polsrJossv or{1 pue g sr onluluesre ra8ru1
I : (1Koui) x eqr sllql ',(lessaeauun e.r? suorJerelr JequnJ pu"
ANNIINOJ 0f rolcanua?ra oql ur eSueqc ou sr aJeql l?ql pug eA\
LOT sna'rsoud golvANecrir
108 MATRIX OPBRATIONS ON THE COMPUTER

Steps 4. To obtain the eigenvector, we have simply to takc


the product of all the rotation matrices R used.
First cycle
At the end of the first cycle, the product is
In this cycle, we have to annihilate the off-diagona I | 0.92 0.38 0l 10.99 0 - 0.151
elements Ap, An and Aru one after the other using i-0.:s o.sz olrj xlo o r o lx
rotation matrices. Let R denote the rotation matrix, t o o l-o.rs o.eej
i, the row and j, the column numbers of the elements 0 0 Ir 0.91 0.2t -0.351
of ,4 or R. The matrix R for annihilating Ait is given fl 0.77 : j-0.:z 0.75
0.64-0.64i
10
by l.o 0.17) | o.rs 0.63-o.s4l
0.761
Rii : t, Rik : -- sin t,
cos Rki : sin t, Rkk : cos t, At the end of the 4th cycle, the product of all the
AiF rotation matrices used, i.e. 12 in number, works out
r:0. 5 t dn-rAii-Akk
,2
to

other elements of R being identical with those ol an


0.89 0.23 - 0.401
identity matrix, of the same size as .4. --0.43 0.74 -0.s2
o. 17 0.63 .76) O

1. Considertheannihilationof,4rr. Here i : l, k : 2. The three columns represent the eigenvectors of the


t : 0.5 t an-r ,-l] givins R as given matrix l.
2-4 On the Method
t 0.92 0.38 0l
R- i-0.:a 0.92 0l l. The method involves about
I o o ri l0 n?
20 nz
multiplications
additions
t0.92 - 0.38 0l
R-r : 0. 38 0.92 0l b: easily modified for a Hermitian
I
lo o rJ
2. The method can
matrix. Read Scfterd (83).
[ 1.58 0
New value of A : R-t I R- i 0 4.41-0.381
0.92 3. The method being iterative, is well suited for com-
l.*-0.:a o.s2 4.0 )
puter work.

Note that Azr: An: 0 4. For matlrematical discussion read Ral.vton and lAilf
(80).
2. Annihilate next -4rr. Here i - l, k - 3.

t:0.5 tan-r 2X(- o'38) Sonte points about the program


1.58 4
- 1. N: 3 derrotes the size of the given matrix A.
l'0.99 0 ( 0.99 0 0.15
o In-': i tt ooee]
R: io oI -0.15.] Io 2. Matrix ol array B (3, 3) stores temporarity the product

lo.rs oeej [.-ots i


AR.
1.53 0.14 0 3. W (3,3) is first an identity matrix. It is then used
New value of A R-l ,4 R : ,lo.l+ 4.41 0.91 I to obtain succsssive products of rotation matrices
l.o o el 4.06)
i

R generated in the DO loop, DO 90 I : l, Nl.


3. Annihilate next Ar, on the above lines. We get, For this purpose, the products are stored temporarily
in matrix or array V. After the products are ob-
(t 0 0 I I l.s3O.ll tained, V goes to W.
o
R-loo.77-0.64i a-l o.lls.l7 -0.091 I

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.

32. Margulis, 8.E.,


Systems of Linear Equations,Pet- 47. Buckingham, R. A., Numerical Methods, Sir Isaac
gamon Press, Oxford 1964. Pitnran & Sons, London, 1962.
33. Mathews, G. (ed.), Contemporary School Mathe- 48. Carnahan. B. L. H.A. and Wilkes, J.O., Applied
matics Mutrices I and 2, Houghton Mifftin Co., Numericals Methods, John Wiley & Sons, New
Boston, 1965. York, 1969.
34. Munkres, J. R., Elententary Linear Algebra, Addison- 49. Conte, 5.D., Elententary Numerical Analysis-An
Wesley Pr-rblishing Co., Reading, Massachusetts, Algorithmic Approach, McGraw-Hill Book Co',
1964. Inc.,1957.
35. Ostrowski, A. M., Solution of Equations and Systems 50. Dorn, W. S. and Greenberg, H. J., Mathematics and
of Equations, Academic Press [nc., New York, Computing with Forlran Programming, John Wiley &
1960. Sotts, Inc', New York, 1967.
51. Dwyer, P.5., Linear Computations, John Wiley &
36. Perlis, S,, Theory of Mcitrices, Addison-Wesley
Sons, Inc., New York, 1951.
Publishing Co., Reading, Massachusetts, 1952.
52. Faddeeva, V. N., Computational Methods of Linear
37. Stiefel, E. L., Henrici, P., and Rutishauser, H.r
Algebra, Dover Publications, Inc., New York,
Further Contibutions to the Solution of Simul'
1 959.
taneous Linear Equations and the Determinstiort
of Eigenvalues, National Bureau of Standards 53. Forsythe, G.E. and Moler, C.8., Contputer Solu-
Applied Mathematics Series No. 49, U. S. Govern- tions of Linear Algebraic Systems, Prentice-H all,
ment Printing Office, Washington, D. C., 1958. Inc., Englewood Cliffs. 1967.
38. Taussky, O. and Paige, L. J. (eds.), Simultaneous 54. Forsythe, G. E. and Wasow, W.R., Finite Diference
Linear Equations and the Determination of Eigen- Methods for Partial Diferential Equations, John
values, National Bureau of Standards Applied Wiley & Sons, Inc., New York, 1960.
Mathematics Series No. 29, U. S. Government 55. Fox, L., An Introductionto Numerical Linear Algebra,
Printing Office, Washington, D.C., 1953. Oxford University Press, New York, 1965.
39. Taussky, O. (ed.), Contribtttion to tlrc Solution of 56. Fox, L. and Mayers, D.F., Contputing Methods for
Systems of Linear Equations and the Determina- Scientisls and Engineers, Oxford University Press,
tion of Eigenvalues, National Bureau of Standard New York. 1968.
Applied Mathematics Series No. 39, U, S. Governs
57. Hamming, R.W., Introdttction lo Applied Nunterical
ment Printing Office, Washington, D. C., 1954.
Analysis, McGraw-Hill Book, lnc., New York,
40. Y ar ga, R. 5., M alr ix lte rqt i e A nnly sis, Prentice-Hall,
v

Englewood Cliffs, New Jersey, 1962.


l91l.
58. Harris, L.D., Nunterical Methods Using Fortran,
41. Wade, T.L., The Algebraof Vectors and Matrices,
Charles E. Merrill, Columbus, Ohio, 1964.
Addison-WesleyPublishing Co., Reading, Massa-
chusetts, 1951. 59. Hartree, D. R., Numericctl Analysis, The Clarendon
Press, Oxford, 1952.
42. Wilkinson, J. H., The Algebraic Eigenrelue Problem,
Clarendon Press, Oxford, 1965. 60. Herrrici, P., Elements of Nunterical Analysis, John
Wiley & Sons, Itrc., New York 1964.
Numerical Methods (and Computer Programming) 61. t{erriot, J.G., Methods of Mathentatical Analysis
Compulotion, John Wiley & Sons, Inc', New York,
43. Acton, F. S., Nunterical Methods That Ll/ork,
1963.
Harper & Row, New York. 1970.
44. Beckett, R. and Hurt, J., Numerical Calculations and 62. Hollingdale, S.H., High Speed Contpttting Methods and
Algorithms, McGraw-Hill Book Co, Inc., 1967. Applications, The Macmillan Co., New York, 1959.

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
!

116 MATRIX OPERATIONS ON THE COMPUTER

Ex. 3.17 For lower triangular matrices A, B, C of Cii:ZAtBtcj fall i, j, k:l to n


size z satisfyingC : AB t : in-(n-k)-i(i-I)12 lkTzi
Cii :lA* B*i I,i:lton : kn-(n-i)-k(k-r)12 Ii>k
i.i: ltoi Cii: 2Bitc At
l'.
k:.7 to i t == k n-(n-j)-k (k-t)12 u>k
Ex. 3. 18 For lower triangular matrices A, B, C of size n : j n- (n-k)-j (j - Dlz Ik>i
satisfying C : AB Ex. 3.25 For A, B, C, D of size n satisfying A : BCD
Aii: Ciilhr li:Iton Aii =2Bitt Ctt D6 lall i,.j, k, I
Aii : (Cii-ZAir, Br,ilBii ( i: nto2 I : ltoz
\i-,-rto Ex. 3.26 For real parts [A], [3], [C], and imaginary
'tk-i+ltol parts (A), (B), (C) of complex matrices A, B, C of
Ex.3.19 For lower triangular matrices A, B, C of sizie sizes n satisfying C:AB
nsatisfyingC:AB lclir, :2 { 1Al7l4tk - (A)it (B)u,l I att:1j.,k I
Bi;: Ci;lAii li: lton ,i,,0 : tlt,r i (A'Yt t;-
to n
|
Bii * (Cii->AikB*ilAii li - 2ton = 1tol,, i
ly t to;-t : DETERMINANT
lk-= j to i-l Art.4.6 Determinant of a square nratrix A of size n
Ex.3.20 Forlower triangular matrices L and Y of by Pivotal Condensation
size n, satisfying YL : LY : I Ait : A1* A1i Ait<lAii [i:1 to n-l
-
Y;t: llLii li: lton li:t+tton
Yij: -(2LikYrc)lLii li:2ton
l.tr:r*tlon
: - Yii(ZLik Ykj) i7 == I to i-l determinant : (- l)P> A6 i : 7 to n,p: number
it:itoi-l of row or column exchanges.
If L is unil lower triangular RANK OF A MATRIX
Yit : l, Yij : -'(ZLit Yti) [i, 7, /r as above Art.5.2 Rank of matrix of size mx n
Ai11 : Ait li : lto m-l
Bx. 3.21 For matrices ,4 lower triangular, ,B upper - Aii Ait<lAii l.i:i-vtto-
triangular, C square of size n satisfying C : AB
lk: i + lton
Cii:ZAitBtcj fi
- llon rank:r-1if Aii-0
).1 : llon
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
{

n8 MATRIX OPERATIONS ON THE COMPUTER

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

ii. Y: Ait : lj-i+.1ton


- Aii AitlAii
is given by
yii: I,-1
Ait,
I [f: lton [t:t*Itoz
Yii:-(5'LirrYrt) (i:2ton Ait:
l,r: ttoi-l O
li: ttoi
lk: i to i-l [r: tton
iii. X: U-lis given by Air -- 0
li:i+r
Xii:llU ii [r : I ton
Xij: -(ZXikUt)lUii f : lton-l In the nth cycle. CA-r : l.t:ttoi
-- Xii (ZXit U*i) j:i+'lton
- k: i to i-l Art, 7 .10 Improvemerrt ol Accuracy of an Inverse
B : approximate A-r
iv.B: A-r:XY A-r: (1+ R +R2 +..).Bwhere R: I-BA
Bii - ZXitt Ytj f i -lto n Art. 7 .11 Complex Matrix
l.i :tto,' IfC+iD:(A+iB)-,
llr:itonrfi)i i. D:- A_I B C :
'Lk:7to nif i<i
i. C: -(A B_LA +Bf
t- BA-rB)-1:
-(A -B-rAD
B replaced by ,{ in program. EIGENVALUE PROBLEMS
Art.7 .7 Cholesky Method for Symmetric Matrix Alt. 8.2 Characteristic Polynomical by Leverrier-
i. A : Tt T,find Zas in Art. 6.10.1 Faddeev Method
ii. R : Z-1is given by Ar : A (A,'-:- -- 7,.- t I) [r: ltoz
Rii: llTii [i: lton ?i. - (trace of malrix A1.)lr
Ry : li: lton-l
-(E R* Tr1)lTi1 i7:i+1ton
Art. 8.3 Largest Eigenvalue of a Symmeatric matrix by
: Iteration
- Rii(ZRitTtci) lk: ito 7-l
iii. B : A-r : R Rt is given by i. If surn of elements of ith row is maximum,
B,i : ZRttc Rite Xi-|, all other elements of X : 0.
fi.: lton
t.l : t to n ii.FormAX:B
Bii : Bii (not for.rnd) ik:jton Xi:BilBi [i:ltoa
A[ f, R, B overwritten on ,4. All symbols I, iii. Repeat srep (ii) until Bi approaches a limit,
R,,B replacedby A in program. giving the largest eigenvalue.
Art.7 .8 Rank Annihilation Art. 8.4 Jacobi's Method
Matrices ,4, C square, U, V one dimensional of size n. A, B, R, V, W arc square matrices of size n. Annihilate
Let C : I anidentity matrix. offdiagonal Ak one by one, using
i.NewA:4-C I : 0.5 tan-r (2 Ai*) l(Aii-At<*)
:
ii. Repeat cycles, i : I to n Rii cos t,
Ritc : sin t, Rki : sirt t, Rkk : ocJ t, other
Ui:\Cik Akt, Vi : ZAit Cr1 p: tto,, -
elements of R equal to those of 1.
lrk
= ito,, New ,,4 : R-r A R, R-t: Rt as R is orthogonal.
Form S : (ZVi Aii)+ Aii [.i : lton Elements Ait finally give the eigenvalues.
Qre:Circ-UiVilS li : tton Matrix of eigenvector is given by product of
llir: ttoz all the rotation matrices R used in annihilation.

)
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

Matrlx Algebra is a topic of fundamental importance to stud'ents


of physics, engineering and the management sciences. .Techniques
lor the manipulation of matrices, and procedures for computing
determinants, inverting matrices, solving simultaneous linear equa-
tions, and determining the digenvalues and eigenvectors of given
matrices, form an essential part of the prolessional repertoire ol
students in these areas of sp6cialization. This book contains a
wealth of inlormation about these topics in a readily accessible form.
By developing actual computational procedures in the form of
FORTRAN programs, the author has really accomplished two tasks
at tlie same time. This book. provides training in computer program-
ming as much as in matrix calculations. Since all the programs ltt-
corporated in this book have actually been teoted on a computer, tho
student is assured ol the correctness of their mathematical, as well as
programming, aspects. This is a valuable book and could be used
as a lext or as a reference guide.

Rs. 13.50

OXFORD & IBH PUBLISHING CO.


NEW DETHI BOMEAY CALCUTTA

You might also like