Solves a system of 4 linear equations with 4 variables.

**Enter the augmented matrix of the system: **

This JavaScript program solves a linear system of equations represented by an augmented system matrix. For example, the augmented matrix:

0 | 2 | 4 | : | 16 |

0 | 4 | 1 | : | 11 |

5 | 2 | 0 | : | 9 |

represents the following system of linear equations:

2y | + | 4z | = | 16 | ||

4y | + | z | = | 11 | ||

5x | + | 2y | = | 9 |

On completion of the algorithm, the augmented matrix would be transformed to:

1 | 0 | 0 | : | 1 |

0 | 1 | 0 | : | 2 |

0 | 0 | 1 | : | 3 |

which means that the solution to the system of equations is

x = 1, y = 2, z = 3. |

To operate the solver, enter the elements of the augmented matrix into the cells above. Press the [** Initialize **] key set the state of the solver to the starting value. Press the [** Single Step **] key to advance through each step of the algorithm. The [** Test **] key loads a test case to demonstrate how the calculator works.

If the algorithm determines that the system is singular, having no solution, a pop-up message will be displayed. The algorithm will not advance any further.

The Java Script source code for this program can be viewed by using the **View|Source** command of your web browser.

You may use or modify this source code in any way you find useful, provided that you agree that the author has no warranty, obligations or liability. You must determine the suitablility of this source code for your use.

The Gauss-Jordan method enables us to solve a set of linear equations. It is done by manipulating an augmented system matrix using elementary row operations to put the matrix into reduced row echelon form. The following criteria apply:

- The first non-zero number in the row is 1.
- Any rows entirely made up of zeros are grouped at the bottom of the matrix.
- The leading 1 in a lower row occurs farther to the right that the leading 1 in a higher row.
- Each column containing a leading 1 has zeros everywhere else.

The Gauss-Jordan algorithm performs operations to arrange the system matrix to meet the above criteria. This allows the solution to be found by inspection. All that remains in the matrix is a main diagonal of ones and the augmentation column. Since the matrix is representing the coefficients of the system variables, the augmentation column represents the values of each of those variables.

Gauss-Jordan Elimination Algorithm:

- Start at the first diagonal element.
- Check for a zero in the current diagonal element
*a*(*i*,*i*). If it is zero, interchange the current row with the first row beneath it in which the element in the same column is not zero. - Zeroize each element
*a*(*j*,*i*) below the current diagonal element*a*(*i*,*i*) by applying the following to each element of row (*j*):*a*(*j*,*k*) ←*a*(*j*,*k*) −*m*×*a*(*i*,*k*)

where

*m*=*a*(*j*,*i*) /*a*(*i*,*i*) - Move to the next diagonal element.
- Repeat steps 2 . . . 4 until the last element in the diagonal is done.
- Now start at the last diagonal element.
- Zeroize each element
*a*(*j*,*i*) above the current diagonal element*a*(*i*,*i*) using the method of step 3. - Move to the previous diagonal element.
- Repeat steps 7 . . . 8 until the first diagonal element is reached.
- Now start at the first diagonal element.
- Normalize each element in the row (
*i*) by multiplying by:*m*= 1 /*a*(*i*,*i*) - Move to the next diagonal element.
- Repeat steps 11 . . . 12 until the last element in the diagonal is done.

Copyright © 2004, Stephen R. Schmitt