Solving System of Linear Equations and Finding Inverses of N N Matrices
Solving System of Linear Equations and Finding Inverses of N N Matrices
N*N matrices
Namit Anand
Roll No. - 1111033
0.1 Objective
1. Find the inverse of a given matrix by Gaussian elimination with back substitution
and LU decomposition and make a generic program for the same.
Table 1: Given matrix
1.0 3.0 2.1
2.0 5.0 7.5
2.3 4.0 8.0
2. Solve following set of linear equations with Gauss Jordan method, Gauss elimination
by back substitution and LU decomposition. Use pivoting in all the cases.
2.5x1 + 4.2x2 1.1x3 2.1x4 = 10.1
3.9x1 + 2.1x3 + 1.2x4 = 6.5
1.2x1 + 3.4x2 1.5x4 = 2.7
3.0x1 + 1.9x2 + 5.2x4 = 1.8
0.2 LU decomposition:
0.2.1 Theory :
LU decomposition is a matrix decomposition in which a matrix is written as the product
of a lower triangular matrix and an upper triangular matrix. This decomposition is used
in numerical analysis to solve systems of linear equations or calculate the determinant.
Let A be a square matrix. An LU decomposition is a decomposition of the form
A = LU
A =
_
_
A
00
A
01
A
02
..
A
10
A
11
A
12
..
A
20
A
21
A
22
..
.. .. .. ..
_
_
=
_
_
_
_
L
00
0 0 ..
L
10
L
11
0 ..
L
20
L
21
L
22
..
.. .. .. ..
_
_
_
_
_
_
_
_
U
00
U
01
U
02
..
0 U
11
U
12
..
0 0 U
22
..
.. .. .. ..
_
_
_
_
(1)
1
0.2.2 Algorithm used:
1. The diagonal values of U are set to be 1.
2. The rst row elements of U and rst column elements of L are calculated as follows:
L
i,0
= A
i,0
U
0,i
=
A
0,j
L
0,0
3. For every column, at rst, L
i,i
is calculated as L
i,i
= A
i,i
L
i,k
U
k,i
. Then, for
rows, (i + 1) to n, L
j,i
and U
i,j
are calculated as :
L
j,i
= A
j,i
k
L
j,k
U
k,i
U
i,j
=
A
i,j
k
L
i,k
U
k,j
L
i,i
0.3 Result :
0.3.1 Inverse of given matrix A by Gauss elimination
1.562500 -2.437500 1.875000
0.195312 -0.495313 -0.515625
-0.546875 0.453125 -0.156250
0.3.2 Inverse of given matrix A by LU decomposition
1.562500 -2.437500 1.875000
0.195312 -0.495313 -0.515625
-0.546875 0.453125 -0.156250
2
0.3.3 Solution of linear equations
x1 = 1.146987
x2 = 0.215361
x3 = 5.000066
x4 = 0.394259
3