UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Utils::Zeros_base_fun< Real > Class Template Referenceabstract

Abstract base class for defining mathematical functions used in root-finding algorithms. More...

#include <Utils_zeros.hh>

Public Member Functions

virtual Real eval (Real x) const =0
 
virtual Real eval_D (Real x) const =0
 
virtual Real eval_DD (Real x) const =0
 
virtual Real eval_DDD (Real x) const =0
 
Real operator() (Real x) const
 
Real D (Real x) const
 
Real DD (Real x) const
 
Real DDD (Real x) const
 

Detailed Description

template<typename Real>
class Utils::Zeros_base_fun< Real >

Abstract base class for defining mathematical functions used in root-finding algorithms.

This class serves as a base interface for user-defined functions that can be evaluated and differentiated. It allows for the implementation of various numerical methods to find the roots of the equation \( f(x) = 0 \). Users must inherit from this class and implement the virtual methods to define their specific functions.

The class provides methods to evaluate the function itself as well as its first, second, and third derivatives, which are essential for many root-finding algorithms such as Newton-Raphson and Halley methods.

Template Parameter:

  • Real: A numeric type representing the data type of the function's input and output, such as float, double, etc.

Usage Example: To create a custom function, derive from this class and implement the required methods. Here is an example for the function \( f(x) = x^2 - 2 \):

class Fun1 : public Zeros_base_fun<double> {
public:
double eval(double x) const override { return x*x - 2; }
double eval_D(double x) const override { return 2*x; }
double eval_DD(double x) const override { return 2; }
double eval_DDD(double x) const override { return 0; }
};
Abstract base class for defining mathematical functions used in root-finding algorithms.
Definition Utils_zeros.hh:87
virtual Real eval(Real x) const =0
virtual Real eval_D(Real x) const =0
virtual Real eval_DD(Real x) const =0
virtual Real eval_DDD(Real x) const =0

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