brentq 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 |
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 ( |
type,extends(root_solver),public :: brentq_solver !! brentq root solver private contains private procedure,public :: find_root => brentq end type brentq_solver