The task of finding the solutions x , x ,. . . . . . , x to a set of n simultaneous equations is a common problem that occurs in many types of programs. This job can be handled very efficiently by the method of matrix inversion.
Consider the set of three simultaneous equations in three unknowns x , x and x shown below:
a x + a x + a x = c
a x + a x + a x = c
a x + a x + a x = c
This set can be expressed in matrix notation as follows:
a a a x c
a a a x = c
a a a x c
A X C
The solution matrix X can be explicitly expressed in terms of inverse of the coefficient matrix A i.e. A and the constant matrix C ..
x a a a c
x = a a a c
x a a a c
X = A C
Algorithm to find Inverse of a Matrix:
The Gauss-Jordan method for finding inverse of a matrix is shown below in the form of flowchart. In their approach, the following steps are involved:
1. Read nxn matrix A
2. Insert identity matrix into matrix A resulting to a expanded matrix A1 of size nx2n
3. Reduce the first nxn of the expanded matrix A1 to an identity matrix.
4. Extract the remaining nxn matrix as the inverse of matrix A, call this as AI.
Write a program to compute the solution of the problem stated above. Implement the program with subroutines and functions. The output of the program should be as shown below. Your program must declare subprograms, and the calls to those subprograms must pass parameters.
=====================================================
ASSIGNMENT FOUR
=====================================================
SOLUTION OF THE SIMULATANEOUS ALGEBRAIC EQUATIONS
BY
MATRIX INVERSION
SOLUTIONS:
x1 = - - - - - - - - - -
x2 = - - - - - - - - - - -
x3 = - - - - - - - - - - -
=====================================================
B. Test Data:
Verify your program by solving the following sets of equations:
(a) (b) (c)
7x1 - 8x2 + 5x3 = 5 4.5x1 - 2x2 + 3.5x3 = 6 5I1 - I2 - I3 = 11
-4x1 + 5x2 - 3x3 = -3 -2.5x1 + 6x2 + x3 = -5 -I1 + 5I2 - 2I3 = 0
x1 - x2 + x3 = 0 3x1 + 2x2 - x3 = 4 -I1 - I2 + 4I3 = 0
Solutions: x1 = 1.0 x1 = 1.398 I1 = 2.627
x2 = -1.0 x2 = -0.212 I2 = 0.985
x3 = -2.0 x3 = -0.213 I3 = 1.149
Consider the set of three simultaneous equations in three unknowns x , x and x shown below:
a x + a x + a x = c
a x + a x + a x = c
a x + a x + a x = c
This set can be expressed in matrix notation as follows:
a a a x c
a a a x = c
a a a x c
A X C
The solution matrix X can be explicitly expressed in terms of inverse of the coefficient matrix A i.e. A and the constant matrix C ..
x a a a c
x = a a a c
x a a a c
X = A C
Algorithm to find Inverse of a Matrix:
The Gauss-Jordan method for finding inverse of a matrix is shown below in the form of flowchart. In their approach, the following steps are involved:
1. Read nxn matrix A
2. Insert identity matrix into matrix A resulting to a expanded matrix A1 of size nx2n
3. Reduce the first nxn of the expanded matrix A1 to an identity matrix.
4. Extract the remaining nxn matrix as the inverse of matrix A, call this as AI.
Write a program to compute the solution of the problem stated above. Implement the program with subroutines and functions. The output of the program should be as shown below. Your program must declare subprograms, and the calls to those subprograms must pass parameters.
=====================================================
ASSIGNMENT FOUR
=====================================================
SOLUTION OF THE SIMULATANEOUS ALGEBRAIC EQUATIONS
BY
MATRIX INVERSION
SOLUTIONS:
x1 = - - - - - - - - - -
x2 = - - - - - - - - - - -
x3 = - - - - - - - - - - -
=====================================================
B. Test Data:
Verify your program by solving the following sets of equations:
(a) (b) (c)
7x1 - 8x2 + 5x3 = 5 4.5x1 - 2x2 + 3.5x3 = 6 5I1 - I2 - I3 = 11
-4x1 + 5x2 - 3x3 = -3 -2.5x1 + 6x2 + x3 = -5 -I1 + 5I2 - 2I3 = 0
x1 - x2 + x3 = 0 3x1 + 2x2 - x3 = 4 -I1 - I2 + 4I3 = 0
Solutions: x1 = 1.0 x1 = 1.398 I1 = 2.627
x2 = -1.0 x2 = -0.212 I2 = 0.985
x3 = -2.0 x3 = -0.213 I3 = 1.149