How should a programmer store and solve simultaneous algebraic equations?

584 Views Asked by At

I need to store and solve simultaneous algebraic equations (no trig, no calc, no logs) as part of a larger program. I am not yet committed to a particular language, so long as it's a free one. For solving, some have recommended Python, but it requires external libraries to do so. Perhaps another language would be able to handle such a task without outside help, which would be better/cleaner.

As far as storage goes, one could try to define an equation in terms of objects, or store them as strings, but I was wondering if there is anything more suited to the task.

2

There are 2 best solutions below

1
On BEST ANSWER

If by "simultaneous algebraic equations" you mean linear equations, then there is a standard approach using matrices. If they are not linear simultaneous equations, you have a problem.

Linear simultaneous equations are usually represented by a matrix (2D arrays). The process of solving such a set of equations requires you to find the inverse of the matrix. This is a somewhat tedious programming exercise, but if you understand matrices its not too difficult. (in fact inverting a 3x3 matrix is one of the exercises in http://www.cquestions.com/2011/09/c-program-to-find-inverse-of-matrix.html).

This wheel has been invented many, many times. If you search for "matrix inverse program" or similar you will find many standalone solutions, including http://www.codeproject.com/Questions/754429/C-Program-to-calculate-inverse-of-matrix-n-n

You save the simultaneous equation by saving the matrix, which is just an array.

If you are not familiar with the use of matrices to solve linear simultaneous equations, http://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html might be a good place to start.

0
On

I've used Sage for a few things, and it's been great. Maybe a bit overkill for storing and solving systems of equations, but it will most likely be able to get the job done. It's built around Python, but should include all the libraries you could ever want.

I've never used Sage for what you're describing, so your mileage may vary.