Lecture - Solutos of System of Ler Equtos Numerc Ler Alger Revew of vectorsd mtrces System of Ler Equtos Guss Elmto (drect solver) LU Decomposto Guss-Sedel method (tertve solver)
VECTORS,,, colum vector row vector Emples: umers rry of oe dmesol : Vector e e e e vectors Idetty
MATRICES Trdgol, dgol detty mtr zero mtr Emples: umers rry of two dmesol Mtr :
MATRICES upper trgulr, symmetrc Emples:
Determt of MATRICES Defed for squre mtrces oly Emples: - det - - ( ) ( ) ( ) 8 -
Addg d Multplyg Mtrces The ddto of two mtrces A d B * Defed oly f they hve the sme sze * C A B c j j j, j Multplcto of two mtrces A( m) d B(pq) * The product C AB s defed oly f m p * C A B c j m k k kj, j
7 Systems of Ler Equtos Mtr form Stdrd form 7. 7. dfferet forms ler equtos c e preseted A system of
8 Solutos of Ler Equtos ; s soluto to the followg equtos : A set of equtos s cosstetf there ests o soluto to the system of equtos: These equtos re cosstet ;
9 Solutos of Ler Equtos Some systems of equtos my hve fte umer of solutos soluto for ll s ).( solutos hve fte umer of Both re sme equtos!!! lerly depedet equto I mtr form: ; A A Sgulr mtr
Grphcl Soluto of Systems of Ler Equtos Soluto =, =
Crmer s Rule s Not Prctcl Crmer' s Rule c e used to solve the system, Crmer' s To solve N y N system requres (N )(N -)N! multplctos. To solve y system,.8 It c e used f Rule s ot prctcl for lrge systems. multplctos re eeded. the determts re computed effcet wy
Nve Guss Elmto The method cossts of two steps: Forwrd Elmto: the system s reduced to upper trgulr form. A sequece of elemetry opertoss used. Bckwrd Susttuto: Solve the system strtg from the lst vrle. ' ' ' ' '
Elemetry Row Opertos Addg multple of oe row to other Multply y row y o-zero costt Bsclly To elmte ukow EX:...(); Add - () to () yelds...()
Emple Forwrd Elmto 8 7 8,, from equtos Elmte Step: Forwrd Elmto : Prt 9 8 9 8 Row Row Row Row (/) Row Row (-) Row Row Row Row (-/)
Emple Forwrd Elmto 9 fromequto Elmte Step: 9, from equtos Elmte Step : Row Row
Emple Forwrd Elmto 9 9 8 9 8 Elmto : the Forwrd Summry of
7 Emple Bckwrd Susttuto () ) ( (), () ) ( 9,,...solve for for solve the, for Solve 9
8 Forwrd Elmto j j j j j j j j ) ( To elmte ) ( To elmte
9 Forwrd Elmto s elmted. Cotue utl ) ( To elmte k kk k kj kk k j j k k j k
Bckwrd Susttuto j j j,,,,,,,,
Emple 7 7 8 7 ) ( 8, from equtos Elmte Elmto Step: Forwrd : Prt Guss Elmto : Nve usg Solve eq eq eq eq eq eq equto pvot uchged eq
Emple 8 7 7 ) ( 8 from equto Elmte Step : Forwrd Elmto : Prt eq eq eq equto pvot uchged eq uchged eq
Emple Bckwrd Susttuto The soluto s 8,,,,,,,
Determt The elemetry opertos do ot ffect the determt Emple: Elemetry opertos A A' det( A) det( A' )
How My Solutos Does System of Equtos A=Hve? Uque det( A) reduced mtr hs o zero rows No soluto det( A) reduced mtr hs oe or more zero rows correspodg B elemets Ifte det( A) reduced mtr hs oe or more zero rows correspodg B elemets
Emples.!. # : solutos fte # of No soluto Uque X mpossle X solutos Ifte No soluto soluto X X X X X X
Pseudocode: Forwrd Elmto Do k = to - Do = k+ to fctor =,k / k,k Do j = k+ to Ed Do,j =,j fctor * k,j = fctor * k Ed Do Ed Do 7
Pseudocode: Bck Susttuto = /, Do = - dowto sum = Do j = + to sum = sum,j * j Ed Do = sum /, Ed Do 8
9 Prolems wth Nve Guss Elmto o The Nve Guss Elmto my fl for very smple cses. (The pvotg elemet (dgol elemet; pvot ) s zero). o Also, very smll pvotg elemet my result serous computto errors.
Remedy : Pvotg & Sclg Pvotg Choose lrgest elemet ech colum for pvot Ths c e doe y swppg oth rows d colums complete pvotg. Or oly swppg rows Prtl pvotg Sclg Dvde ll elemets ech row y ts lrgest elemet
Emple 8 Pvotg : wth Prtl Solve the followg system usg Guss Elmto Prtl pvotg mes row swps usg pvots,.e., No colum swps.
Emple Itlzto step L Ide Vector 8
Why Ide Vector? Ide vectors re used ecuse t s much eser to echge sgle de elemet compred to echgg the vlues of complete row. I prctcl prolems wth very lrge N, echgg the cotets of rows my ot e prctcl,.e., c tke tme d memory.
Emple Forwrd Elmto-- Step : elmte ] [ the frst pvot equto Echge equto s to correspods m ] Frst colum [ ] [ 8 the pvot equto Selecto of L l d l l L T
Emple Forwrd Elmto-- Step : elmte.8..8... 8.....8. 8 Updte A d B Frst pvot equto
Emple Forwrd Elmto-- Step : elmte Selecto of L d [.. 8. Colum : the secod pvot equto.8..... ].8..8... L [ ]
7 Emple Forwrd Elmto-- Step : elmte.8..... 8.88.77. ] [.8..8... 8.88.77..88 L Thrd pvot equto
8 Emple Bckwrd Susttuto 7. 8.....8.7.77.88..,.. ] [.8..... 8.88.77.,,,,,,,,,, L
9 Emple wth Sclg 8 Pvotg : wth Scled Prtl Solve the followg system usg Guss Elmto Scled Prtl pvotg mes row swps usg scled pvots.
Emple Itlzto step L Ide Vector 8 S Scle vector 8 Scle vector: dsregrd sg fd lrgest mgtude ech row
Emple Forwrd Elmto-- Step : elmte ] [ the frst pvot equto Echge equto s to correspods m, 8,,,,, ] [ ] 8 [ 8 the pvot equto Selecto of, L l d l l S Rtos L S l l
Emple Forwrd Elmto-- Step : elmte..7..7...7.7...7. 8 Updte A d B Frst pvot equto
Emple Forwrd Elmto-- Step : elmte Selecto of S. [.. 8 the secod pvot equto.7.7. ]..7.7 L [..7. ] Rtos : l, S l,,.. 8. L [ ]
Emple Forwrd Elmto-- Step : elmte 9.7..8...7. ] [.8.7..7..8...7. L Thrd pvot equto
Emple Bckwrd Susttuto 7....7...7..8.7., 9 ] [ 9.7..8...7.,,,,,,,,,, L l
Emple : Scled Prtl Pvotg 8 Solve the followg system usg Guss elmto wth scled prtl pvotg
7 Emple Itlzto step L Ide Vector 8 S Scle vector 8
8 Emple Forwrd Elmto-- Step : elmte ] [ the frst pvot equto Echge equto s to correspods m, 8,,,,, ] [ ] 8 [ 8 the pvot equto Selecto of, L l d l l S Rtos L S l l
9 Emple Forwrd Elmto-- Step : elmte..7..7...7.7...7. 8 Updte A d B
] [. 8..,, Rtos : ] [ ] 8 [..7..7...7.7...7. the secod pvot equto Selecto of, L S L S l l Emple Forwrd Elmto-- Step : elmte
Emple Forwrd Elmto-- Step : elmte..87.98.7...7 -.79.7.787 ] [..7..7...7.7...7. Updtg A d B L
Emple Forwrd Elmto-- Step : elmte ] [.787.79, Rtos : ] [ ] 8 [..87.98.7...7.79.7.787 the thrd pvot equto Selecto of, L S L S l l
Emple Forwrd Elmto-- Step : elmte..87.9.7...7.79.88 ] [..87.98.7...7.79.7.787 L
Emple Bckwrd Susttuto.87.9.98.79.7.87.7,.88.9 ] [..87.9.7...7.79.88,,,,,,,,,, L l l l l l l l l l l l l l l
How Do We Kow If Soluto s Good or Not Gve A= (A : mtr, : rghthd-sde (RHS) vector) s soluto f A-= Compute the resdul vector r= A- Due to roudg error, rmy ot e zero The soluto s cceptle f m r ε s usully clled tolerce.
How Good s the Soluto?.... Resdues :.7.98.9.87 8 R soluto
Remrks: We use de vector to vod the eed to move the rows whch my ot e prctcl for lrge prolems. If we order the equto s the lst vlue of the de vector, we hve trgulr form. Scle vector s formed y tkg mmum mgtude ech row. Scle vector does ot chge. The orgl mtr Ad vector re used 7 checkg the resduls.
8 Trdgol Systems: The o-zero elemets re the m dgol, super dgold sudgol. j = f -j > Trdgol Systems
Trdgol Systems Occur my pplctos Needs less storge(- compred to + for the geerl cses) Selecto of pvotg rows s uecessry (uder some codtos) Effcetlysolved y Guss elmto 9
Algorthm to Solve Trdgol Systems Bsed o Nve Guss elmto. As prevous Guss elmto lgorthms Forwrd elmto step Bckwrd susttuto step Elemets the super dgolre ot ffected. Elemets the m dgol, d eed updtg
Trdgol System ' ' ' ' ' ' elemets re ot updted The elemets d to updte the eed e zeros, wll elemets the All d c d c d c d d c d c d c d c d M M O O M M O O O
Dgol Domce A mtr A j, j j s dgolly domt f for ( ) The mgtude of ech dgol elemet s lrger th the sum of elemets the correspodg row.
Dgol Domce Emples : Dgolly domt Not Dgolly domt
Dgolly Domt Trdgol System A trdgol system s dgolly domt f d c ( ) Forwrd Elmto preserves dgol domce
Solvg Trdgol System,...,, for Susttuto Bckwrd Elmto Forwrd c d d d c d d d
Emple,, for, Susttuto Bckwrd, Elmto Forwrd 8 9,,, 8 9 Solve c d d d c d d d B C A D
7 Emple.9...9,.... 8.,.. 9., ForwrdElmto 8 9,,, d c d d d d c d d d d c d d d B C A D
8 Emple Bckwrd Susttuto After the Forwrd Elmto: Bckwrd Susttuto:....,.9.9.9...9,.. d c d c d c d T T d
How does LU Decomposto work? If solvg set of ler equtos If A = LU the Multply y L - whch gves Rememer L - L = I whch leds to Now, sce IU = U the Now, let A = LU = L - LU = L - IU = L - U = L - L - = z Whch eds wth Lz = () Ad U = z () Thus, gve A =,. Decompose A = LU. Solve Lz= for z. Solve U= z for 9
Is LU Decomposto etter th Guss Elmto? Solve A = T = clock cycle tme d = sze of the mtr Forwrd Elmto Decomposto CT FE 8 T 8 CT DE 8 T Bck Susttuto CT BS T Forwrd Susttuto CT FS T Bck Susttuto CT BS T 7
Is LU Decomposto etter th Guss Elmto? Tme tke y methods To solve A = Guss Elmto LU Decomposto T 8 T = clock cycle tme d = sze of the mtr T 8 So oth methods re eqully effcet. 7
To fd verse of A Tme tke y Guss Elmto Tme tke y LU Decomposto CT 8 T FE CT BS CT T LU CT FS CT BS 7
To fd verse of A Tme tke y Guss Elmto 8 T Tme tke y LU Decomposto T Tle Comprg computtol tmes of fdg verse of mtr usg LU decomposto d Guss elmto. CT verse GE / CT verse LU.8.8.8 7
Method: A Decomposes to L d U A LU l l l u u u u u u U s the sme s the coeffcet mtr t the ed of the forwrd elmto step. L s oted usg the multplers tht were used the forwrd elmto process 7
Fdg the U mtr Usg the Forwrd Elmto Procedure of Guss Elmto 8 Step :.;.7; Row Row. Row Row.7.8.8.8...7 7
Fdg the UMtr Step :.7.8..8.7..8..;.8.8 Row Row.7..8 U Mtr fter Step : 7
Fdg the L mtr l l Usg the multplers used durg the Forwrd Elmto Procedure From the frst l. step of forwrd 8 elmto l.7 l 77
Fdg the LMtr From the secod step of forwrd elmto.8.8..7 l.8.8. L..7. 78
Does LU= A? LU..7..8..7? 79
Geerl Formul (Doolttle s method) 8 ;,,,, ;,,,, k k j u u j u j j k u u k u k s sk js jk kk jk j j j s sk js jk jk k k K l l K l K l K
Prevous Emple Revsted 8 A.7.).( /..8) ) /( / (.; /.8; / 8 ; / ; / ; ; ; u u u u u u l l l 8
Usg LU Decomposto to solve SLEs Solve the followg set of ler equtos usg LU Decomposto 8. 8 77. 79. Usg the procedure for fdg the L d U mtrces A LU..7..8..7 8
Emple Set Lz = Solve for z 79. 77..8..7. z z z 79...7 77...8 z z z z z z.7 9...7.8 79...7 79. 9...8 77.. 77. z z z z z.7 9..8 z z z z 8
Emple Set U = z.8..7. 8 9.. 7 Solve for The equtos ecome.8..7.8 9..7 8
Emple From the rd equto Susttutg d usg the secod equto. 7. 7. 7. 7... 8. 9 9... 8 9.... 8 9. 7 8
Emple Susttutg d usg the frst equto 8.. 8. 8 9. 7. 9. Hece the Soluto Vector s:.9 9.7. 8
Fdg the verse of squre mtr How c LU Decomposto e used to fd the verse? Let B = A - d ssume the frst colum of B to e [ ] T Usg ths d the defto of mtr multplcto Frst colum of B, Secod colum of B, M M A M M A The remg colums B c e foud the sme mer 87
Emple: Iverse of Mtr Fd the verse of squre mtr A A 8 Usg the decomposto procedure, the L d U mtrces re foud to e A LU. 8.. 7... 7 88
Emple: Iverse of Mtr Solvg for the ech colum of B requres two steps ) Solve Lz = for z ) Solve U = z for Step :..7. z z z Lz Ths geertes the equtos:..7. z z z z z z 89
Emple: Iverse of Mtr Solvg for z 7 7.... z. z. z.. z. z z.. z z z z 9
Emple: Iverse of Mtr Solvg U = z for.8..7...8..7.. 9
Emple: Iverse of Mtr Usg Bckwrd Susttuto..7.7...8...7.9.8.9.7.7 So the frst colum of the verse of A s:.7.9.7 9
Emple: Iverse of Mtr Repetg for the secod d thrd colums of the verse Secod Colum Thrd Colum 8..7.8 8.9..7 9
Emple: Iverse of Mtr The verse of A s A.7.9.7.8.7..7..9 To check your work do the followg operto AA - = I = A - A 9
Guss-Jord Method The method reduces the geerl system of equtos A=to I= where Is detty mtr. Oly Forwrd elmto s doe d o ckwrd susttuto s eeded. It hs the sme prolems s Nve Guss elmto d c e modfed to do scled prtl pvotg. It tkes % more tme th Nve Guss method. It s ofte used to fd verse mtrces. 9
9 Guss-Jord Method Emple 7 / from Elemte 7 eq eq eq eq eq eq eq eq d equtos Step
97 Guss-Jord Method Emple.7.7.8.7 / from Elemte 7 eq eq eq eq eq eq eq eq d equtos Step
98 Guss-Jord Method Emple.8.7 / from Elemte.7.7.8.7 eq eq eq eq eq eq eq eq d equtos Step
99 Guss-Jord Method Emple 7 s soluto to trsformed s
Guss-Jord Method Fdg verse mtr () A Fd the verse mtr of A I B Frst costruct the ugmeted mtr:
Guss-Jord Method Fdg verse mtr () Applyg the Guss-Jord method: / / / / / / / / / / / / / / / / / / / /
Guss-Jord Method Fdg verse mtr () / / / / / / / / / / / / / / / / A Therefore,
LU Decomposto Method For most o-sgulr mtr A tht oe could coduct Nïve Guss Elmto forwrd elmto steps, oe c lwys wrte t s A = LU where L = lower trgulr mtr U = upper trgulr mtr
Guss-Sedel Method Guss-Sedel s the smplest tertve method for solvg mtr equto. Bsc Procedure: - Algerclly solve ech ler equto for - Assume tl guess soluto rry - Solve for ech d repet - Use solute ppromte error fter ech terto to check f error s wth pre-specfed tolerce.
Advtges If oly few tertos re requred, computtol cost s lower compred to Guss elmto or LU decomposto. If the physcs of the prolem re uderstood, close tl guess c e mde, decresg the umer of tertos eeded. However, f the mtr s ll-codtoed, the soluto mght ot coverge.
Algorthm Iput : mtr A, vector, tl guess, tolerce. Updte j, j=,, usg ( m) j Ajj j j k A ( m) k. Check f the covergece crtero s met. m j Repet utl covergece. jk ( m ) ( m) j j k j A jk ( m) k
Emple Solve.. -. 7 -. -. -.. ; 7 st terto: =[. -.7.] d terto: =[.8 -..] rd terto: =[.7 -..] th terto: =[.7 -..] NOTE: Oly few tertos re requred for dgolly domtmtrces (well-codtoed, or smll codto umer). 7