## Simultaneous Equation Solver |

This page contains a routine that numerically solves a system of N equations in N unknowns, where N may be up to 12 and the variables are real.

**References:**

Author: E. A. Voorhees, Los Alamos National Laboratory (LANL)

Dongarra, J. J.; J.R. Bunch; C.B. Moler; and G.W. Stewart.

"LINPACK User's Guide"

SIAM, Philadelphia

1979

The utility posted on this page is based on the program "SGEFS.F", written by E. A. Voorhees (LANL).

"SGEFS.F" is part of the SLATEC library of programs, and its original code (written in FORTRAN) can be viewed there.

Before being posted on this page, "SGEFS.F" was translated to Javascript and edited. Although all care was taken to ensure that it was translated accurately, some errors may have crept into the translation. These errors are mine; the original FORTRAN routines have been thoroughly tested and work properly. Please contact the webmaster to report any errors.

Consider a system of three equations in three unknowns, which takes the following form:

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

where the **a** and **b** values are known *constants*. Knowing these constants, the task is then to solve for the values of x that satisfy this system.

This system can be rearranged into matrix form:

**[A](x) = (b)**

where **[A]** is a square matrix and **(x)** and **(b)** are column vectors:

a_{11} |
a_{12} |
a_{13} |
||||||

[A] |
= | a_{21} |
a_{22} |
a_{23} |
||||

a_{31} |
a_{32} |
a_{33} |

x_{1} |
||||

(x) |
= | x_{2} |
||

x_{3} |

b_{1} |
||||

(b) |
= | b_{2} |
||

b_{3} |

**HOW TO USE THIS UTILITY**

(i) The first entry should be the dimension of the system, N (remember, N should not be greater than 12).

(ii) The next NxN entries should be the coefficients of the **A** Matrix.

The coefficients should be entered in the following order:

a_{11}, a_{12}, a_{13}, . . .

a_{21}, a_{22}, a_{23}, . . .

etc.

(iii) The next N entries should be the coefficients of the **b** vector: b_{1}, b_{2}, b_{3}, . . . etc.

Do not enter commas, periods, brackets, etc. Also note that numbers in scientific notation are NOT recognized.

For example, say we want to solve the following system:

1 x_{1} |
+ | 2 x_{2} |
+ | 3 x_{3} |
= | 7 |

2 x_{1} |
- | 1 x_{2} |
+ | 1 x_{3} |
= | 8 |

3 x_{1} |
+ | 4 x_{2} |
- | 1 x_{3} |
= | 9 |

Data input to the box should be as follows:

3 | ||

1 | 2 | 3 |

2 | -1 | 1 |

3 | 4 | -1 |

7 | 8 | 9 |

Once all the data has been entered, click the **Solve** button, and the values of **x** that solve the system will be computed.

**IMPORTANT**: Make sure that Error Code is greater than 0; if it is not, the solution is meaningless.

If Error Code > 0, it represents a rough estimate of the number of digits of accuracy in the solution, **(x)**.

If Error Code < 0, there are errors:

Error Code = -1: Fatal Error. **[A]** is computationally singular. No solution was computed.

Error Code = -2: Warning. Solution has no significance. The solution may be inaccurate, or **[A]** may be poorly scaled.

In addition, several other properties of **[A]** follow, for example,

rcond, which is an estimate of 1/cond(**A**),

the determinant of the **[A]** Matrix,

the LU Decomposition Matrices **[P]**, **[L]**, and **[U]** such that **[P][L][U]** = **[A]**,

and the inverse of the **[A]** Matrix (if non-singular).