root finding subroutines More...

Data Types

type  roots_typ
 basic type for root finding functions More...
 

Functions/Subroutines

pure subroutine, public initroots (this, x1, x2, f1, f2, dxacc, maxiter)
 
character(len=64) function, public geterrormessage (error)
 
subroutine getroot_generic (this, Stepper, func, x1, x2, dxacc, maxiter, plist, xm)
 
subroutine, public getroot_newton (funcd, x1, x2, root, error, plist, xm, iterations)
 
subroutine, public getroot_regulafalsi (func, x1, x2, root, error, plist, xm, iterations)
 
subroutine, public getroot_pegasus (func, x1, x2, root, error, plist, xm, iterations)
 
subroutine, public getroot_king (func, x1, x2, root, error, plist, xm, iterations)
 
subroutine, public getroot_andersonbjoerk (func, x1, x2, root, error, plist, xm, iterations)
 
subroutine, public getroot_ridder (func, x1, x2, root, error, plist, xm, iterations)
 
subroutine, public getroot_brentdekker (func, x1, x2, root, error, plist, xm, iterations)
 
subroutine, public getroot_bisection (func, x1, x2, root, error, plist, xm, iterations)
 
pure subroutine updatebounds_bisection (this)
 
pure subroutine step_bisection (this)
 
pure subroutine step_newton (this)
 
pure subroutine step_regulafalsi (this)
 
pure subroutine step_pegasus (this)
 
pure subroutine step_king (this)
 
pure subroutine step_andersonbjoerk (this)
 
pure subroutine step_ridder (this)
 
pure subroutine step_brentdekker (this)
 
pure subroutine step_secantmethod (this)
 
pure subroutine saveinversequadraticinterpolation (a, b, c, fa, fb, fc, db_numer, db_denom)
 
pure subroutine step_arithmeticmean (this)
 
pure real function arithmeticmean (a, b)
 
pure real function linearinterpolation (x1, x2, f1, f2)
 
pure subroutine testconvergence (this)
 

Variables

integer, parameter, public default_max_iterations = 1000
 
real, parameter, public default_accuracy = 4*EPSILON(DEFAULT_ACCURACY)
 
character(len=64), dimension(0:4), parameter error_message = (/ "unknown error ", "root not bracketed ", "iteration exceeds maximum ", "requested accuracy smaller than machine precission ", "upper limit for iterations should be larger than 1 " /)
 

Detailed Description

root finding subroutines

Author
Tobias Illenseer
  1. Newton's method combined with bisection, for ill-posed problems
  2. Regula falsi
  3. Bisection
  4. Pegasus
  5. King
  6. Anderson Bjoerk
  7. Ridder
  8. Brent Dekker (default)

The algorithms can be found in standard textbooks on numerical analysis. See e. g. [press2007] and [engeln2011] and references therein.

Function/Subroutine Documentation

◆ arithmeticmean()

pure real function roots::arithmeticmean ( real, intent(in)  a,
real, intent(in)  b 
)
private

Definition at line 887 of file roots.f90.

◆ geterrormessage()

character(len=64) function, public roots::geterrormessage ( integer, intent(in)  error)

Definition at line 160 of file roots.f90.

◆ getroot_andersonbjoerk()

