#include <gsl_root_stef.h>
x[i+1] = x[i] - f(x[i]) / f'(x[i])
x_accelerated[i] = x[i] - (x[i+1] - x[i])**2 / (x[i+2] - 2*x[i+1] + x[i])
We can only use the accelerated estimate after three iterations, and use the unaccelerated value until then.
This class finds a root of a function a derivative. If the derivative is not analytically specified, it is most likely preferable to use of the alternatives, gsl_root_brent, cern_root, or cern_mroot_root. The function solve_de() performs the solution automatically, and a lower-level GSL-like interface with set() and iterate() is also provided.
By default, this solver compares the present value of the root () to the previous value (
), and returns success if
, where
.
If test_residual is set to true, then the solver additionally requires that the absolute value of the function is less than root::tolf.
The original variable x_2
has been removed as it was unused in the original GSL code.
Definition at line 99 of file gsl_root_stef.h.
Public Member Functions | |
virtual const char * | type () |
Return the type, "gsl_root_stef" . | |
int | iterate () |
Perform an iteration. | |
virtual int | solve_de (double &xx, param_t &pa, func_t &fun, dfunc_t &dfun) |
Solve func using x as an initial guess using derivatives df . | |
int | set (func_t &fun, dfunc_t &dfun, double guess, param_t &pa) |
Set the information for the solver. | |
Data Fields | |
double | root |
The present solution estimate. | |
double | tolf2 |
The relative tolerance for subsequent solutions (default ![]() | |
bool | test_residual |
True if we should test the residual also (default false). | |
Protected Attributes | |
double | f |
Function value. | |
double | df |
Derivative value. | |
double | x_1 |
Previous value of root. | |
double | x |
Root. | |
int | count |
Number of iterations. | |
func_t * | fp |
The function to solve. | |
dfunc_t * | dfp |
The derivative. | |
param_t * | params |
The function parameters. |
int iterate | ( | ) | [inline] |
After a successful iteration, root contains the most recent value of the root.
Definition at line 157 of file gsl_root_stef.h.
int set | ( | func_t & | fun, | |
dfunc_t & | dfun, | |||
double | guess, | |||
param_t & | pa | |||
) | [inline] |
Set the function, the derivative, the initial guess and the parameters.
Definition at line 275 of file gsl_root_stef.h.
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page