Documentation API of the 'jhplot.math.num.root.BrentRootFinder' Java class
BrentRootFinder
jhplot.math.num.root

## Class BrentRootFinder

• `public class BrentRootFinderextends IterativeMethod`

Brent's method (1) for finding roots of functions.

For example, to find roots for sine, first a `Function` is defined:

` Function sine = new Function() {    public double evaluate(double x) {        return Math.sin(x);    }} }; `

Then, a Brent's method root finder is created with the above function:

` BrentRootFinder finder = new BrentRootFinder(sine); `

Lastly, locating roots is accomplished using the `findRoot(double, double)` method:

` // find the root between 3 and 4. double pi = finder.findRoot(3.0, 4.0);  // find the root between -1 and 1. double zero = finder.findRoot(-1.0, 1.0); `

References:

1. Wikipedia contributors, "Brent's method," Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/w/index.php?title=Brent%27s_method&oldid=132341223

• ### Nested classes/interfaces inherited from class jhplot.math.num.IterativeMethod

`IterativeMethod.IterativeState`
• ### Constructor Summary

Constructors
Constructor and Description
`BrentRootFinder(Function f)`
Create a root finder for the given function.
`BrentRootFinder(Function f, int iterations, double error)`
Create a root finder for the given function.
• ### Method Summary

All Methods
Modifier and TypeMethod and Description
`double``findRoot(double min, double max)`
Find a root of the target function that lies between the two initial approximations, x0 and x1.
`Function``getFunction()`
Access the target function.
`void``setFunction(Function f)`
Modify the target function.
• ### Methods inherited from class jhplot.math.num.IterativeMethod

`getMaximumIterations, getMaximumRelativeError, iterate, setMaximumIterations, setMaximumRelativeError`
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### BrentRootFinder

`public BrentRootFinder(Function f)`
Create a root finder for the given function.
Parameters:
`f` - the target function.
• #### BrentRootFinder

`public BrentRootFinder(Function f,                       int iterations,                       double error)`
Create a root finder for the given function.
Parameters:
`f` - the target function.
`iterations` - maximum number of iterations.
`error` - maximum relative error.
• ### Method Detail

• #### findRoot

`public double findRoot(double min,                       double max)                throws NumericException`
Find a root of the target function that lies between the two initial approximations, x0 and x1.
Parameters:
`min` - the lower bound of the search interval.
`max` - the upper bound of the search interval.
Returns:
a root that lies between min and max, inclusive.
Throws:
`NumericException` - if a root could not be found.
• #### getFunction

`public Function getFunction()`
Access the target function.
Returns:
the target function.
• #### setFunction

`public void setFunction(Function f)`
Modify the target function.
Parameters:
`f` - the new target function.

DMelt 1.2 © DataMelt by jWork.ORG

BrentRootFinder
jhplot.math.num.root

## Class BrentRootFinder

• `public class BrentRootFinderextends IterativeMethod`

Brent's method (1) for finding roots of functions.

For example, to find roots for sine, first a `Function` is defined:

` Function sine = new Function() {    public double evaluate(double x) {        return Math.sin(x);    }} }; `

Then, a Brent's method root finder is created with the above function:

` BrentRootFinder finder = new BrentRootFinder(sine); `

Lastly, locating roots is accomplished using the `findRoot(double, double)` method:

` // find the root between 3 and 4. double pi = finder.findRoot(3.0, 4.0);  // find the root between -1 and 1. double zero = finder.findRoot(-1.0, 1.0); `

References:

1. Wikipedia contributors, "Brent's method," Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/w/index.php?title=Brent%27s_method&oldid=132341223

Warning: You cannot see the full API documentation of this class since the access to the DatMelt documentation for third-party Java classes is denied. Guests can only view jhplot Java API. To view the complete description of this class and its methods, please request the full DataMelt membership.

If you are already a full member, please login to the DataMelt member area before visiting this documentation.