A c++ class to find roots of a system of non-linear equations

565 views
Skip to first unread message

Dilawar Singh

unread,
Apr 14, 2016, 5:47:09 AM4/14/16
to wncc...@googlegroups.com
In short,

It does the same thing as GNU-gsl `gnewton` solver for finding roots of a system of non-linear system.

The standard caveats apply when finding the multi-dimensional roots.
https://bestw.gnu.org/software/gsl/manual/html_node/Multidimensional-Root_002dFinding.html#Multidimensional-Root_002dFinding

The templated class (must be compiled with  -std=c++11). It uses boost::numeric::ublas library.

The code is available here:

    https://github.com/dilawar/algorithms/tree/master/RootFinding

The header file contains the class, file `test_root_finding.cpp` shows how to use it.

best,
    Dilawar

Kumar Ayush

unread,
Apr 20, 2016, 4:29:46 AM4/20/16
to wncc...@googlegroups.com
Hey

That is some beautiful piece of code. I could not compile it as I don't have BLAS.

In any case, I have a suggestion for your newton-raphson function. It might be helpful to scale the tolerance by the largest coefficient in your equation. In that case, you can lower the initial tolerance to the machine epsilon.
although that code is just for sqrt using newton-raphson.

Regards
Ayush

--
--
The website for the club is http://wncc-iitb.org/
To post to this group, send email to wncc...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dilawar Singh

unread,
Apr 20, 2016, 4:45:23 AM4/20/16
to wncc...@googlegroups.com
Thanks. I am now using std::limits to get the machine epsilon and using it to compute the step size (sqrt( eps )) instead of using the fixed 1e-7 which is too small for 32 bit machines. Library ublas is part of boost-math. On some systems, this solver is not doing a great job (does not converge to a solution while gsl solver always does). As far as I can tell, the implementation is quite the same. I've added one more example in cpp file. 

best,
    Dilawar
Reply all
Reply to author
Forward
0 new messages