Nonlinear solvers: Newton method.
More...
Nonlinear solvers: Newton method.
|
template<class Scalar , class ResFunc , class DerivFunc , typename std::enable_if_t< std::is_invocable_r_v< Scalar, ResFunc, Scalar > &&std::is_invocable_r_v< Scalar, DerivFunc, Scalar > > ...> |
Scalar | Dumux::findScalarRootNewton (Scalar xOld, const ResFunc &residual, const DerivFunc &derivative, const Scalar tol=1e-13, const int maxIter=200) |
| Newton's root finding algorithm for scalar functions (secant method) More...
|
|
template<class Scalar , class ResFunc , typename std::enable_if_t< std::is_invocable_r_v< Scalar, ResFunc, Scalar > > ...> |
Scalar | Dumux::findScalarRootNewton (Scalar xOld, const ResFunc &residual, const Scalar tol=1e-13, const int maxIter=200) |
| Newton's root finding algorithm for scalar functions (secant method) More...
|
|
template<class Scalar , class ResFunc , typename std::enable_if_t< std::is_invocable_r_v< Scalar, ResFunc, Scalar > > ...> |
Scalar | Dumux::findScalarRootBrent (Scalar a, Scalar b, const ResFunc &residual, const Scalar tol=1e-13, const int maxIter=200) |
| Brent's root finding algorithm for scalar functions. More...
|
|
◆ findScalarRootBrent()
template<class Scalar , class ResFunc , typename std::enable_if_t< std::is_invocable_r_v< Scalar, ResFunc, Scalar > > ...>
Scalar Dumux::findScalarRootBrent |
( |
Scalar |
a, |
|
|
Scalar |
b, |
|
|
const ResFunc & |
residual, |
|
|
const Scalar |
tol = 1e-13 , |
|
|
const int |
maxIter = 200 |
|
) |
| |
Brent's root finding algorithm for scalar functions.
- Note
- Modified from pseudo-code on wikipedia: https://en.wikipedia.org/wiki/Brent%27s_method
-
See also R.P. Brent "An algorithm with guaranteed convergence for finding a zero of a function", The Computer Journal (1971).
-
This is usually more robust than Newton's method
- Parameters
-
a | Lower bound |
b | Upper bound |
residual | Residual function |
tol | Relative shift tolerance |
maxIter | Maximum number of iterations |
◆ findScalarRootNewton() [1/2]
template<class Scalar , class ResFunc , class DerivFunc , typename std::enable_if_t< std::is_invocable_r_v< Scalar, ResFunc, Scalar > &&std::is_invocable_r_v< Scalar, DerivFunc, Scalar > > ...>
Scalar Dumux::findScalarRootNewton |
( |
Scalar |
xOld, |
|
|
const ResFunc & |
residual, |
|
|
const DerivFunc & |
derivative, |
|
|
const Scalar |
tol = 1e-13 , |
|
|
const int |
maxIter = 200 |
|
) |
| |
Newton's root finding algorithm for scalar functions (secant method)
- Parameters
-
xOld | initial guess |
residual | Residual function |
derivative | Derivative of the residual |
tol | Relative shift tolerance |
maxIter | Maximum number of iterations |
◆ findScalarRootNewton() [2/2]
template<class Scalar , class ResFunc , typename std::enable_if_t< std::is_invocable_r_v< Scalar, ResFunc, Scalar > > ...>
Scalar Dumux::findScalarRootNewton |
( |
Scalar |
xOld, |
|
|
const ResFunc & |
residual, |
|
|
const Scalar |
tol = 1e-13 , |
|
|
const int |
maxIter = 200 |
|
) |
| |
Newton's root finding algorithm for scalar functions (secant method)
- Note
- The derivative is numerically computed. If the derivative is know use signature with derivative function.
- Parameters
-
xOld | initial guess |
residual | Residual function |
tol | Relative shift tolerance |
maxIter | Maximum number of iterations |