Matrix Inverse: Matrix Inversion Technique

Matrix Inversion Technique 

The inverse of a matrix

The inverse of a square n × n matrix A is another n × n matrix denoted by A-1 such that

AA-1=A-1A=I

where I is the n × n identity matrix. That is, multiplying a matrix by its inverse produces an identity matrix. Not all square matrices have an inverse matrix. If the determinant of the matrix is zero, then it will not have an inverse, and the matrix is said to be singular. Only non-singular matrices have inverses.

A formula for finding the inverse

Given any non-singular matrix A, its inverse can be found from the formula A-1 = adj A |A| where adj A is the adjoint matrix and |A| is the determinant of A. The procedure for finding the adjoint matrix is given below.

Finding the adjoint matrix

The adjoint of a matrix A is found in stages:

Find the transpose of A, which is denoted by AT. The transpose is found by interchanging the rows and columns of A. So, for example, the first column of A is the first row of the transposed matrix; the second column of A is the second row of the transposed matrix, and so on.

The minor of any element is found by covering up the elements in its row and column and finding the determinant of the remaining matrix. By replacing each element of AT with its minor, we can write down a matrix of minors of AT.

The cofactor of any element is found by taking it's minor and imposing a place sign according to the following rule:

Matrix Inverse: Matrix Inversion Technique

This means, for example, that to find the cofactor of an element in the first row, or second column, the sign of the minor is changed. On the other hand to find the cofactor of an element in the second row, second column, the sign of the minor is unaltered. This is equivalent to multiplying the minor by ‘+1’ or ‘−1’ depending upon its position. In this way, we can form a matrix of cofactors of AT. This matrix is called the adjoint of A, denoted adj A. The matrix of cofactors of the transpose of A, is called the adjoint Matrix, adj A.

C program to find value using the matrix inversion technique

#include <stdio.h>
#include <math.h>

int main()
{
    int n, i, k, j, p, q;
    float pivot, term, a[10][10];
    printf("Matrix Inversion");
    printf("\nEnter Dimension of System of equation\n");
    scanf("%d", &n);
    printf("\nEnter the coefficients of the Matrix\n");
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
        {
            scanf("%f", &a[i][j]);
        }

    for (i = 0; i < n; i++)
    {
        for (j = n; j < 2 * n; j++)
        {
            if (i == j - n)
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
    }

    for (k = 0; k < n; k++)
    {
        pivot = a[k][k];
        for (p = 0; p < 2 * n; p++)
            a[k][p] = a[k][p] / pivot;
        for (i = 0; i < n; i++)
        {
            term = a[i][k];
            if (k != i)
                for (j = 0; j < 2 * n; j++)
                {
                    a[i][j] = a[i][j] - a[k][j] * term;
                }
        }
    }

    printf("\nMatrix Inverse is:\n");
    for (i = 0; i < n; i++)
    {
        for (j = n; j < 2 * n; j++)
            printf("%f\t", a[i][j]);
        printf("\n");
    }
    return 0;
}

Matrix Inverse: Matrix Inversion Technique


Comments

Popular posts from this blog

C Program for SCAN Disk Scheduling Algorithm | C Programming

C Program To Check The String Is Valid Identifier Or Not | C Programming

C program to Find Cartesian Product of Two Sets | C programming