UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Zero-Finding Algorithms

Algorithms for root-finding in mathematical functions. More...

Classes

class  Utils::Bracket_base_fun< Real >
 Abstract base class for defining mathematical functions used in the Bracket search algorithm. More...
 
class  Utils::AlgoBracket< Real >
 Class for solving \( f(x)=0 \) without the usew of derivative. More...
 
class  Utils::AlgoHNewton_base_fun< Real >
 Abstract base class for defining mathematical functions used in the zero search algorithm. More...
 
class  Utils::AlgoHNewton< Real >
 Class for solving \( f(x)=0 \) without the usew of derivative. More...
 
class  Utils::Sturm< Real >
 Class for managing and computing the Sturm sequence associated with a polynomial. More...
 
class  Utils::Zeros_base_fun< Real >
 Abstract base class for defining mathematical functions used in root-finding algorithms. More...
 
class  Utils::Zeros< Real >
 Class for solving the equation \( f(x) = 0 \) using various numerical methods. More...
 

Functions

virtual Real Utils::Zeros_base_fun< Real >::eval (Real x) const =0
 
virtual Real Utils::Zeros_base_fun< Real >::eval_D (Real x) const =0
 
virtual Real Utils::Zeros_base_fun< Real >::eval_DD (Real x) const =0
 
virtual Real Utils::Zeros_base_fun< Real >::eval_DDD (Real x) const =0
 
Real Utils::Zeros_base_fun< Real >::operator() (Real x) const
 
Real Utils::Zeros_base_fun< Real >::D (Real x) const
 
Real Utils::Zeros_base_fun< Real >::DD (Real x) const
 
Real Utils::Zeros_base_fun< Real >::DDD (Real x) const
 
 Utils::Zeros< Real >::Zeros ()=default
 
 Utils::Zeros< Real >::~Zeros ()=default
 
void Utils::Zeros< Real >::set_max_iterations (Integer mit)
 
void Utils::Zeros< Real >::set_max_fun_evaluation (Integer mfev)
 
void Utils::Zeros< Real >::set_tolerance (Real tol)
 
Real Utils::Zeros< Real >::solve_Newton (Real x_guess, Zeros_base_fun< Real > *fun)
 
Real Utils::Zeros< Real >::solve_Chebyshev (Real x_guess, Zeros_base_fun< Real > *fun)
 
Real Utils::Zeros< Real >::solve_Halley (Real x_guess, Zeros_base_fun< Real > *fun)
 
Real Utils::Zeros< Real >::solve_Order4 (Real x_guess, Zeros_base_fun< Real > *fun)
 
Real Utils::Zeros< Real >::solve_Order8 (Real x_guess, Zeros_base_fun< Real > *fun)
 
Real Utils::Zeros< Real >::solve_Order16 (Real x_guess, Zeros_base_fun< Real > *fun)
 
Real Utils::Zeros< Real >::solve_Order32 (Real x_guess, Zeros_base_fun< Real > *fun)
 
Integer Utils::Zeros< Real >::used_iter () const
 
Integer Utils::Zeros< Real >::num_fun_eval () const
 
Real Utils::Zeros< Real >::tolerance () const
 
bool Utils::Zeros< Real >::converged () const
 

Detailed Description

Algorithms for root-finding in mathematical functions.

This module implements a variety of efficient algorithms to compute the roots (zeros) of scalar functions, i.e., points where a function equals zero. It supports techniques ranging from simple bisection and secant methods to more advanced techniques like Newton-Raphson and Brent's method for solving nonlinear equations.

Function Documentation

◆ converged()

template<typename Real>
bool Utils::Zeros< Real >::converged ( ) const
inline
Returns
true if the last computation was successfull

◆ D()

template<typename Real>
Real Utils::Zeros_base_fun< Real >::D ( Real x) const
inline

Evaluate the first derivative of \( f(x) \)

This operator provides a convenient way to evaluate the first derivative using the call operator.

