Object-oriented Scientific Computing Library: Version 0.910
Public Member Functions | Data Fields | Protected Attributes
gsl_root_stef< func_t, dfunc_t > Class Template Reference

Steffenson equation solver (GSL) More...

#include <gsl_root_stef.h>

Inheritance diagram for gsl_root_stef< func_t, dfunc_t >:
root_de< func_t, dfunc_t > root< func_t >

Detailed Description

template<class func_t, class dfunc_t = func_t>
class gsl_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

\[ 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, 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{tol\_abs} + \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::tol_rel.

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.
Idea for Future:
This can probably be modified to shorten the step if the function goes out of bounds as in gsl_mroot_hybrids.

Definition at line 104 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, 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)
 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.

Member Function Documentation

template<class func_t , class dfunc_t = func_t>
int gsl_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 gsl_root_stef.h.

template<class func_t , class dfunc_t = func_t>
int gsl_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 277 of file gsl_root_stef.h.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.