Posts

Showing posts with the label row operation

mathajax

Matrix Forward and Back Substitution

Image
A square matrix is transformed into a Lower triangular matrix L or an Upper triangular matrix U by applying elementary row operation (Gaussian elimination) for solving system linear of equations. A solution vector X of system of linear equations is obtained by applying substitution method. The forward substitution method is applied to matrix L The back substitution method is applied to matrix U Algorithm steps for forward substitution to matrix L Input : a square matrix, A a non-homogeneous vector b Output : Solution vector, X read matrix A read vector b L = transform_to_L (A,b) X = substitute-forward(L); Example of forward substitution to matrix L substitute unknown variables top to bottom approach 0.4286x = 1.7143 3.6667x + 2.3334y = 10.0 2.0x+ + 4.0y + 6.0z = 18.0 find x, from equation 1 ...

Matrix A = LU Decompose

Image
LU decompose - a square matrix A that can be expressed as product of L and U matrix, is called LU decomposition. A = LU Matrix L - It is called Lower triangular Matrix , whose elements above the main diagonal is zero valued elements. Matrix U - It is called Upper Triangular Matrix , whose elements below the main diagonal is zero valued elements. How to LU decompose - a square matrix A is decomposed or factorized into L and U matrix by elementary row operation , such as swapping two rows and adding or subtracting row by a scalar value. Application of LU decompose It is useful to find solution of system of linear equation and matrix inverse. Algorithm steps for A= LU decompose Read matrix A U = copy (A) L = Identity-matrix() i,j - position of a element in the matrix For i=1 To N Eor j=i+1 To N lambda=U ji /U ii R j <- R j - lambda ...

Matrix Determinant by Diagonal Matrix

Image
A matrix diagonal transformation method is preferred over minor or cofactor of matrix method while finding determinant of the matrix's size over 3x3. The matrix A is converted into Diagonal matrix D by elementary row operation or reduction and then product of main diagonal elements is called determinant of the matrix A. Read matrix A Convert matrix A into diagonal matrix D by applying Row operation or reduction technique Read Main Diagonal elements from D Determinant = product of Main Diagonal elements Algorithm steps for Determinant by Diagonal matrix Read matrix A a - element of the matrix A i,j - position of a element in the matrix for i=1 To N for j=1 To N if i not-equal j RowOperation .add(j,i ,-a ii /a ji ) end end end Determinant = a 11 x a 22 x ... x a nn Java program for a matrix Determinant by Diagonal matrix public class Determinant { Matrix mat; publ...

Matrix Determinant by Lower Triangular Matrix

Image
Determinant, a properties of matrix determines the matrix is singular or not. Lower Triangular matrix transformation method is preferred over minor or cofactor of matrix method while finding determinant of the matrix's size over 3x3. The matrix A is converted into Lower triangular matrix, L by elementary row operation or reduction and then product of main diagonal elements is called determinant of the matrix A. Read matrix A Convert matrix A into L by applying Row operation or reduction technique Read Main Diagonal elements from L Determinant = product of Main Diagonal elements Algorithm steps for Determinant by Lower Triangular Matrix Read matrix A a - elements of matrix A i,j - position of a element in the matrix for i=N-1 To 1 decrement by -1 for j=i-1 To 1 decrement by -1 RowOperation.add(j,i ,-a ii /a ji ) end end Determinant = a 11 x a 22 x ... x a nn Java progr...

Matrix Determinant by Upper Triangular Matrix

Image
Determinant, a properties of matrix determines the matrix is singular or not. Upper triangular method is preferred over minor or cofactor of matrix method while finding determinant of the matrix's size over 3x3. The matrix A is converted into upper triangular matrix U by elementary row operation and then multiplication of main diagonal elements is called determinant of the matrix A. Read matrix A Convert matrix A into U by applying Row operation Read Main Diagonal elements from U Determinant = product of Main Diagonal elements Algorithm steps for Determinant by Upper Triangular Matrix Read matrix A a - element of the matrix A i,j - position of a element in the matrix for i=1 To N for j=i+1 To N RowOperation.add (j,i ,-a ii /a ji ) end end Determinant = a 11 x a 22 x ... x a nn Java program for Determinant by Upper Triangular Matrix...

Solving System of Linear Equations by Gauss Jordan Elimination

