<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://patrius.cnes.fr/index.php?action=history&amp;feed=atom&amp;title=User_Manual_4.15_Root-Finding_Algorithms</id>
	<title>User Manual 4.15 Root-Finding Algorithms - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://patrius.cnes.fr/index.php?action=history&amp;feed=atom&amp;title=User_Manual_4.15_Root-Finding_Algorithms"/>
	<link rel="alternate" type="text/html" href="https://patrius.cnes.fr/index.php?title=User_Manual_4.15_Root-Finding_Algorithms&amp;action=history"/>
	<updated>2026-04-05T19:54:22Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://patrius.cnes.fr/index.php?title=User_Manual_4.15_Root-Finding_Algorithms&amp;diff=3868&amp;oldid=prev</id>
		<title>Admin tsn : Page créée avec « __NOTOC__  == Introduction == === Scope === This section is about the root-finding algorithms for univariate real functions provided by the library. First we explain how t... »</title>
		<link rel="alternate" type="text/html" href="https://patrius.cnes.fr/index.php?title=User_Manual_4.15_Root-Finding_Algorithms&amp;diff=3868&amp;oldid=prev"/>
		<updated>2024-11-21T15:43:45Z</updated>

		<summary type="html">&lt;p&gt;Page créée avec « __NOTOC__  == Introduction == === Scope === This section is about the root-finding algorithms for univariate real functions provided by the library. First we explain how t... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__ &lt;br /&gt;
