Posts

Showing posts from April, 2017

mathajax

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...

Matrix Addition Subtraction and Multiplication

The Java program implements following matrix arithmetic operation by matrix object. matrix addition - The two matrix involving in addition operation must have same number of rows and columns matrix subtraction - The two matrix involving in subtraction operation must have same number of rows and columns matrix multiplication -- The two matrix involving in multiplication operation first matrix number of columns and second matrix of number rows must be equal. matrix square - Only one matrix involving matrix square operation, it must be a square matrix i.e number of rows and columns must be same Add two matrix -Algorithm set matrix C =0 Read matrix A Read matrix B For i=1 to A.row For j=1 to A.column C ij = A ij + B ij End End print matrix C Subtract two matrix -Algorithm set matrix C=0 Read matrix A ...

Scalar arithmetic operation on Matrix

Image
An Arithmetic operation (addition or subtraction or multiplication or division) is carried out between a matrix and a scalar constant. In which each element of the matrix individually undergoes arithmetic operation by the consultant. Assume that, A is matrix and c is a scalar constant and an arithmetic operation addition i.e (A + c) The following figure shows how to add scalar constant over a matrix. The results of a scalar constant addition over a matrix is each elements of the matrix added by the constant c. Matrix scalar addition Each elements of the matrix is added by the constant c. The example shown below a 3x3 matrix is added by a scalar constant 2 Matrix scalar subtraction Each elements of the matrix is subtracted by the constant c. The example shown below a 3x3 matrix is subtracted by a scalar constant 4 Matrix scalar multiplication Each elements of the matrix is multipli...

Matrix in Java

Image
A matrix is a arrangement of elements or coefficients in rows and columns manners. The following Java Matrix class provides some functions to create different types matrix and some functions to operate on the matrix. a 11 ,a 11 .... a mn are elements of the matrix A. m - number of row of the matrix A. n - number of column of the matrix A. a mn - a element of m th row and n th column of the matrix A. The functions helps to create the following types matrix square matrix zero or null matrix Identity matrix diagonal matrix The functions helps to operate on the matrix transpose cofactor The functions setter/getter a element on the matrix getElement - read a element value from matrix at specified by row and column index setElement - set/put a element value on a matrix at specified row and column index Square Matrix -Example...

Complex number on Polar coordinates

Image
A complex number is represented on polar coordinates to simplify arithmetic operation like multiplication and division on the complex numbers. The complex number's real and imaginary number is converted into polar coordinates' parameter r (radius) and θ (angle/radiant). Complex number on polar coordinates A complex number z = a + ib on polar graph representation is r(cos(θ)+isin(θ)). Here r  - radius , θ  - angle/radiant derived from the complex number c. r  =  |z|  = √ a 2 + b 2   θ   =   atan2  ( b , a ) Complex number on polar form - Multiplication complex number z1 = a + ib z2 = a + ib polar form z1= r1(cos(θ1)+isin(θ1)) z2= r2(cos(θ2)+isin(θ2)) Multiplication z1 x z2 = (r1 x r2)(cos(...