Loading [MathJax]/extensions/tex2jax.js
MRFFL: MR Fortran Finance Library 2024-12-28
Computational Tools For Finance
All Namespaces Files Functions Variables
mrffl_solver Module Reference

Root solvers. More...

Functions/Subroutines

subroutine, public bisection (xc, x0_init, x1_init, f, x_epsilon, y_epsilon, max_itr, status, progress)
 Search for a root for the function f in the interval [x0_init, x1_init].
 
subroutine, public multi_bisection (xc, x0_init, x1_init, f, x_epsilon, y_epsilon, max_itr, status, progress)
 Use bisection() to search for a root for the function f in a list of intervals returning the first root found.
 

Detailed Description

Root solvers.

Function/Subroutine Documentation

◆ bisection()

subroutine, public mrffl_solver::bisection ( real(kind=rk), intent(out) xc,
real(kind=rk), intent(in) x0_init,
real(kind=rk), intent(in) x1_init,
procedure(func_to_solve_t) f,
real(kind=rk), intent(in) x_epsilon,
real(kind=rk), intent(in) y_epsilon,
integer(kind=ik), intent(in) max_itr,
integer(kind=ik), intent(out) status,
logical, intent(in) progress )

Search for a root for the function f in the interval [x0_init, x1_init].

The process is iterative. At each step the size of the search interval is cut in half. If the search interval gets too small (< x_epsilon), then the process is abandoned. If no zero is found after max_itr, then the process is abandoned.

Parameters
xcThe solution (or last value tested if no solution is found)
x0_initLeft side of search interval
x1_initRight side of search interval
fFunction to solve for zero
x_epsilonUsed to test if current search interval is too small
y_epsilonUsed to test if f is near zero
max_itrMaximum number of iterations before giving up
statusReturns status of computation. 0 if everything worked. Range: 0 & 4001-4032.
progressPrint progress as solver searches for a solution

Definition at line 65 of file mrffl_solver.f90.

References mrffl_config::mrfflik, and mrffl_config::mrfflrk.

Referenced by multi_bisection().

Here is the caller graph for this function:

◆ multi_bisection()

subroutine, public mrffl_solver::multi_bisection ( real(kind=rk), intent(out) xc,
real(kind=rk), dimension(:), intent(in) x0_init,
real(kind=rk), dimension(:), intent(in) x1_init,
procedure(func_to_solve_t) f,
real(kind=rk), intent(in) x_epsilon,
real(kind=rk), intent(in) y_epsilon,
integer(kind=ik), intent(in) max_itr,
integer(kind=ik), intent(out) status,
logical, intent(in) progress )

Use bisection() to search for a root for the function f in a list of intervals returning the first root found.

Parameters
xcThe solution (or last value tested if no solution is found)
x0_initA VECTOR of left sides for search intervals
x1_initA VECTOR of right sides for search intervals
fFunction to solve for zero
x_epsilonUsed to test if current search interval is too small
y_epsilonUsed to test if f is near zero
max_itrMaximum number of iterations before giving up
statusReturns status of computation. 0 if everything worked. Range: 0 & 4033-4064.
progressPrint progress as solver searches for a solution

Definition at line 150 of file mrffl_solver.f90.

References bisection(), mrffl_config::mrfflik, and mrffl_config::mrfflrk.

Referenced by mrffl_cashflows::cashflow_matrix_irr(), mrffl_cashflows::cashflow_vector_irr(), and mrffl_tvm12::tvm12_solve().

Here is the call graph for this function:
Here is the caller graph for this function: