Root solver methods for:
Note
The default real kind (wp
) can be
changed using optional preprocessor flags.
This library was built with real kind:
real(kind=real64)
[8 bytes]
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | root_module_rk | = | real64 |
real kind used by this module [8 bytes] |
integer, | private, | parameter | :: | wp | = | root_module_rk |
local copy of |
integer, | private, | parameter | :: | name_len | = | 32 |
max length of the method names |
real(kind=wp), | private, | parameter | :: | golden_ratio | = | (1.0_wp+sqrt(5.0_wp))/2.0_wp |
golden ratio |
type(root_method), | public, | parameter | :: | root_method_null | = | root_method(0, '') |
enum type for an invalid method |
type(root_method), | public, | parameter | :: | root_method_brent | = | root_method(1, 'brent') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_bisection | = | root_method(2, 'bisection') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_regula_falsi | = | root_method(3, 'regula_falsi') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_illinois | = | root_method(4, 'illinois') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_anderson_bjorck | = | root_method(5, 'anderson_bjorck') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_ridders | = | root_method(6, 'ridders') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_pegasus | = | root_method(7, 'pegasus') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_bdqrf | = | root_method(8, 'bdqrf') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_muller | = | root_method(9, 'muller') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_brenth | = | root_method(10, 'brenth') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_brentq | = | root_method(11, 'brentq') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_chandrupatla | = | root_method(12, 'chandrupatla') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_toms748 | = | root_method(13, 'toms748') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_zhang | = | root_method(14, 'zhang') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_anderson_bjorck_king | = | root_method(15, 'anderson_bjorck_king') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_blendtf | = | root_method(16, 'blendtf') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_barycentric | = | root_method(17, 'barycentric') |
enum type for |
type(root_method), | public, | parameter | :: | root_method_itp | = | root_method(18, 'itp') |
enum type for |
type(root_method), | public, | parameter, dimension(*) | :: | set_of_root_methods | = | [root_method_brent, root_method_bisection, root_method_regula_falsi, root_method_illinois, root_method_anderson_bjorck, root_method_ridders, root_method_pegasus, root_method_bdqrf, root_method_muller, root_method_brenth, root_method_brentq, root_method_chandrupatla, root_method_toms748, root_method_zhang, root_method_anderson_bjorck_king, root_method_blendtf, root_method_barycentric, root_method_itp] |
list of the available methods (see root_scalar) |
Non-object-oriented wrapper.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | method |
the method to use |
||
procedure(func2) | :: | fun |
user function to find the root of |
|||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
||
real(kind=wp), | intent(in), | optional | :: | ftol |
absolute tolerance for |
|
real(kind=wp), | intent(in), | optional | :: | rtol |
relative tol for x |
|
real(kind=wp), | intent(in), | optional | :: | atol |
absolute tol for x |
|
integer, | intent(in), | optional | :: | maxiter |
maximum number of iterations |
|
real(kind=wp), | intent(in), | optional | :: | fax |
if |
|
real(kind=wp), | intent(in), | optional | :: | fbx |
if |
|
logical, | intent(in), | optional | :: | bisect_on_failure |
if true, then if the specified method fails,
it will be retried using the bisection method.
(default is False). Note that this can use up
to |
Non-object-oriented wrapper.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(root_method), | intent(in) | :: | method |
the method to use |
||
procedure(func2) | :: | fun |
user function to find the root of |
|||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
||
real(kind=wp), | intent(in), | optional | :: | ftol |
absolute tolerance for |
|
real(kind=wp), | intent(in), | optional | :: | rtol |
relative tol for x |
|
real(kind=wp), | intent(in), | optional | :: | atol |
absolute tol for x |
|
integer, | intent(in), | optional | :: | maxiter |
maximum number of iterations |
|
real(kind=wp), | intent(in), | optional | :: | fax |
if |
|
real(kind=wp), | intent(in), | optional | :: | fbx |
if |
|
logical, | intent(in), | optional | :: | bisect_on_failure |
if true, then if the specified method fails,
it will be retried using the bisection method.
(default is False). Note that this can use up
to |
Interface to the function to be minimized (Object-oriented version). It should evaluate f(x) for any x in the interval (ax,bx)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x |
independant variable |
f(x)
Interface to the function to be minimized (Functional version). It should evaluate f(x) for any x in the interval (ax,bx)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
independant variable |
f(x)
Root solver function interface
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag |
a type to define enums for the different methods
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private | :: | id | = | 0 |
unique ID code for the method |
|
character(len=name_len), | private | :: | name | = | '' |
name of the method |
abstract class for the root solver methods
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
procedure(func), | private, | pointer | :: | f | => | null() |
user function to find the root of |
real(kind=wp), | private | :: | ftol | = | 0.0_wp |
absolute tolerance for |
|
real(kind=wp), | private | :: | rtol | = | 1.0e-6_wp |
relative tol for x |
|
real(kind=wp), | private | :: | atol | = | 1.0e-12_wp |
absolute tol for x [not used by all methods] |
|
integer, | private | :: | maxiter | = | 2000 |
maximum number of iterations [not used by all methods] |
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure(root_f), private, deferred :: find_root | root solver function. Meant to be called from solve, which handles some common startup tasks. All these routines assume that and have opposite signs. |
procedure, private :: get_fa_fb | |
procedure, private :: converged | |
procedure, private :: solution | ../../ to check |
Classic brent (zeroin) root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => brent |
Classic bisection root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => bisection |
Classic Regula Falsi root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => regula_falsi |
Illinois (modified Regula Falsi) root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => illinois |
anderson bjorck root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => anderson_bjorck |
ridders root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => ridders |
pegasus root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => pegasus |
bdqrf root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => bdqrf |
muller root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => muller |
brenth root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => brenth |
brentq root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => brentq |
chandrupatla root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => chandrupatla |
TOMS748 root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => toms748 |
zhang root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => zhang |
anderson-bjorck-king root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => anderson_bjorck_king |
blendtf root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => blendtf |
barycentric root solver
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => barycentric |
ITP root solver
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=wp), | private | :: | k1 | = | 0.1_wp |
from (0, inf) |
|
real(kind=wp), | private | :: | k2 | = | 0.98_wp*(1.0_wp+golden_ratio) |
from [1, 1+phi] |
|
integer, | private | :: | n0 | = | 1 |
procedure, public :: initialize => initialize_root_solver | ../../ initialize the class [must be called first] |
procedure, public :: solve | ../../ main routine for finding the root |
procedure, public :: find_root => itp | |
procedure, public :: set_optional_inputs => itp_optional_inputs |
Convert a root method name to the corresponding root_method enum type.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | name |
method name |
the root_method enum type for that method
Determines convergence in x based on if the reltol or abstol is satisfied.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | a |
old value |
||
real(kind=wp), | intent(in) | :: | b |
new value |
Bisection step.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1 | |||
real(kind=wp), | intent(in) | :: | x2 |
point half way between x1 and x2
Regula Falsi step. With a protection to fall back to bisection if:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1 | |||
real(kind=wp), | intent(in) | :: | x2 | |||
real(kind=wp), | intent(in) | :: | f1 | |||
real(kind=wp), | intent(in) | :: | f2 | |||
real(kind=wp), | intent(in) | :: | ax |
original interval lower bound |
||
real(kind=wp), | intent(in) | :: | bx |
original interval upper bound |
intersection of line connecting x1,x2 with x-axis
Secent step. With a protection to fall back to bisection if:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1 | |||
real(kind=wp), | intent(in) | :: | x2 | |||
real(kind=wp), | intent(in) | :: | f1 | |||
real(kind=wp), | intent(in) | :: | f2 | |||
real(kind=wp), | intent(in) | :: | ax |
original interval lower bound |
||
real(kind=wp), | intent(in) | :: | bx |
original interval upper bound |
intersection of secant step with x-axis
lowercase a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | str |
input string |
lowercase version of the string
Returns true if this is a solution and sets xzero
and fzero
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | f | |||
real(kind=wp), | intent(inout) | :: | xzero | |||
real(kind=wp), | intent(inout) | :: | fzero |
Initialize the root_solver class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(out) | :: | me | |||
procedure(func) | :: | f |
user function |
|||
real(kind=wp), | intent(in), | optional | :: | ftol |
absolute tolerance for |
|
real(kind=wp), | intent(in), | optional | :: | rtol |
relative tol for x |
|
real(kind=wp), | intent(in), | optional | :: | atol |
absolute tol for x |
|
integer, | intent(in), | optional | :: | maxiter |
maximum number of iterations |
Non-object-oriented wrapper.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | method |
the method to use |
||
procedure(func2) | :: | fun |
user function to find the root of |
|||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
||
real(kind=wp), | intent(in), | optional | :: | ftol |
absolute tolerance for |
|
real(kind=wp), | intent(in), | optional | :: | rtol |
relative tol for x |
|
real(kind=wp), | intent(in), | optional | :: | atol |
absolute tol for x |
|
integer, | intent(in), | optional | :: | maxiter |
maximum number of iterations |
|
real(kind=wp), | intent(in), | optional | :: | fax |
if |
|
real(kind=wp), | intent(in), | optional | :: | fbx |
if |
|
logical, | intent(in), | optional | :: | bisect_on_failure |
if true, then if the specified method fails,
it will be retried using the bisection method.
(default is False). Note that this can use up
to |
Non-object-oriented wrapper.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(root_method), | intent(in) | :: | method |
the method to use |
||
procedure(func2) | :: | fun |
user function to find the root of |
|||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
||
real(kind=wp), | intent(in), | optional | :: | ftol |
absolute tolerance for |
|
real(kind=wp), | intent(in), | optional | :: | rtol |
relative tol for x |
|
real(kind=wp), | intent(in), | optional | :: | atol |
absolute tol for x |
|
integer, | intent(in), | optional | :: | maxiter |
maximum number of iterations |
|
real(kind=wp), | intent(in), | optional | :: | fax |
if |
|
real(kind=wp), | intent(in), | optional | :: | fbx |
if |
|
logical, | intent(in), | optional | :: | bisect_on_failure |
if true, then if the specified method fails,
it will be retried using the bisection method.
(default is False). Note that this can use up
to |
Main wrapper routine for all the methods.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
||
real(kind=wp), | intent(in), | optional | :: | fax |
if |
|
real(kind=wp), | intent(in), | optional | :: | fbx |
if |
|
logical, | intent(in), | optional | :: | bisect_on_failure |
if true, then if the specified method fails,
it will be retried using the bisection method.
(default is False). Note that this can use up
to |
Returns the function values at ax
and bx
to start the root finding algorithm.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(root_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in), | optional | :: | fax |
if |
|
real(kind=wp), | intent(in), | optional | :: | fbx |
if |
|
real(kind=wp), | intent(out) | :: | fa |
|
||
real(kind=wp), | intent(out) | :: | fb |
|
Find a zero of the function in the given interval to within a tolerance , where is the relative machine precision defined as the smallest representable number such that .
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(brent_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Compute the zero of the function f(x) in the interval ax,bx using the bisection method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(bisection_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Compute the zero of the function f(x) in the interval ax,bx using the regula falsi method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(regula_falsi_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Illinois method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(illinois_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Compute the zero of the function f(x) in the interval ax,bx using the Anderson-Bjorck method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(anderson_bjorck_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Ridders method to find a root of f(x).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ridders_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Pegasus method to find a root of f(x).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pegasus_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Bisected Direct Quadratic Regula Falsi (BDQRF) root solver method to find the root of a 1D function.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(bdqrf_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Improved Muller method (for real roots only). Will fall back to bisection if any step fails.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(muller_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Brent's method with hyperbolic extrapolation.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(brenth_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Classic Brent's method to find a zero of the function f on the sign changing interval [ax, bx], but with a different formula for the extrapolation step.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(brentq_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Chandrupatla's method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(chandrupatla_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
TOMS748 rootfinding method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(toms748_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Zhang's method (with corrections from Stage).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(zhang_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Modified anderson-bjorck-king method. Same as anderson_bjorck, but with an extra initial bisection step.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(anderson_bjorck_king_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
BlendTF blended method of trisection and false position methods.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(blendtf_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Barycentric interpolation method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(barycentric_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
For the itp method, set the optional inputs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(itp_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | optional | :: | k1 |
from (0, inf) [Default is 0.1] |
|
real(kind=wp), | intent(in), | optional | :: | k2 |
from [1, 1+phi] [Default is 0.98*(1+phi)] |
|
integer, | intent(in), | optional | :: | n0 |
[Default is 1 |
Compute the zero of the function f(x) in the interval ax,bx using the Interpolate Truncate and Project (ITP) method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(itp_solver), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | ax |
left endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | bx |
right endpoint of initial interval |
||
real(kind=wp), | intent(in) | :: | fax |
|
||
real(kind=wp), | intent(in) | :: | fbx |
|
||
real(kind=wp), | intent(out) | :: | xzero |
abscissa approximating a zero of |
||
real(kind=wp), | intent(out) | :: | fzero |
value of |
||
integer, | intent(out) | :: | iflag |
status flag ( |
Given two points with two function evaluations, choose the best one (the one closest to the root).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x1 | |||
real(kind=wp), | intent(in) | :: | x2 | |||
real(kind=wp), | intent(in) | :: | f1 | |||
real(kind=wp), | intent(in) | :: | f2 | |||
real(kind=wp), | intent(out) | :: | xbest | |||
real(kind=wp), | intent(out) | :: | fbest |
Swap two real(wp) values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout) | :: | a | |||
real(kind=wp), | intent(inout) | :: | b |