newton_root_finder< Function > Class Template Reference

#include <newton.h>

Inheritance diagram for newton_root_finder< Function >:

iterative_method

List of all members.

Public Member Functions

 newton_root_finder (Function &f, Function &d, unsigned int iterations=100, double relative_error=1.0e-15)
double find_root (double x0)


Detailed Description

template<class Function>
class newton_root_finder< Function >

This class provides the means to find roots of functions using the Newton's method. For example, to find roots for sine:
typedef double function(double);
 num::newton_root_finder<function> finder(std::sin);

find the root around 3.
 double pi = finder.find_root(3.0);

find the root around 1.
 double zero = finder.find_root(1.0);

References:

  1. Eric W. Weisstein. "Newton's Method." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/NewtonsMethod.html

Constructor & Destructor Documentation

template<class Function>
newton_root_finder< Function >::newton_root_finder ( Function &  f,
Function &  d,
unsigned int  iterations = 100,
double  relative_error = 1.0e-15 
) [inline]

Create a root finder with the given function and derivative functor.

Parameters:
f the function functor.
d the derivative functor.
iterations the maximum number of iterations.
relative_error the maximum allowable relative error.


Member Function Documentation

template<class Function>
double newton_root_finder< Function >::find_root ( double  x0  )  [inline]

Find a root of the target function that lies around the approximation, x0.

Parameters:
x0 an initial approximation to the root.
Returns:
a root that lies close to x0.


The documentation for this class was generated from the following file:
Generated on Wed Nov 21 22:22:16 2007 for numerics4c++ by  doxygen 1.5.3