Page 249 -
P. 249

x(1)=b(1)/L(1,1);
                                   for k=2:n
                                   x(k)=(b(k)-L(k,1:k-1)*x(1:k-1))/L(k,k);
                                   end
                                x


                             Example 8.5
                             Solve the system of equations: UX = B, where U is an upper triangular matrix.
                             Solution: The matrix form of the problem becomes:


                                        U 11  U 12  U 13   L      U 1 n    x     b 
                                                                          1      1  
                                         0   U 22  U 23    L      U 2 n     x  2      b 2 
                                         M    M    O        M       M     M  =   M   (8.15)
                                                                               
                                         0    0    L     U n 1 −  U n 1   x n 1   b n 1
                                                            −
                                                                     −
                                                                            −
                                                                                   −
                                                              n 1
                                                                       n
                                         0    0     0      L      U       x     b 
                                                                    nn    n     n 
                             In this case, the solution of this system can also be directly obtained if we pro-
                             ceed iteratively, but this time in the backward order x , x , …, x , obtaining:
                                                                           n
                                                                                     1
                                                                              n–1
                                                          b
                                                     x =   n
                                                      n
                                                         U
                                                           nn
                                                           b (  n−1  − U n−1 n  x )
                                                                      n
                                                     x   =
                                                      n−1
                                                              U
                                                                n−1 n−1
                                                                                           (8.16)
                                                     M
                                                              n     
                                                           k ∑
                                                           b −  U x  
                                                                     j
                                                                   kj
                                                              =+1
                                                     x =     jk     
                                                      k
                                                              U
                                                                kk
                             The corresponding script M-file is
                                U=[ ];                      % enter the U matrix
                                b=[ ];                      % enter the B column
                                n=length(b);
                                x=zeros(n,1);
                                x(n)=b(n)/U(n,n);
                                   for k=n-1:-1:1

                             © 2001 by CRC Press LLC
   244   245   246   247   248   249   250   251   252   253   254