Maths › Optimization ›
Brent
Calculates the minimum of a one-dimensional real function using Brent's method.
Controller: CodeCogs
Contents
Interface
C++
Brent
doublebrent( | double | (*f)(double)[function pointer] | |
double | a | ||
double | b | ||
double | c | ||
double | eps = 1E-10 | ||
int | maxit = 1000 | ) |
MISSING IMAGE!
1/brent-378.png cannot be found in /users/1/brent-378.png. Please contact the submission author.
Example 1
#include <codecogs/maths/optimization/brent.h> #include <iostream> #include <iomanip> #include <cmath> // user-defined function double f(double x) { return x * sin(x) - 2 * cos(x); } int main() { double x = Maths::Optimization::brent(f, 4, 5, 6); std::cout << "Function minimum is Y = " << std::setprecision(13) << f(x); std::cout << std::endl; std::cout << "for X = " << x << std::endl; return 0; }
Output
Function minimum is Y = -5.534528774008 for X = 5.232938450552
References:
- GNU Scientific Library, Reference Manual, http://nereida.deioc.ull.es/html/gsl/gsl-ref_24.html
Parameters
f the user-defined function a the first point of the bracketing triplet b the second point of the triplet c the third point of the triplet eps Default value = 1E-10 maxit Default value = 1000
Returns
- The approximated abscissa coresponding to the minimum of the function.
Authors
- Lucian Bentea (August 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.