Class root_stef (o2scl)¶
-
template<class func_t = funct, class dfunc_t = func_t>
class root_stef : public o2scl::root_de<funct, funct>¶ Steffenson equation solver (GSL)
This is Newton’s method with an Aitken “delta-squared” acceleration of the iterates. This can improve the convergence on multiple roots where the ordinary Newton algorithm is slow.
Defining the next iteration with
\[ x_{i+1} = x_i - f(x_i) / f^{\prime}(x_i) \]the accelerated value is\[ x_{\mathrm{acc},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, o2scl::root_brent_gsl, o2scl::root_bkt_cern, or o2scl::root_cern. 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 ( \( \mathrm{root} \)) to the previous value ( \( \mathrm{x} \)), and returns success if \( | \mathrm{root} - \mathrm{x} | < \mathrm{tol} \), where \( \mathrm{tol} = \mathrm{tol\_abs} + \mathrm{tol\_rel2}~\mathrm{root} \) .
If test_residual is set to true, then the solver additionally requires that the absolute value of the function is less than root::tol_rel.
The original variable
x_2
has been removed as it was unused in the original GSL code.See the One-dimensional solvers section of the User’s guide for general information about O2scl solvers.
Todo
class root_stef
Future:
There’s some extra copying here which can probably be removed.
Compare directly to GSL
This can probably be modified to shorten the step if the function goes out of bounds as in exc_mroot_hybrids.
Public Functions
-
inline root_stef()¶
-
inline virtual const char *type()¶
Return the type,
"root_stef"
.
-
inline int iterate()¶
Perform an iteration.
After a successful iteration, root contains the most recent value of the root.