P. 1
LU Factorisation and Forward and Back Substitution_Excel

LU Factorisation and Forward and Back Substitution_Excel

|Views: 29|Likes:
Published by rodwellhead
A guide to an Excel spreadsheet that contains code in visual basic that implements the LU factorisation (with pivoting) algorithm and the forward and back substitution algorithms. The spreadsheet has a number of demonstration matrix-vector systems that can be used to illustrate the method. Your own matrix-vector system may be tried too.
A guide to an Excel spreadsheet that contains code in visual basic that implements the LU factorisation (with pivoting) algorithm and the forward and back substitution algorithms. The spreadsheet has a number of demonstration matrix-vector systems that can be used to illustrate the method. Your own matrix-vector system may be tried too.

More info:

Categories:Types, School Work
Published by: rodwellhead on Jul 17, 2014
Copyright:Traditional Copyright: All rights reserved

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/29/2015

pdf

text

original

www.numerical-methods.

com

LU factorisation and back substitution – Excel Spreadsheet
1


This spreadsheet contains the VBA source files for carrying out the LU factorisation and
back-substitution of a general square matrix, which is useful in solving general
linear systems of equations
2
. Several test problems that demonstrate the computation
of LU factors are given and these are followed up by examples of solving matrix-vector
systems by backward and forward substitution. The spreadsheet implements two
algorithms as VBA subroutines that can be viewed or downloaded; the LU factorisation
method LUfac
3
and the LU back and forward substitution method LUfbsub
4
.

The spreadsheet consists of three sheets; the first sheet demonstrates the methods on a
3x3 matrix and matrix-vector problem, the second sheets similarly on a 5x5 problem
and the third sheet similarly on a similar 10x10 problem. Two algorithms are
implemented in VBA in order to carry out the objectives of this spreadsheet; LU
factorisation and backward and forward substitution. All three spreadsheets find the LU
factorisation of a matrix ‘A’, giving L and U. The LU factorisation method also requires
and also a permutation matrix is allowed, to record row exchanges (as a result of
pivoting) throughout the method, necessary to avoid division by zero or ‘small’
numbers. In summary, the spreadsheet returns the lower-triangular matrix L, the
upper-triangular matrix U and the permutation matrix P so that



Since the three sheets have a similar format then it is suffice to consider the first sheet
in this document.

An image of the top half of page one of the spreadsheet is shown below.



The 3x3 matrix is placed in the 3x3 yellow square and h. The sheet is able to solve any
3x3 system, by pacing the matrix in the yellow 3x3 grid and the vector in the yellow 1x3
column. However the following sample test problem is included and this can be
restored by using the button.

(



)(

) (

)


1
LU.xlsm
2
LU Factorisation
3
LUfac
4
LUfbsub
www.numerical-methods.com

The test data is on the right of the spreadsheet. The default test data is shown as
follows.



The matrix and vector can be cleared using the button and the
vector alone can be cleared using the button.

The LU factorisation of the matrix can be found by pressing the
button, by executing the LUfac
5
subroutine . For the matrix in test 1 above, this gives



From the results above the permutation matrix in the row index in this ase indicates
that no rows have interchanged; the permutation matrix is

(



)

As a check, in green, the matrices L and U are multiplied to give LU and P
T
LU. P
T
LU
should be equal to the matrix A, as shown in the example.



On pressing the button, the matrix-vector system is solved from the LU
factors and by using the LUfbsub
6
subroutine. The results are given, as follows:
;

5
LUfac
www.numerical-methods.com

Test 2 _ Pivotting required
The second test problem can be introduced by pressing . The
test data from the right of the screen



is then placed in the yellow cells.



In this case the zero in the first row and column would cause a division by zero error if
the LU factorisation method was applied without pivoting. The LU factors can be found
by pressing the , to give the following.


Hence the LU factorisation in terms of is as follows:

(



)(



) (



)(



)

As before, the solution to the matrix-vector system can be obtained by pressing the
button.

Test 3 – Singular matrix
The third test problem can be introduced by pressing . The
following test data from the right of the screen is then placed in the yellow cells.



6
LUfbsub
www.numerical-methods.com



In this case the matrix is singular and cannot be solved over; on pressing
the following message appears on the screen.



Note that if the matrix is ‘nearly singular’ or ill-conditioned
7
then it is still unsuitable for
numerical solution and this is also flagged up in the message box.

Larger Matrices
The following 5x5 and 10x10 systems are on the other two sheets of the spreadsheet, in LU
factorisations and solutions are obtained using the same LU





7
Condition and Condition Number of a Matrix

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->