Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What good libraries are there for solving a system of non-linear equations in C++?

In a C++ application I'm coding, I need to solve a system of non-linear equations (N equations, N unknowns).

The systems I'm solving will be rather small (up to 10 equations/unknowns), so performance is not going to be a real issue. I've searched the web a bit for a non-linear solver library, and I couldn't get to something which looks easy to use (got to NOX and C/C++ Minpack, but both seem to be an overkill for my need).

Any thoughts and ideas of easy-to-use libraries for this purpose?

like image 483
hoffer Avatar asked Nov 20 '10 17:11

hoffer


4 Answers

One thing should be clear: non-linear equation solution isn't easy. It's not the same as solving linear equations. You aren't always guaranteed to get a solution. And your choice of initial condition and incrementation strategy can have a profound effect on the solution you do get.

With that said, I can't recommend a particular library, but you should be on the lookout for a linear algebra package that includes Newton-Raphson iteration in its menu of choices.

like image 58
duffymo Avatar answered Oct 24 '22 05:10

duffymo


There are two options for you, you can use the sundials packages which includes a nonlinear solver, written in C I think. The only problem I've found with it is that you need to give it good initial estimates. The second option is to use NLEQ or NLEQ2 which I think are superior (writtein in FORTRAN but easy to link to C like langages. However I have had some problems locating it just now. There is a good web site with a list of possible options at: http://plato.asu.edu/sub/zero.html

like image 35
rhody Avatar answered Oct 24 '22 04:10

rhody


Numerical Recipes has a routine that will do the job for you.

like image 1
David Heffernan Avatar answered Oct 24 '22 04:10

David Heffernan


It depends on how non-linear the equations are. If they possess some "nice" properties...most obvious being positive-semi-definite matrix or convexity, there may be specialized algorithms available. I use IBM/ILOG CPLEX for most of my linear programming needs. Libraries are provided that can be pulled into C++ applications. Although I have not used their quadratic programming module, it is really the state-of-the-art in high horse-power linear and (well-behaved) non-linear programming.

like image 1
Tryer Avatar answered Oct 24 '22 04:10

Tryer