subroutine, public roots::getroot_andersonbjoerk (   func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 417 of file roots.f90.

◆ getroot_bisection()

subroutine, public roots::getroot_bisection (   func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 519 of file roots.f90.

◆ getroot_brentdekker()

subroutine, public roots::getroot_brentdekker (   func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 485 of file roots.f90.

◆ getroot_generic()

subroutine roots::getroot_generic ( type(roots_typ), intent(inout)  this,
  Stepper,
  func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(in), optional  dxacc,
integer, intent(in), optional  maxiter,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm 
)
private

Definition at line 178 of file roots.f90.

◆ getroot_king()

subroutine, public roots::getroot_king (   func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 383 of file roots.f90.

◆ getroot_newton()

subroutine, public roots::getroot_newton (   funcd,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 247 of file roots.f90.

◆ getroot_pegasus()

subroutine, public roots::getroot_pegasus (   func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 349 of file roots.f90.

◆ getroot_regulafalsi()

subroutine, public roots::getroot_regulafalsi (   func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 315 of file roots.f90.

◆ getroot_ridder()

subroutine, public roots::getroot_ridder (   func,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(out)  root,
integer, intent(out)  error,
real, dimension(:), intent(in), optional  plist,
real, intent(in), optional  xm,
integer, intent(out), optional  iterations 
)

Definition at line 451 of file roots.f90.

◆ initroots()

pure subroutine, public roots::initroots ( type(roots_typ), intent(inout)  this,
real, intent(in)  x1,
real, intent(in)  x2,
real, intent(in)  f1,
real, intent(in)  f2,
real, intent(in), optional  dxacc,
integer, intent(in), optional  maxiter 
)

Definition at line 98 of file roots.f90.

◆ linearinterpolation()

pure real function roots::linearinterpolation ( real, intent(in)  x1,
real, intent(in)  x2,
real, intent(in)  f1,
real, intent(in)  f2 
)
private

Definition at line 897 of file roots.f90.

◆ saveinversequadraticinterpolation()

pure subroutine roots::saveinversequadraticinterpolation ( real, intent(in)  a,
real, intent(in)  b,
real, intent(in)  c,
real, intent(in)  fa,
real, intent(in)  fb,
real, intent(in)  fc,
real, intent(out)  db_numer,
real, intent(out)  db_denom 
)
private

Definition at line 842 of file roots.f90.

◆ step_andersonbjoerk()

pure subroutine roots::step_andersonbjoerk ( type(roots_typ), intent(inout)  this)
private

Definition at line 691 of file roots.f90.

◆ step_arithmeticmean()

pure subroutine roots::step_arithmeticmean ( type(roots_typ), intent(inout)  this)
private

Definition at line 874 of file roots.f90.

◆ step_bisection()

pure subroutine roots::step_bisection ( type(roots_typ), intent(inout)  this)
private

Definition at line 568 of file roots.f90.

◆ step_brentdekker()

pure subroutine roots::step_brentdekker ( type(roots_typ), intent(inout)  this)
private

Definition at line 748 of file roots.f90.

◆ step_king()

pure subroutine roots::step_king ( type(roots_typ), intent(inout)  this)
private

Definition at line 643 of file roots.f90.

◆ step_newton()

pure subroutine roots::step_newton ( type(roots_typ), intent(inout)  this)
private

Definition at line 578 of file roots.f90.

◆ step_pegasus()

pure subroutine roots::step_pegasus ( type(roots_typ), intent(inout)  this)
private

Definition at line 618 of file roots.f90.

◆ step_regulafalsi()

pure subroutine roots::step_regulafalsi ( type(roots_typ), intent(inout)  this)
private

Definition at line 604 of file roots.f90.

◆ step_ridder()

pure subroutine roots::step_ridder ( type(roots_typ), intent(inout)  this)
private

Definition at line 717 of file roots.f90.

◆ step_secantmethod()

pure subroutine roots::step_secantmethod ( type(roots_typ), intent(inout)  this)
private

Definition at line 811 of file roots.f90.

◆ testconvergence()

pure subroutine roots::testconvergence ( type(roots_typ), intent(inout)  this)
private

Definition at line 907 of file roots.f90.

◆ updatebounds_bisection()

pure subroutine roots::updatebounds_bisection ( type(roots_typ), intent(inout)  this)
private

Definition at line 550 of file roots.f90.

Variable Documentation

◆ default_accuracy

real, parameter, public roots::default_accuracy = 4*EPSILON(DEFAULT_ACCURACY)

Definition at line 67 of file roots.f90.

◆ default_max_iterations

integer, parameter, public roots::default_max_iterations = 1000

Definition at line 66 of file roots.f90.

◆ error_message

character(len=64), dimension(0:4), parameter roots::error_message = (/ "unknown error ", "root not bracketed ", "iteration exceeds maximum ", "requested accuracy smaller than machine precission ", "upper limit for iterations should be larger than 1 " /)
private

Definition at line 68 of file roots.f90.