0% found this document useful (0 votes)
5 views1 page

Script Lahi

The document outlines a procedure for solving a system of linear equations using LU decomposition with row pivoting in Excel. It details the definitions of matrices involved, the reading of the coefficient matrix and vector, and the steps for forward and backward substitution to find the solution vector. Finally, it instructs on how to print the results back into the Excel sheet.

Uploaded by

palero.nathanj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Script Lahi

The document outlines a procedure for solving a system of linear equations using LU decomposition with row pivoting in Excel. It details the definitions of matrices involved, the reading of the coefficient matrix and vector, and the steps for forward and backward substitution to find the solution vector. Finally, it instructs on how to print the results back into the Excel sheet.

Uploaded by

palero.nathanj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Matrix Definitions:
 A(1 To 6, 1 To 6) is the coefficient matrix.
 L(1 To 6, 1 To 6) and U(1 To 6, 1 To 6) will store the lower and
upper triangular matrices.
 X(1 To 6) will store the solution vector.
 B(1 To 6) is the vector on the right-hand side of the linear
equations.
2. Define Coefficients (Matrix A):
 The coefficients of the 6x6 matrix A are defined. You should
modify these values according to your specific linear system.
3. Read Matrix B:
 The code reads the vector B from column H in your Excel sheet
and stores it in the array B.
4. LU Decomposition with Row Pivoting:
 The code performs LU decomposition with row pivoting. It
iterates through each row of the matrix A, finding the row with
the maximum absolute value in the current column and
swapping rows if necessary to avoid division by zero.
 Upper triangular matrix U is computed, and lower triangular
matrix L is computed in the process.
5. Forward Substitution (LY = B):
 After LU decomposition, the code solves for Y using forward
substitution: LY = B.
6. Backward Substitution (UX = Y):
 The code then solves for the final solution vector X using
backward substitution: UX = Y.
7. Print the Results:
 The results (values of X) are printed to column I in your Excel
sheet.

To ensure that division by zero is avoided, the code performs row pivoting by
swapping rows when it finds a pivot element that is close to zero. This
prevents division by zero and ensures the stability of the LU decomposition.

You can run this code in the VBA editor within Excel to solve your system of
linear equations. Make sure your Excel sheet has the coefficient matrix A in
the proper format in columns A to F and the vector B in column H. The
results (solution vector X) will be printed in column I.

You might also like