You are on page 1of 4

MATRIX INVERSION

A matrix A is said to have an INVERSE if there exists a matrix B such that AB=BA=U
In this case, B is said to be the inverse of A and is denoted by A-1. The inverse of a matrix
may be required for many reasons. For example, it may be desirable to solve the matrix
equation
AX = B
For the unknown X, a number of times with the same coefficient matrix A, but different
matrix B. A convenient way is to obtain the inverse matrix A-1 and there are many ways
of obtaining it. One of the simplest and most effective ways of calculating the inverse of
large matrices in connection with power system analysis is the generalization of the
elimination process. It is most easily understood by considering the following two
simultaneous equations
a11x1 + a12x2 = b1
a21x1 + a22x2 = b2
Dividing the second equation by a22 and re arranging
x2 = a22-1 (b2 - a21x1)
Substituting into the first equation for x2
(a11-a12a22-1a21)x1 + a12a22-1 b2 = b1
The original simultaneous equations and the last two equations can be written in the
matrix form as
 a11 a12   x1   b1   a '11 a '12   x1   b1 
a 21 a 22   x 2   b 2  a'21 a '22  b 2    x 2 
           

where
a’11 = a11 – a12 a22-1a21
a’12 = a12 a22-1
a’21 = - a22-1 a21
a’22 = a22-1

The new equations are of the same form as the original but with x2 and b2 interchanged.
The process can be repeated to interchange x1 and b1. The order in which the interchange
process is carried out is unimportant and can be extended to any number of variables and
leads to the following set of rules :

(1) a’dd = a-1 dd


(2) a’rd = ard a’dd
(3) a’rc = arc - a’rd adc
(4) a’dc = - a’dd adc

where a dd = diagonal element in row and column d


a rc = element in row r and column c
a’ = new element which replaces its predecessor

The process is repeated for all diagonal elements taken in any order with the new
elements stored in the position of previous values. The process leads to the following
very simple FOTRAN program find proposed by Shipley and Coleman :
SUBROUTINE MATINV (A,N)
DIMENSION A(N,N)
C REPLACES MATRIX A OF ORDER N x N BY ITS INVERSE
Do 6 I = 1,N
A(I,I)=1.0/A(I,I)
Do 5 J = 1,N
IF (J-I) 1,5,1
1 A(J,I) = A(J,I) x A(I,I)
Do 4 K = 1,N
IF (K-I) 2,4,2
2 A(J,K) = A(J,K) – A(J,I) x A(I,K)
IF (J-N) 4,3,4
3 A(I,K) = -A(I,I) x A(I,K)
4 CONTINUE
5 CONTINUE
6 CONTINUE
K=N–1
Do 7 L = 1,K
A(N,L) = -A(N,N) x A(N,L)
7 CONTINUE

Function C
#pragma hdrstop
#include <condefs.h>
#include <conio.h>
#include <iostream.h>
#include <stdio.h>

//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
int i,j,k,l;
int n = 3 ;
float a[4][4];

a[1][1] = 1; a[1][2] = -1; a[1][3] = -1;


a[2][1] = -1; a[2][2] = 2; a[2][3] = 0;
a[3][1] = -1; a[3][2] = 0; a[3][3] = 3;

printf(a[1][1]);
// << a[1][2] << a[1][3];

for (i=1;i<=n;i++)
{
a[i][i] = 1.0/a[i][i];
for (j=1;j<=n;j++)
{
if (j!=i)
{
a[j][i] = a[j][i] * a[i][i];
for (k=1;k<=n;k++)
{
if (k!=i)
{
a[j][k] = a[j][k] - a[j][i]*a[i][k];
if (j==n)
{
a[i][k] = -a[i][i]* a[i][k];
}
}
}
}
}
}
k = n-1;
for (l = 1;l<=k;l++)
{
a[n][l] = -a[n][n]*a[n][l];
}
return 0;
}

Example

Using the Shipley and Coleman method, invert the following matrix:

 1  1  1
A   1 2 0 
 1 0 3 
Using natural order for pivoting. The inverse is obtained in the following three stages:

Stage 1 Stage 2

1  1  1  2 1  2 6 3 2
1 1  1 1 1  1  A   3 2 1
1
     
1  1 2  2 1 1  2 1 1

Check on the accuracy of inversion can be obtained from. A.A-1 = U

 1  1  1  6 3 2  1 0 0 
 1 2 0   3 2 1   0 1 0 
     
 1 0 3  2 1 1  0 0 1
Important matrices and rules

1. A matrix of only one row is termed a row vector


2. A matrix of only one column is termed a column vector
3. The transposed form of a matrix is one in which the rows and columns are
interchanged and is denoted by a superscript (or subscript ) t
 1 2 3 1 4 

A    1 2 0  A  2 5
t

 1 0 3 3 6


4. Zero matrix is one which every element is zero and numerically is equivalent to 0
5. Unit matrix has unity in its main diagonal and zero elsewhere
1 
U   1 

 1

6. Diagonal matrix is a square matrix in which all the element except those on the
principal diagram are zero
7. Lower Triangular matrix is a square matrix all of whose elements in the principal
diagonal are zero

a 0 0
A  1 3 0 
8 5 x 
8. Upper Triangular matrix is a square matrix all of whose elements below the principal
diagonal are zero
9. Symmetrical matrix is a square matrix symmetrical with respect to principal diagonal
1 4 7 
A  4 5 6
7 6 3
Skew-symmetric matrix has components with opposite signs on the two sides of the
principal diagonal
10. Singular matrix is a matrix whose inverse does not exist
11. Only a square matrix A has an inverse
12. A-1 is a square matrix
13. If A is a symmetrical matrix, A-1 is also symmetrical
14. If A is a diagonal matrix, A-1 is also diagonal
15. The product of A A-1 = A-1 A = U (unit matrix)
16. (ABC) t = Ct Bt At
(ABC) -1 = C-1 B-1 A-1
Note that the order is reversed

You might also like