Maths › Rootfinding ›
Brent
Calculates the zeros of a function using Brent's method.
Controller: CodeCogs
Contents
Interface
C++
Brent
doublebrent( | double | (*f)(double)[function pointer] | |
double | x1 = -1E+7 | ||
double | x2 = 1E+7 | ||
double | eps = 1E-10 | ||
int | maxit = 1000 | ) |
References:
- Jean-Pierre Moreau's Home Page, http://perso.wanadoo.fr/jean-pierre.moreau/
- MathWorld, http://mathworld.wolfram.com/BrentsMethod.html
Example 1
#include <codecogs/maths/rootfinding/brent.h> #include <iostream> #include <iomanip> // user-defined function double f(double x) { return (x + 1) * (x + 1) * (x + 1); } int main() { double x = Maths::RootFinding::brent(f, -3, 0); std::cout << "The calculated zero is X = " << std::setprecision(12) << x << std::endl; std::cout << "The associated ordinate value is Y = " << f(x) << std::endl; return 0; }
Output:The calculated zero is X = -0.999999878599 The associated ordinate value is Y = 1.78923630993e-021
Parameters
f the user-defined function x1 Default value = -1E+7 x2 Default value = 1E+7 eps Default value = 1E-10 maxit Default value = 1000
Authors
- Lucian Bentea (August 2005)
Source Code
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.