Parameters
[in]xthe point to evaluate \( f'(x) \)
Returns
the value of \( f'(x) \)

◆ DD()

template<typename Real>
Real Utils::Zeros_base_fun< Real >::DD ( Real x) const
inline

Evaluate the second derivative of \( f(x) \)

This operator allows for an easy evaluation of the second derivative using the call operator.

Parameters
[in]xthe point to evaluate \( f''(x) \)
Returns
the value of \( f''(x) \)

◆ DDD()

template<typename Real>
Real Utils::Zeros_base_fun< Real >::DDD ( Real x) const
inline

Evaluate the third derivative of \( f(x) \)

This operator enables straightforward evaluation of the third derivative using the call operator.

Parameters
[in]xthe point to evaluate \( f'''(x) \)
Returns
the value of \( f'''(x) \)

◆ eval()

template<typename Real>
virtual Real Utils::Zeros_base_fun< Real >::eval ( Real x) const
pure virtual

Evaluate the function \( f(x) \)

Parameters
[in]xthe point to evaluate \( f(x) \)
Returns
the value of \( f(x) \)

◆ eval_D()

template<typename Real>
virtual Real Utils::Zeros_base_fun< Real >::eval_D ( Real x) const
pure virtual

Evaluate the first derivative of \( f(x) \)

Parameters
[in]xthe point to evaluate \( f'(x) \)
Returns
the value of \( f'(x) \)

◆ eval_DD()

template<typename Real>
virtual Real Utils::Zeros_base_fun< Real >::eval_DD ( Real x) const
pure virtual

Evaluate the second derivative of \( f(x) \)

Parameters
[in]xthe point to evaluate \( f''(x) \)
Returns
the value of \( f''(x) \)

◆ eval_DDD()

template<typename Real>
virtual Real Utils::Zeros_base_fun< Real >::eval_DDD ( Real x) const
pure virtual

Evaluate the third derivative of \( f(x) \)

Parameters
[in]xthe point to evaluate \( f'''(x) \)
Returns
the value of \( f'''(x) \)

◆ num_fun_eval()

template<typename Real>
Integer Utils::Zeros< Real >::num_fun_eval ( ) const
inline
Returns
the number of evaluation used in the last computation

◆ operator()()

template<typename Real>
Real Utils::Zeros_base_fun< Real >::operator() ( Real x) const
inline

Evaluate the function \( f(x) \)

This operator allows for a more intuitive usage of the function object, enabling the evaluation of the function using the call operator.

Parameters
[in]xthe point to evaluate \( f(x) \)
Returns
the value of \( f(x) \)

◆ set_max_fun_evaluation()

template<typename Real>
void Utils::Zeros< Real >::set_max_fun_evaluation ( Integer mfev)

Fix the maximum number of evaluation.

Parameters
mfevthe maximum number of evaluation of \( f(x) \)

◆ set_max_iterations()

template<typename Real>
void Utils::Zeros< Real >::set_max_iterations ( Integer mit)

Fix the maximum number of iteration.

Parameters
mitthe maximum number of iteration

◆ set_tolerance()

template<typename Real>
void Utils::Zeros< Real >::set_tolerance ( Real tol)

Fix the requested tolerance for ieration stop. Stop when \( |f(x)| < \epsilon \)

Parameters
tolthe requested tolerance

◆ solve_Chebyshev()

template<typename Real>
Real Utils::Zeros< Real >::solve_Chebyshev ( Real x_guess,
Zeros_base_fun< Real > * fun )

Find the zero of a function wrapped in the class Zeros_base_fun<Real> starting from guess value x_guess.

Parameters
x_guessstarting value for iterative method
funthe pointer to base class Zeros_base_fun<Real> wrapping the user function

◆ solve_Halley()

template<typename Real>
Real Utils::Zeros< Real >::solve_Halley ( Real x_guess,
Zeros_base_fun< Real > * fun )

Find the zero of a function wrapped in the class Zeros_base_fun<Real> starting from guess value x_guess

Parameters
x_guessstarting value for iterative method
funthe pointer to base class Zeros_base_fun<Real> wrapping the user function

◆ solve_Newton()

template<typename Real>
Real Utils::Zeros< Real >::solve_Newton ( Real x_guess,
Zeros_base_fun< Real > * fun )

Find the zero of a function wrapped in the class Zeros_base_fun<Real> starting from guess value x_guess

Parameters
x_guessstarting value for iterative method
funthe pointer to base class Zeros_base_fun<Real> wrapping the user function

◆ solve_Order16()

template<typename Real>
Real Utils::Zeros< Real >::solve_Order16 ( Real x_guess,
Zeros_base_fun< Real > * fun )

Find the zero of a function wrapped in the class Zeros_base_fun<Real> starting from guess value x_guess

Parameters
x_guessstarting value for iterative method
funthe pointer to base class Zeros_base_fun<Real> wrapping the user function

◆ solve_Order32()

template<typename Real>
Real Utils::Zeros< Real >::solve_Order32 ( Real x_guess,
Zeros_base_fun< Real > * fun )

Find the zero of a function wrapped in the class Zeros_base_fun<Real> starting from guess value x_guess

Parameters
x_guessstarting value for iterative method
funthe pointer to base class Zeros_base_fun<Real> wrapping the user function

◆ solve_Order4()

template<typename Real>
Real Utils::Zeros< Real >::solve_Order4 ( Real x_guess,
Zeros_base_fun< Real > * fun )

Find the zero of a function wrapped in the class Zeros_base_fun<Real> starting from guess value x_guess

Parameters
x_guessstarting value for iterative method
funthe pointer to base class Zeros_base_fun<Real> wrapping the user function

◆ solve_Order8()

template<typename Real>
Real Utils::Zeros< Real >::solve_Order8 ( Real x_guess,
Zeros_base_fun< Real > * fun )

Find the zero of a function wrapped in the class Zeros_base_fun<Real> starting from guess value x_guess

Parameters
x_guessstarting value for iterative method
funthe pointer to base class Zeros_base_fun<Real> wrapping the user function

◆ tolerance()

template<typename Real>
Real Utils::Zeros< Real >::tolerance ( ) const
inline
Returns
the tolerance set for computation

◆ used_iter()

template<typename Real>
Integer Utils::Zeros< Real >::used_iter ( ) const
inline
Returns
the number of iterations used in the last computation

◆ Zeros()

template<typename Real>
Utils::Zeros< Real >::Zeros ( )
default

◆ ~Zeros()

template<typename Real>
Utils::Zeros< Real >::~Zeros ( )
default