A linear system is said to be square if the number of equations matches the number of unknowns. If the system Ax=b is square, then the coefficient matrix, A, is square. If A has an inverse, then the solution to the system Ax=b can be found by multiplying both sides by A−1
Ax=b
A−1Ax=A−1b
x=A−1b
If A is an invertible n by n matrix, then the system Ax=b has a unique solution for every n‐vector b, and this solution equals A−1b.
Since the determination of A−1 typically requires more calculation than performing Gaussian elimination and back substitution, this is not necessarily an improved method of solving Ax=b (And, of course, if A is not square, then it has no inverse, so this method is not even an option for non square systems.).However, if the coefficient matrix A is square, and if A−1 is known or the solution of Ax=b is required for several different b's, then this method is indeed useful, from both a theoretical and a practical point of view.
The elementary row operations that characterize Gauss‐Jordan elimination can be applied to compute the inverse of a square matrix.
If E is the elementary matrix that results when a particular elementary row operation is performed on I(Identity Matrix), then the product EA is equal to the matrix that would result if that same elementary row operation were applied to A. In other words, an elementary row operation on a matrix A can be performed by multiplying A on the left by the corresponding elementary matrix.
Thus the sequence of elementary matrix product will give the identity matrix En...E2E1A=I. where the elementary transformation matrix En....E2E1 will represent A−1
We can solve the equation using an augmented notation
[A|In]……[In|A−1]
This means that , if we bring the augmented equation system into reduced row echelon form, we can read out the inverse on the right hand side of the equation system.Hence determining the inverse of a matrix is equivalent to solving system of linear equations.
Example:
Determine the inverse of the matrix
The augmented matrix is
Since the transformation [ A | I] → [ I | A −1] reads
So the inverse of the matrix A is
Python Program
# Importing NumPy Library
import numpy as np
import sys
# Reading order of matrix
n = int(input('Enter order of matrix: '))
# Making numpy array of n x 2n size and initializing
# to zero for storing augmented matrix
a = np.zeros((n,2*n))
# Reading matrix coefficients
print('Enter Matrix Coefficients:')
for i in range(n):
for j in range(n):
a[i][j] = float(input( 'a['+str(i)+']['+ str(j)+']='))
# Augmenting Identity Matrix of Order n
for i in range(n):
for j in range(n):
if i == j:
a[i][j+n] = 1
# Applying Guass Jordan Elimination
for i in range(n):
if a[i][i] == 0.0:
sys.exit('Divide by zero detected!')
for j in range(n):
if i != j:
ratio = a[j][i]/a[i][i]
for k in range(2*n):
a[j][k] = a[j][k] - ratio * a[i][k]
# Row operation to make principal diagonal element to 1
for i in range(n):
divisor = a[i][i]
for j in range(2*n):
a[i][j] = a[i][j]/divisor
# Displaying Inverse Matrix
print('\nINVERSE MATRIX IS:')
for i in range(n):
for j in range(n, 2*n):
print(a[i][j], end='\t')
print()
Enter order of matrix: 4 Enter Matrix Coefficients: a[0][0]=1 a[0][1]=0 a[0][2]=2 a[0][3]=0 a[1][0]=1 a[1][1]=1 a[1][2]=0 a[1][3]=0 a[2][0]=1 a[2][1]=2 a[2][2]=0 a[2][3]=1 a[3][0]=1 a[3][1]=1 a[3][2]=1 a[3][3]=1 INVERSE MATRIX IS: -1.0 2.0 -2.0 2.0 1.0 -1.0 2.0 -2.0 1.0 -1.0 1.0 -1.0 -1.0 0.0 -1.0 2.0
sympy code
from sympy import Matrix
M = Matrix(4, 4, [1, 0,0, 1, 0, 2, 1, 2, 2,1,0,1,2,0,1,4])
print(M.inv())
[1010011011011110]
Augmented matrix AI
[1010|10000110|01001101|00101110|0001]
R3=R3−R1,R4=R4−R1
[1010|10000110|010001−11|−10100100|−1001]
R2=R2−R4,R3=R3−R4
[1010|10000010|110−100−11|001−10100|−1001]
Swap R2 and R4[1010|10000100|−100100−11|001−10010|110−1]
R1=R1−R4, R3=R3+R4[1000|0−1010100|−10010001|111−20010|110−1]
swap R3 and R4[1000|0−1010100|−10010010|110−10001|111−2]
So the inverse is[0−101−1001110−1111−2]
Determine the inverses of the following matrix using Gaussian elimination method.Show all steps( university question)
[1001021221012014]
Determine the inverses of the following matrix if possible ( university question)
[1010011011011110]
Augmented matrix AI
[1010|10000110|01001101|00101110|0001]
R3=R3−R1,R4=R4−R1
[1010|10000110|010001−11|−10100100|−1001]
R2=R2−R4,R3=R3−R4
[1010|10000010|110−100−11|001−10100|−1001]
Swap R2 and R4[1010|10000100|−100100−11|001−10010|110−1]
R1=R1−R4, R3=R3+R4[1000|0−1010100|−10010001|111−20010|110−1]
swap R3 and R4[1000|0−1010100|−10010010|110−10001|111−2]
So the inverse is[0−101−1001110−1111−2]
Determine the inverses of the following matrix using Gaussian elimination method.Show all steps( university question)
[1001021221012014]
Augmented matrix AI
[1001|10000212|01002101|00102014|0001]
[1001|10000212|01002101|00102014|0001]
R3=R1×−2+R3
R4=R1×−2+R4
[1001|1000011/21|01/200010−1|−20100012|−2001]
R3=R3−R2
[1001|1000011/21|01/20000−1/2−2|−2−1/2100012|−2001]
R3=R3×−2
[1001|1000011/21|01/2000014|41−200012|−2001]
R4=R4−R3
[1001|1000011/21|01/2000014|41−20000−2|−6−121]
R4=R4/−2
[1001|1000011/21|01/2000014|41−200001|31/2−1−1/2]
R1=R1−R4
[1000|−2−1/211/2011/21|01/2000014|41−200001|31/2−1−1/2]
R2=R3×−1/2+R2
[1000|−2−1/211/2010−1|−20100014|41−200001|31/2−1−1/2]
R2=R2+R4
[1000|−2−1/211/20100|11/20−1/20014|41−200001|31/2−1−1/2]
R3=R4×−4+R3
[1000|−2−1/211/20100|11/20−1/20010|−8−1220001|31/2−1−1/2]
The inverse is
[−2−1/211/211/20−1/2−8−12231/2−1−1/2]
Comments
Post a Comment