Image
It finds a solution vector X for solving a system of linear equations which has NxN elements using Gauss-Jordan elimination method. Gauss-Jordan elimination method matrix A has N x N elements I, Identity matrix has N x N elements b is a vector has Nx1 system of non-homogeneous elements A|b is a augmented matrix result X, is a solution vector has Nx1 elements Elementary row operation is applied to augmented matrix, until it transforms A|b into I|X Algorithm Steps for solving system of linear equations by Gauss-Jordan Elimination Read Matrix A Read vector b form Augmented matrix A|b 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 i th row of non-zero elements in A|b by a ii Java programming code- Gauss Jordan solving Linear equations im...

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 Linear equations by Lower Triangular & Forward Substitution

Image
The Java program that wrote down, finds a solution vector for a system of linear equations which has N equations and N variables by Lower Triangular matrix and Forward Substitution method. A system linear equations has a system matrix (coefficient matrix ), A and a non-homogeneous vector, b thereby, Augmented matrix A|b is formed to find solution vector for unknown variables of the system using lower triangular and forward substitution method. Example for Lower Triangular & Forward substitution The example shown below explains how to solve solution of linear system having 3 equations and 3 variables by lower triangular and forward substitution method. Given System of Linear Equation \[\begin{array}{c} 2.0x+4.0y+6.0z=18 \\ 4.0x+5.0y+6.0z=24 \\ 3.0x+1y-2.0z=4 \end{array} \] Augmented matrix A|b \[ \left[\begin{array}{rrr|r} 2.0 & 4.0 & 6.0 & 18.0 \\ 4.0 & 5.0 & 6.0 & 24.0 \\ 3.0 & 1.0 & -2.0 & 4.0 ...

Solving System of Linear Equation by Gaussian Elimination

Image
Solving linear equation by matrix inverse method is difficult when a system has more than 3 equations and 3 unknown variables. hence, Gaussian elimination is preferred for solving system of linear equations, which has N linear equations and N unknown variables. Gaussian elimination is performed by two steps. they, upper triangular matrix back substitution System of Linear Equation by Gaussian Elimination - algorithm Given - system of Linear equations represents it in matrix form -: A - coefficient matrix X - unknown vector b - non-homogeneous vector form augmented matrix, A|b convert augmented matrix, A|b into upper triangular matrix, U by row operation U = A|b ...

Lower Triangular Matrix by Row Operation

Image
A system of Linear equations AX=b is to transformed into lower triangular matrix by elementary row operation in order to find a solution vector for the unknown vector X. The lower triangulation, which is a intermediate step for solving linear equations, is explained how to finds it from the system of linear equations by row operation . Lower triangular matrix - the matrix contains all elements above the main diagonal elements are zeros. system of Linear equations Matrix representation of system of Linear equations Low Triangular matrix algorithm steps Given matrix A, b and A is 3x3 and b is 3x1 matrix Augmented Matrix mat = A | b maxpivot - finds m th row has maximum value (pivotal value) along c th column RowOperation-swap - swaping two rows c th and m th RowOperation-add - Rc2 th <- ratio R c + R c2 For c=mat.Nrow-1 to ...

Upper Triangular Matrix by Row Operation

Image
It explains how to decompose an augmented matrix into upper triangular matrix by row operation and it is implemented in Java programming. A system of linear equation is represented in matrix format by a matrix called A and two column vectors called X and b respectively. AX =b The X is an unknown vector and is to be found as solution for a system of linear equations. The Gaussian elimination is one of the methods for finding the unknown vector of a linear system of equations. The Gaussian elimination has two main steps Augmented matrix into Upper Triangular Back substitution Here, it contains explanation about how to decompose an augmented matrix into upper triangular matrix. The augmented matrix consist of coefficient matrix A and a column vector b i.e. Alb and it is decomposed into upper triangular matrix by elementary row operation. A matrix has rows and columns arrangements of elements and if all elements below th...

Matrix Elementary Row Operation

Image
The matrix in algebra has three row operations are called Matrix Elementary Row Operation. They are Swapping any two rows Multiply a row by constant Adding any two rows The row operation is carried out on a matrix to turn it a lower triangular matrix or a upper triangular matrix to find out solution vector for system of linear equations. Swap two rows The matrix A has 3 rows and 3 columns. Row R 1 and R 2 swapped - Both rows interchanged their elements. i.e R 1 becomes R 2 and vice versa. Add two rows The matrix A has 3 rows and 3 columns. Add two rows R 1 and R 2 - R 1 's each elements is added to R 2 's corresponding elements. resultant row replace row R 2 i.e R 2 -> R 1 + R 2 . Multiply a row by constant...