o2scl::root_stef< func_t, dfunc_t > Class Template Reference

Steffenson equation solver (GSL) More...

#include <root_stef.h>

Inheritance diagram for o2scl::root_stef< func_t, dfunc_t >:

## Public Member Functions

virtual const char * type ()
Return the type, "root_stef".

int iterate ()
Perform an iteration. More...

virtual int solve_de (double &xx, func_t &fun, dfunc_t &dfun)
Solve func using x as an initial guess using derivatives df.

void set (func_t &fun, dfunc_t &dfun, double guess)
Set the information for the solver. More...

Public Member Functions inherited from o2scl::root_de< func_t, dfunc_t >
virtual int solve_bkt (double &x1, double x2, func_t &func)
Solve func in region returning .

virtual int solve (double &x, func_t &func)
Solve func using x as an initial guess.

Public Member Functions inherited from o2scl::root< func_t >
virtual int print_iter (double x, double y, int iter, double value=0.0, double limit=0.0, std::string comment="")
Print out iteration information. More...

virtual int solve_de (double &x, func_t &func, func_t &df)
Solve func using x as an initial guess using derivatives df.

## Public Attributes

double root
The present solution estimate.

double tol_rel2
The relative tolerance for subsequent solutions (default )

bool test_residual
True if we should test the residual also (default false)

Public Attributes inherited from o2scl::root< func_t >
double tol_rel
The maximum value of the functions for success (default )

double tol_abs
The minimum allowable stepsize (default )

int verbose
Output control (default 0)

int ntrial
Maximum number of iterations (default 100)

bool err_nonconv
If true, call the error handler if the solver does not converge (default true)

int last_ntrial
The number of iterations used in the most recent solve.

## 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.

## Detailed Description

### template<class func_t = funct11, class dfunc_t = func_t> class o2scl::root_stef< func_t, dfunc_t >

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

the accelerated value is

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 ( ) 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::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.

Idea for 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.

Definition at line 109 of file root_stef.h.

## ◆ iterate()

template<class func_t = funct11, class dfunc_t = func_t>
 int o2scl::root_stef< func_t, dfunc_t >::iterate ( )
inline

After a successful iteration, root contains the most recent value of the root.

Definition at line 158 of file root_stef.h.

## ◆ set()

template<class func_t = funct11, class dfunc_t = func_t>
 void o2scl::root_stef< func_t, dfunc_t >::set ( func_t & fun, dfunc_t & dfun, double guess )
inline

Set the function, the derivative, the initial guess and the parameters.

Definition at line 274 of file root_stef.h.

The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).