<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Examples of Root-Finding (with and without derivatives)</title> <link rel="stylesheet" href="../../math.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> <link rel="home" href="../../index.html" title="Math Toolkit 2.3.0"> <link rel="up" href="../roots.html" title="Root finding"> <link rel="prev" href="roots_deriv.html" title="Root Finding With Derivatives: Newton-Raphson, Halley & Schröder"> <link rel="next" href="root_finding_examples/cbrt_eg.html" title="Finding the Cubed Root With and Without Derivatives"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> <td align="center"><a href="../../../../../../index.html">Home</a></td> <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="roots_deriv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../roots.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="root_finding_examples/cbrt_eg.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="section"> <div class="titlepage"><div><div><h3 class="title"> <a name="math_toolkit.roots.root_finding_examples"></a><a class="link" href="root_finding_examples.html" title="Examples of Root-Finding (with and without derivatives)">Examples of Root-Finding (with and without derivatives)</a> </h3></div></div></div> <div class="toc"><dl> <dt><span class="section"><a href="root_finding_examples/cbrt_eg.html">Finding the Cubed Root With and Without Derivatives</a></span></dt> <dt><span class="section"><a href="root_finding_examples/lambda.html">Using C++11 Lambda's</a></span></dt> <dt><span class="section"><a href="root_finding_examples/5th_root_eg.html">Computing the Fifth Root</a></span></dt> <dt><span class="section"><a href="root_finding_examples/multiprecision_root.html">Root-finding using Boost.Multiprecision</a></span></dt> <dt><span class="section"><a href="root_finding_examples/nth_root.html">Generalizing to Compute the nth root</a></span></dt> <dt><span class="section"><a href="root_finding_examples/elliptic_eg.html">A More complex example - Inverting the Elliptic Integrals</a></span></dt> </dl></div> <p> The examples demonstrate how to use the various tools for <a href="http://en.wikipedia.org/wiki/Root-finding_algorithm" target="_top">root finding</a>. </p> <p> We start with the simple cube root function <code class="computeroutput"><span class="identifier">cbrt</span></code> ( C++ standard function name <a href="http://en.cppreference.com/w/cpp/numeric/math/cbrt" target="_top">cbrt</a>) showing root finding <a class="link" href="root_finding_examples/cbrt_eg.html#math_toolkit.roots.root_finding_examples.cbrt_eg.cbrt_no_derivatives">without derivatives</a>. </p> <p> We then show how use of derivatives can improve the speed of convergence. </p> <p> (But these examples are only a demonstration and do not try to make the ultimate improvements of an 'industrial-strength' implementation, for example, of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">cbrt</span></code>, mainly by using a better computed initial 'guess' at <a href="../../../../../../libs/math/include/boost/math/special_functions/cbrt.hpp" target="_top">cbrt.hpp</a>). </p> <p> Then we show how a higher root (<a class="link" href="root_finding_examples/5th_root_eg.html" title="Computing the Fifth Root">fifth root</a>) <sup>5</sup>√ can be computed, and in <a href="../../../../example/root_finding_n_example.cpp" target="_top">root_finding_n_example.cpp</a> a generic method for the <a class="link" href="root_finding_examples/nth_root.html" title="Generalizing to Compute the nth root">nth root</a> that constructs the derivatives at compile-time. </p> <p> These methods should be applicable to other functions that can be differentiated easily. </p> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno Lalande, John Maddock, Johan Råde, Gautam Sewani, Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="roots_deriv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../roots.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="root_finding_examples/cbrt_eg.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>