Solving System of Linear Equations
with Application to Matrix Inversion

This JavaScript E-labs learning object is intended for finding the solution to systems of linear equations up to three equations with three unknowns. It also allows us to find the inverse of a matrix.

Other JavaScript learning objects for decision making in this series are categorized under different areas of applications at the MENU section on this page.

Professor Hossein Arsham   


In entering your data to move from cell to cell in the data-matrix use the Tab key not arrow or enter keys.

Instructions and Applications:

  1. The unknown variable names are X1, X2, X3,..and X10, depending on if you have one equation, two equations, or three equations with one unknown, two unknown, or three unknown variables, respectively.

  2. Starting from left-upper corner, replace as many zeros, in the data-matrix with the coefficients of the unknown variables in the equations together with their right-hand-side values, as needed. The coefficient matrix must be a squared-matrix appearing on the upper left corner of the Data-Matrix, therefore, do not leave any blank rows in between.

  3. The JavaScript is based on the Gauss-Jordan (GJ) row operations. The requirement for GJ operations is that the first element in the coefficients-matrix must be non-zero. Therefore, first enter the coefficient of all equations having non-zero X1 coefficient; then enter all other equations. That is, any equation with zero coefficients for X1 must appear at the end of Data Entry Table.

    Numerical Example 1: Consider the following system of equations:

    X2 + X3 = 5
    3X1 + X3 = 6
    -X1 + X2 = 1

    The matrix of the coefficient of the variables is:

     0    1    1
     3    0    1
    -1    1    0

    The first entry of the first column is zero, while there is always at least one non-zero element therein. Therefore, we have to rearrange the system of equation in such a way that any equation with zero X1 coefficient appear among the last set of equations. That is, considering an equivalent system of equation:

    3X1 + X3 = 6
    -X1 + X2 = 1
    X2 + X3 = 5

    Solve this equivalent system of equation by entering its coefficient and the RHS values in the Data Entry Table, then click on the "Calculate" button. The output is the solution: X1 = 1, X2 = 2, and X3 = 3, which can be verified by substitutions.

  4. Finding the Matrix Inverse Using System of Equations Solver: To find the inverse of a square matrix of size n, solve n systems of equations with a unit vector as their right hand side. The following numerical example illustrates the process:

    Numerical Example 2: Suppose we wish to find the inverse (A-1) of the following matrix (if it exists) A:

    2   1
    A =
    1
    -1

    In general, to find the A-1, column by column, solve n systems of equations having the coefficient matrix A, however with n distinct identity vectors as their RHS value.

    For this numerical example, we have to solve the following two systems of equations:

    2X1 + X1 = 1
    X1 - X2 = 0

    and

    2X1 + X1 = 0
    X1 - X2 = 1

    Notice that the coefficient of the variables X1 and X2 are matrix A in both systems of equations, however the RHS are two identity vectors in n=2 dimensional space.

    The solutions, following the above instruction, of the first and second systems of equations provide the first and the second column of the A-1 matrix.

    To find the first column of A-1 solve:

    2X1 + X1 = 1
    X1 - X2 = 0

    This gives X1 = 1/3 , X2 = 1/3. To find the second column of A-1 solve:

    2X1 + X1 = 0
    X1 - X2 = 1

    This gives X1 = 1/3 , X2 = -2/3. Therefore, A-1p is

    1/3   1/3
    A-1 =
    1/3
    -2/3

  5. Notice: A matrix possessing an inverse is called nonsingular, or invertible. A matrix is called singular if it does not have an inverse. For example, the following matrix is a singular one:

     1    6    4
     2    4   -1
    -1    2    5

    Therefore, in applying the above procedure for inverting a matrix, if the matrix is a singular one, then at least of the systems of equations has no solution.

  6. To edit your data, including add/change/delete, you do not have to click on the "clear" button, and re-enter your data all over again. You may simply add, change a number to another in the same cell, or delete a number from a cell by setting its value to zero. After editing, then click the "calculate" button.

    This is helpful in, e.g. finding the inverse of A10x10 matrix, where we have to change the RHS values only.

    For extensive edit or to use the JavaScript for a new set of data, then use the "clear" button.


X1 X2 X3 X4 X5
X6
X7 X8 X9 x10 RHS

 
Solution Is:
X1
X2
X3
X4
X5
X6
X7
X8
X9
X10
 
 

 




For Technical Details, Back to:
Topics in Linear Algebra


Kindly email your comments to:
Professor Hossein Arsham


MENU

Decision Tools in Economics & Finance


Probabilistic Modeling

 
Statistics


The Copyright Statement: The fair use, according to the 1996 Fair Use Guidelines for Educational Multimedia, of materials presented on this Web site is permitted for non-commercial and classroom purposes only.
This site may be translated and/or mirrored intact (including these notices), on any server with public access. All files are available at http://home.ubalt.edu/ntsbarsh/Business-stat for mirroring.

Kindly e-mail me your comments, suggestions, and concerns. Thank you.

Professor Hossein Arsham   


Back to:

Dr Arsham's Home Page


EOF: © 1994-2015.