== Introduction ==&lt;br /&gt;
=== Scope ===&lt;br /&gt;
This section is about the root-finding algorithms for univariate real functions provided by the library.&lt;br /&gt;
First we explain how to use the root-finding algorithms.&lt;br /&gt;
Then a focus is made on the following root finding methods: Brent, Newton, Bisection and Müller.&lt;br /&gt;
&lt;br /&gt;
=== Javadoc ===&lt;br /&gt;
All solvers are in the following package :&lt;br /&gt;
[{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/package-summary.html fr.cnes.sirius.patrius.math.analysis.solver]&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
None as of now.&lt;br /&gt;
&lt;br /&gt;
=== Useful Documents ===&lt;br /&gt;
None as of now.&lt;br /&gt;
&lt;br /&gt;
=== Package Overview ===&lt;br /&gt;
The package &amp;lt;code&amp;gt;fr.cnes.sirius.patrius.math.analysis.solvers&amp;lt;/code&amp;gt; contains all the solvers described here.&lt;br /&gt;
&lt;br /&gt;
== Features Description ==&lt;br /&gt;
&lt;br /&gt;
=== About root finding ===&lt;br /&gt;
This library provides root-finding algorithms for real univariate functions.&lt;br /&gt;
The function for which a root is searched has to be provided as a [{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/UnivariateFunction.html UnivariateFunction].&lt;br /&gt;
The root-finding algorithm is implemented through the [{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/UnivariateSolver.html UnivariateSolver] interface.&lt;br /&gt;
&lt;br /&gt;
A very generic example would be :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = &amp;lt;some function&amp;gt;;&lt;br /&gt;
        UnivariateSolver solver = &amp;lt;some solver&amp;gt;;&lt;br /&gt;
        int numberOfEvals = 100;    &lt;br /&gt;
        double startInterval = 5.;&lt;br /&gt;
        double endInterval = 10.;&lt;br /&gt;
&lt;br /&gt;
        double root = solver.solve(numberOfEvals , f, startInterval , endInterval);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This means the solver with look for a root value of f in the interval [5. , 10.], and will have to do so in no more than 100 evaluation steps.&lt;br /&gt;
&lt;br /&gt;
==== Test functions ====&lt;br /&gt;
&lt;br /&gt;
We will demonstrate the use of root-finding algorithms with two test input functions : a periodic function and a linear function. These functions are defined as follows :&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;sinus function&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; : SinFunction &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class SinFunction implements DifferentiableUnivariateFunction {&lt;br /&gt;
&lt;br /&gt;
    public double value(double x) {&lt;br /&gt;
        return FastMath.sin(x);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public UnivariateFunction derivative() {&lt;br /&gt;
        return new UnivariateFunction() {&lt;br /&gt;
            public double value(double x) {&lt;br /&gt;
                return FastMath.cos(x);&lt;br /&gt;
            }&lt;br /&gt;
        };&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;linear function&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; : XMinus5Function &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class XMinus5Function implements DifferentiableUnivariateFunction {&lt;br /&gt;
&lt;br /&gt;
    public double value(double x) {&lt;br /&gt;
        return x- 5;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public UnivariateFunction derivative() {&lt;br /&gt;
        return new UnivariateFunction() {&lt;br /&gt;
            public double value(double x) {&lt;br /&gt;
                return 1.0;&lt;br /&gt;
            }&lt;br /&gt;
        };&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Available solvers ====&lt;br /&gt;
&lt;br /&gt;
The library provides around ten solvers, but the following have been more thoroughly tested :&lt;br /&gt;
* BrentSolver&lt;br /&gt;
* NewtonSolver&lt;br /&gt;
* BisectionSolver&lt;br /&gt;
* MullerSolver&lt;br /&gt;
&lt;br /&gt;
=== Brent method ===&lt;br /&gt;
The&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Brent&amp;#039;s method&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; is a root-finding algorithm combining the bisection method, the secant method and inverse quadratic interpolation. It has the reliability of bisection but it can be as quick as some of the less reliable methods. The idea is to use the secant method or inverse quadratic interpolation if possible, because they converge faster, but to fall back to the more robust bisection method if necessary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new SinFunction ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new BrentSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 3, 4);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = PI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new XMinus5Function ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new BrentSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 1, 2);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : NoBracketingException exception&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;u&amp;gt;behavior deteriorated in case of several roots in the interval&amp;lt;/u&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;u&amp;gt; :&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new SinFunction ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new BrentSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 1, 20);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = PI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new SinFunction ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new BrentSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 2, 20);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = 3 PI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new SinFunction ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new BrentSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 7, 20);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : NoBracketingException exception&lt;br /&gt;
&lt;br /&gt;
=== Newton method ===&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Newton&amp;#039;s method&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; (also known as the Newton–Raphson method) is a method for finding successively better approximations to the roots of a real-valued function. The idea of the method is as follows: one starts with an initial guess which is reasonably close to the true root, then the function is approximated by its tangent line, and one computes the x-intercept of this tangent line. This x-intercept will typically be a better approximation to the function&amp;#039;s root than the original guess, and the method can be iterated.&lt;br /&gt;
&lt;br /&gt;
IMPORTANT : the Newton solver only works for differentiable functions, this is reflected in the interface and class inheritances.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        DifferentiableUnivariateFunction f = new XMinus5Function ();&lt;br /&gt;
        double r;&lt;br /&gt;
        DifferentiableUnivariateSolver solver = new NewtonSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 1, 6);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = 5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;u&amp;gt;aberrant behavior&amp;lt;/u&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;u&amp;gt; :&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        DifferentiableUnivariateFunction f = new SinFunction();&lt;br /&gt;
        double r;&lt;br /&gt;
        DifferentiableUnivariateSolver solver = new NewtonSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 1, 2);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r =- 4 PI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        DifferentiableUnivariateFunction f = new SinFunction();&lt;br /&gt;
        double r;&lt;br /&gt;
        DifferentiableUnivariateSolver solver = new NewtonSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 1, 3);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = PI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        DifferentiableUnivariateFunction f = new XMinus5Function ();&lt;br /&gt;
        double r;&lt;br /&gt;
        DifferentiableUnivariateSolver solver = new NewtonSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 5.1, 20);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = 5&lt;br /&gt;
&lt;br /&gt;
=== Bisection method ===&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;bisection method&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; is a root-finding method which repeatedly bisects an interval and then selects a subinterval in which a root must lie for further processing. It is a very simple and robust method, but it is also relatively slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new XMinus5Function ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new BisectionSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 3, 4);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = PI&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;u&amp;gt;behavior deteriorated&amp;lt;/u&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;u&amp;gt; :&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new XMinus5Function ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new BisectionSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 5.1, 20);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = 20 (the upper bound of the interval)&lt;br /&gt;
&lt;br /&gt;
=== Müller method ===&lt;br /&gt;
The&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Müller&amp;#039;s method&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; is based on the secant method, which constructs at every iteration a line through two points on the graph of f. Instead, Müller&amp;#039;s method uses three points, constructs the parabola through these three points, and takes the intersection of the x-axis with the parabola to be the next approximation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new XMinus5Function ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new MullerSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 1, 6);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : r = 5&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new XMinus5Function ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new MullerSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 2, 3);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : NoBracketingException exception&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
        UnivariateFunction f = new SinFunction ();&lt;br /&gt;
        double r;&lt;br /&gt;
        UnivariateSolver solver = new MullerSolver();&lt;br /&gt;
&lt;br /&gt;
        r = solver.solve(100, f, 1, 20);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Result : NoBracketingException exception&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
{{specialInclusion prefix=$theme_sub section=&amp;quot;GettingStarted&amp;quot;/}}&lt;br /&gt;
&lt;br /&gt;
== Contents ==&lt;br /&gt;
=== Interfaces ===&lt;br /&gt;
The library defines the following interfaces related to solvers:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Interface&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Summary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Javadoc&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;UnivariateSolver&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|Interface for a univariate solver&lt;br /&gt;
|[{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/UnivariateSolver.html ...]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;UnivariateDifferentiableSolver&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|Interface for a differentiable univariate real solver&lt;br /&gt;
|[{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/UnivariateDifferentiableSolver.html ...]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Classes ===&lt;br /&gt;
This section is about the following classes related to solvers :&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Class&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Summary&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Javadoc&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;BrentSolver&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|Brent solver implementation.&lt;br /&gt;
|[{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/BrentSolver.html ...]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;NewtonRaphsonSolver&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|Newton-Raphson solver implementation.&lt;br /&gt;
|[{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/NewtonRaphsonSolver.html ...]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;BisectionSolver&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|Bisection solver implementation.&lt;br /&gt;
|[{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/BisectionSolver.html ...]&lt;br /&gt;
|-&lt;br /&gt;
|&amp;#039;&amp;#039;&amp;#039;MullerSolver&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
|Müller solver implementation.&lt;br /&gt;
|[{{JavaDoc4.15}}/fr/cnes/sirius/patrius/math/analysis/solver/MullerSolver.html ...]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== [[File:lightBulb.png]] Tips &amp;amp; Tricks ==&lt;br /&gt;
Summing up : the solvers appear to behave in unexpected ways when the initial conditions are not &amp;quot;ideal&amp;quot;. Therefore It is advised, when using the solvers, to :&lt;br /&gt;
&lt;br /&gt;
* avoid non-ideal initial conditions,&lt;br /&gt;
* read the solvers&amp;#039; javadoc carefully,&lt;br /&gt;
* always check if the solvers&amp;#039; results are appropriate.&lt;br /&gt;
&lt;br /&gt;
[[Category:User_Manual_4.15_Mathematics]]&lt;/div&gt;</summary>
		<author><name>Admin tsn</name></author>
	</entry>
</feed>