libSUFR
a LIBrary of Some Useful Fortran Routines
All Classes Namespaces Files Functions Variables Pages
sufr_solvers Module Reference

Procedures to solve equations. More...

Functions/Subroutines

real(double) function root_solver (func, x1, x2, accur, status, verbose)
 Using Brent's method, find the root of a function func that lies between x1 and x2.
 
real(double) function minimum_solver (func, ax, bx, cx, accur, xmin, status, verbose)
 Use Brent's method and parabolic interpolation to find the minimum of function func that lies between xa and xc.
 

Detailed Description

Procedures to solve equations.

Function/Subroutine Documentation

◆ minimum_solver()

real(double) function sufr_solvers::minimum_solver ( real(double), external func,
real(double), intent(in) ax,
real(double), intent(in) bx,
real(double), intent(in) cx,
real(double), intent(in) accur,
real(double), intent(out) xmin,
integer, intent(out), optional status,
integer, intent(in), optional verbose )

Use Brent's method and parabolic interpolation to find the minimum of function func that lies between xa and xc.

Parameters
funcThe function of which the minimum is to be found
axThe lower limit for the x-value of the minimum: xa < x_min < xc
bxA good guess for the x-value of the minimum: xa < xb < xc and func(xb) < min(funx(xa),func(xc))
cxThe upper limit for the x-value of the minimum: xa < x_min < xc
accurRelative accuracy with which the minimum is to be found
xminX-value of the minimum (output)
statusStatus: 0-ok, 1-maximum number of iterations exceeded (output, optional)
verboseVerbosity: 0-print nothing, 1-print errors, 2-print warnings, 3-print info (output, optional argument, default=2)
Return values
minimum_solverThe value of the minimum of the function func, to accuracy accur
See also
Numerical Recipes in Fortran 77, Sect.10.2.

Definition at line 183 of file solvers.f90.

References sufr_kinds::dbl, sufr_numerics::deq(), sufr_kinds::double, golden_section(), and minimum_solver().

Referenced by minimum_solver().

Here is the call graph for this function:

◆ root_solver()

real(double) function sufr_solvers::root_solver ( real(double), external func,
real(double), intent(in) x1,
real(double), intent(in) x2,
real(double), intent(in) accur,
integer, intent(out), optional status,
integer, intent(in), optional verbose )

Using Brent's method, find the root of a function func that lies between x1 and x2.

Parameters
funcFunction to find the root of
x1Lower limit in x for root: x1 < root < x2; func(x1) and func(x2) must be positive and negative or vice versa
x2Upper limit in x for root: x1 < root < x2; func(x1) and func(x2) must be positive and negative or vice versa
accurThe accuracy with which the root is to be determined
statusStatus: 0-ok, 1-maximum number of iterations exceeded, 2-root not bracketed (output, optional)
verboseVerbosity: 0-print nothing, 1-print errors, 2-print warnings, 3-print info (output, optional, default=2)
Return values
root_solverThe value of the root of func, between x1 and x2 and with accuracy accur. If a root was not bracketed by (output) x1 and x2, -huge is returned and status=1.
See also
Numerical Recipes in Fortran 77, Sect.9.3.

Definition at line 45 of file solvers.f90.

References sufr_kinds::dbl, sufr_numerics::deq(), sufr_kinds::double, and root_solver().

Referenced by root_solver().

Here is the call graph for this function: