Posted: August 26th, 2021
7
Name
Institutional Affiliation
Course
Instructor
Date
7
Crout Matrix Decomposition for n x n Linear System
For a linear system, Crout Matrix decomposition refers to an LU decomposition that can be utilized in decomposing n x n matrix to lower triangular matrix (L), upper triangular matrix (U). The decomposition can also lead to the permutation matrix (P), however, it is not always the case according to Durand Crout. According to the Crout Matrix algorithm, the operation count for n by n linear system can be solved using either C programming language or through a Matlab.Thus, let n x n = A, The following crout factorization algorithm implement in C program can be used to solve the n x n linear system;
void crout (double const **A, double **L, double **U, int n) { int i,j,k; double sum = 0; for (i=0;i<n;i++) { U[i][i]=1; } for (j=0,j<n; i++){ sum=0; for (k=0;k<j; k++) { sum=sum +L[ i ][k]*U[k][j]; } L[i][j]-sum; } for (i=j;i<n;i++) { sum = 0; for (k=0; k<j;k++) { sum=sum + L[j][k]*U[k][i]; } if (L[j][j] ==0) { printf(“det(L) close to 0!\n Can’t divide by 0…\n”); exit (EXIT_FAILURE); } U[j][i] – sum) / L[j][j]; } } } |
At the same time, the algorithm can be implemented using MatLab as follows;
function [L,U] = LUdecompCrout (A) [R,C]=size (A); for i=1:R L(I,1)=A(I,1); U(i,i)=1; end for j=1:R U(1,j)=A(1,j)/L(1,1); end for j=1:R for j=2:i L(I,j)=A(i,j)-L(i, 1;j-1)*U(1:j -1, j); end for j=i+1:R U(I,j)=(A(i,j)-L(i, 1:i)*U(1:i-1,j))/L(i,i); end end |
In either case, the Crout factorization algorithm decomposes the n x n matrix into upper and lower triangular unit matrices resulting in L and U matrices. Afterward, the system solutions are then obtained by using backward substitution and forward substation.
Place an order in 3 easy steps. Takes less than 5 mins.