Posts

Showing posts with the label inverse matrix

mathajax

Inverse Matrix by LU Decomposition

One of the application of LU matrix decomposition finds inverse of a square matrix,A. A A -1 = I The square matrix (coefficient matrix) A decomposed into LU (lower triangular and upper triangular) matrix by elementary-row-operations . A = LU after that, inverse matrix A -1 is found by applying forward and back substitution on each column of identity matrix, I and place returning solution vectors x to column of A -1 matrix. Algorithm steps for Matrix Inverse by LU Decomposition Input : a square matrix , A Output : a square matrix, A -1 read matrix A [L,U]= LUDecompose (A) [nrow,ncol]=size(A) I = Identity-matrix(nrow,ncol); iA = zero-matrix(nrow,ncol); For c =1 to ncol Y = forward-substitute (L,I(c)) X = back-substitute (U,Y) A -1 (c,:) = X // set vector X to column of A -1 ...

Inverse Matrix by Gauss Jordan Elimination

Image
It finds N x N inverse matrix for a matrix which has NxN elements by Gauss-Jordan elimination method. Gauss-Jordan elimination method A, matrix has N x N elements I, Identity matrix has N x N elements A|I is a augmented matrix Elementary row operation is applied to augmented matrix A|I and it transforms A|I into I|A -1 . Algorithm Steps for Inverse matrix by Gauss-Jordan Elimination Read Matrix A form Augmented matrix, A|I For i=1 To N For j=1 To N IF i not-equal j apply RowOperation.add(j,i ,-a ii /a ji ) on augmented matrix A|I End End End divide each row of A|I by main diagonal elements, a ii Gauss Jordan Inverse - Java programming code public class Gaussjordan { Matrix mat ; public Gaussjordan( double A[][]) { int row=A.length; int col=A[0].length; mat = new Matrix (row,...

Solving System of Linear Equation by Matrix Inverse

The two or more algebraic equation are called system of equations. The Java program finds solution vector X to a system of three linear equations by matrix inverse method. a 11 x 1 + a 12 x 2 + a 13 x 3 = b 1 a 21 x 1 + a 22 x 2 + a 23 x 3 = b 2 a 31 x 1 + a 32 x 2 + a 33 x 3 = b 3 The three linear equation is represented by matrix format by separating coefficients and unknown variables | a 11 a 12 a 13 | Coefficients matrix A = | a 21 a 22 a 23 | | a 31 a 32 a 33 | unknown variable X = [ x 1 x 2 x 3 ]' non-homogeneous b = [ b 1 b 2 b 3 ]' solve given matrix A and vector b (non-homogeneous vector) find value of vector X Matrix representation A X = b ...

Solve Linear Equation 2x2 matrix

Image
System of Linear Equation The two are more linear equations are called system of linear equation. ax 1 + bx 2 = b 1 cx 1 + dx 2 = b 2 System of Linear Equation in matrix representation solution of system of Linear Equation - Algorithm The following steps are carried out for solving system linear equations by inverse method. Read Matrix A 2x2 D = determinant (Matrix A) D==0, then print matrix A is singular return no solution cA = cofactor_matrix (A) Adjoint-Matrix Adj = transpose (Matrix cA) A -1 = Adj / D solution S = A -1 b print solution S Java program Solve Linear Equation The Java program LinearEquation has one constructor function and following four member functions in order t...

Matrix Determinant, Matrix Adjoint and Matrix Inverse

The Java program implements following three important matrix operation in this code. and these operation is applied on a square matrix size of 3x3. They are, Matrix Determinant Matrix singular or not Adjoint matrix Matrix Inversion AA -1 = I (A -1 ) -1 = A Matrix Determinant - algorithm matrix A - a matrix size of 3x3 A-cofactor(0,c) - read cofactor matrix of 0 th row and c th column of the matrix A set M[] =0 set D=0 Read matrix A For c=0 : A-column matrix cf = A-cofactor(0,c) M[c]=cf[[0][0]*cf[[1][1] - cf[[0][1]*cf[[1][0] End For c=1 : A-column D = D + pow(-1,c+0) *M[c] End print "determinant" D Matrix Inverse - algorithm matrix A - a matrix si...