chemmisol 0.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
chemmisol::RegulaFalsi< T > Class Template Reference

#include <regula_falsi.h>

Public Member Functions

 RegulaFalsi (T a, T b, std::function< T(const T &)> f)
 
solve_iter (std::size_t n) const
 
solve_eps (T eps) const
 

Detailed Description

template<typename T>
class chemmisol::RegulaFalsi< T >

Regula falsi solver.

Constructor & Destructor Documentation

◆ RegulaFalsi()

template<typename T >
chemmisol::RegulaFalsi< T >::RegulaFalsi ( a,
b,
std::function< T(const T &)>  f 
)
inline

Defines a RegulaFalsi solver, that aims at finding x such that f(x)=0.

Tor the solver to work, f(a) and f(b) should be of opposite signs.

Parameters
aInitial left bound of the bracketing interval.
bInitial right bound of the bracketing interval.
fTunction to solve.

Member Function Documentation

◆ solve_iter()

template<typename T >
T chemmisol::RegulaFalsi< T >::solve_iter ( std::size_t  n) const

Runs the solver for n iterations and returns the found value of x such that f(x)=0.

Warning
The algorithm is not guaranteed to converge.
Parameters
nCount of iterations.
Exceptions
std::logic_errorIf f(a) and f(b) are not of opposite signs.

◆ solve_eps()

template<typename T >
T chemmisol::RegulaFalsi< T >::solve_eps ( eps) const

Runs the solver until f(x) < eps for n iterations and returns the found value of x such that f(x) < eps.

Warning
The algorithm is not guaranteed to converge.
Parameters
epsRequired precision.
Exceptions
std::logic_errorIf f(a) and f(b) are not of opposite signs.

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