BrentSearch Class |
Namespace: Accord.Math.Optimization
The BrentSearch type exposes the following members.
Name | Description | |
---|---|---|
BrentSearch |
Constructs a new Brent search algorithm.
|
Name | Description | |
---|---|---|
Function |
Gets the function to be searched.
| |
LowerBound |
Gets or sets the lower bound for the search interval a.
| |
MaxIterations |
Gets or sets the maximum number of iterations that should be
performed before the method terminates. Default is 500.
| |
NumberOfVariables |
Gets the number of variables (free parameters)
in the optimization problem.
| |
Solution | ||
Status |
Gets the status of the search.
| |
Tolerance |
Gets or sets the tolerance margin when
looking for an answer. Default is 1e-6.
| |
UpperBound |
Gets or sets the lower bound for the search interval a.
| |
Value |
Gets the value at the solution found in the last call
to Minimize, Maximize,
Find(Double) or FindRoot.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Find(Double) |
Attempts to find a value in the interval [a;b]
| |
Find(FuncDouble, Double, Double, Double, Double, Double, Int32) |
Finds a value of a function in the interval [a;b]
| |
FindRoot |
Attempts to find a root in the interval [a;b]
| |
FindRoot(FuncDouble, Double, Double, Double, Double, Int32) |
Finds the root of a function in the interval [a;b]
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Maximize |
Finds the maximum of the function in the interval [a;b]
| |
Maximize(FuncDouble, Double, Double, Double, Double, Int32) |
Finds the maximum of a function in the interval [a;b]
| |
Minimize |
Finds the minimum of the function in the interval [a;b]
| |
Minimize(FuncDouble, Double, Double, Double, Double, Int32) |
Finds the minimum of a function in the interval [a;b]
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
In numerical analysis, Brent's method is a complicated but popular 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. Brent's method is due to Richard Brent (1973) and builds on an earlier algorithm of Theodorus Dekker (1969).
The algorithms implemented in this class are based on the original C source code available in Netlib (http://www.netlib.org/c/brent.shar) by Oleg Keselyov, 1991.
References:
The following example shows how to compute the maximum, minimum and a single root of a univariate function.
// Suppose we were given the function x³ + 2x² - 10x + 1 and // we have to find its root, maximum and minimum inside // the interval [-4, 2]. First, we express this function // as a lambda expression: Func<double, double> function = x => x * x * x + 2 * x * x - 10 * x + 1; // And now we can create the search algorithm: BrentSearch search = new BrentSearch(function, -4, 2); // Finally, we can query the information we need bool success1 = search.Maximize(); // should be true double max = search.Solution; // occurs at -2.61 bool success2 = search.Minimize(); // should be true double min = search.Solution; // occurs at 1.28 bool success3 = search.FindRoot(); // should be true double root = search.Solution; // occurs at 0.10 double value = search.Value; // should be zero