

EquationsSolverForm.resx - Form resources.EquationsSolverForm.cs - The main form class that hosts controls.csEquationsSolver.ico - Stores several sizes of icons for the application.ComparableTuple2.cs - Use by the sparse 2 dimensional matrix to store indices.Sparse2DMatrix.cs - A sparse 2 dimensional matrix.LinearEquationSolver.cs - Solve the matrix equations.LinearEquationParserStatusInterpreter.cs - Provides text messages based on parser status values.LinearEquationParser.cs - Parses the equations to populate a matrix and a vector and saves a list of the variable names.
Matrix solve system of equations solver code#
This code is slower because it's not C, but it is still very fast.
Matrix solve system of equations solver Pc#
Today, with that original C code, a problem that size on a PC runs in theīlink of an eye. In the late 1970s, I ran this algorithm on a DEC-10 computer and solved 1000Įquations with 1000 variables in about 30 seconds. The SparseArray and Sparse2DMatrix are in another codeproject article I posted earlier that also provides other higher-dimension sparse containers. I wrote this inįortran, C++ using simple arrays, again in C++ using a sparse container classes, and finally in C# using a SparseArray and a Sparse2DMatrix. I've rewritten this algorithm several times. This is done using both the matrix norms and a constant that is set based on the number of bits in the mantissa of a floating point number.

While this book gives a standard implementation of Gaussian Elimination with partial pivoting, as is taught in Computer Science Linear Algebra courses, this algorithm also determines whether an accurate solution can be found. I was lucky to stumble on this particular reference. Wilf, 1967, John Wiley and Sons, pages 65-93.Īn ill-conditioned set of equations is a set of equations that is either difficult or impossible to solve using the given floating point precision. Wilkinson, "Mathematical Methods For Digital Computers" Volume 2, Edited by Anthony Ralston and Herbert S. " The solution of ill-conditioned linear equations", by J. I needed a way to solve simultaneous equations, and I stumbled on the following book and algorithm: When I was in college, I wrote a circuit analysis program in Fortran. Once solved, trying to solve the equations again will fail because there are then 6 equations and only 3 variables! If one of the original equations is wrong, delete the solution, edit that equation, and use the Operations/Solve menu item to solve the equations again.

Below is the program immediately after solving three equations.
