Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Examples of Root-Finding (with and without derivatives)

Finding the Cubed Root With and Without Derivatives
Using C++11 Lambda's
Computing the Fifth Root
Root-finding using Boost.Multiprecision
Generalizing to Compute the nth root
A More complex example - Inverting the Elliptic Integrals

The examples demonstrate how to use the various tools for root finding.

We start with the simple cube root function cbrt ( C++ standard function name cbrt) showing root finding without derivatives.

We then show how use of derivatives can improve the speed of convergence.

(But these examples are only a demonstration and do not try to make the ultimate improvements of an 'industrial-strength' implementation, for example, of boost::math::cbrt, mainly by using a better computed initial 'guess' at cbrt.hpp).

Then we show how a higher root (fifth root) 5√ can be computed, and in root_finding_n_example.cpp a generic method for the nth root that constructs the derivatives at compile-time.

These methods should be applicable to other functions that can be differentiated easily.


PrevUpHomeNext