Classic brent (zeroin) root solver
initialize the class [must be called first]
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 |
main routine for finding the root
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 |
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 ( |
type,extends(root_solver),public :: brent_solver !! Classic brent (zeroin) root solver private contains private procedure,public :: find_root => brent end type brent_solver