gsl_root_stef Class Template Reference

Steffenson equation solver (GSL). More...

#include <gsl_root_stef.h>

Inheritance diagram for gsl_root_stef:

root_de root

Detailed Description

template<class param_t, class func_t, class dfunc_t>
class gsl_root_stef< param_t, 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.

      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 ($ \mathrm{root} $) to the previous value ($ \mathrm{x} $), and returns success if $ | \mathrm{root} - \mathrm{x} | < \mathrm{tol} $, where $ \mathrm{tol} = \mathrm{tolx} + \mathrm{tolf2}~\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::tolf.

The original variable x_2 has been removed as it was unused in the original GSL code.

Idea for future:
There's some extra copying here which can probably be removed.
Idea for future:
Compare directly to GSL.

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 $ 10^{-12} $).
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.

Member Function Documentation

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.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page