fzero - fabiankindermann/ce-fortran GitHub Wiki

subroutine fzero(x, funcv, check_return)

Description:

This subroutine solves a non-linear equation or equation system, meaning that it searches for a value such that , with . can be either 1 or greater than one, in which case is either a scalar or a vector.

Input arguments:

  • real*8 :: x    or    real*8 :: x(:)
    x can be either a scalar or a one-dimensional array, indicating whether fzero should solve a single equation or an equation system. The subroutine will use the values provided in x as starting guess for solving the equation system. Hence, the closer x is to the actual root of the function , the faster and the more reliable will be the rootfinding process.
  • function :: funcv
    The input funcv is the name of a function that provides the non-linear equation or equation system that should be solved by fzero. Note that this function needs to be stored somewhere in a module and can not be an element of the contains statement the main program. If x is a scalar, this function must follow exactly the calling conventions:
    function funcv(p)
    implicit none
    real*8, intent(in) :: p
    real*8 :: funcv
    [......]
    end function funcv
    

    If x(:) is a one-dimensional array we have

    function funcv(p)
    implicit none
    real*8, intent(in) :: p(:)
    real*8 :: funcv(size(p, 1))
    [......]
    end function funcv
    

Output arguments:

  • real*8 :: x    or    real*8 :: x(:)
    Having successfully solved the non-linear equation or equation system, the resulting solution will again be stored in the scalar or array x, such that no additional output argument is needed. x is hence of the type inout.

Optional arguments:

  • logical :: check_return
    The optional logical scalar check_return can be used as an indicator for whether the root-finding process was successful. If everything went smoothly, then check_return is assigned a value of .false.. If, however, an error occurred throughout the iteration process within the subroutine fzero, check_return is assigned a value of .true..

References

  • Parts of this routine were copied and adapted from:
    • Press, W.H., Teukolsky, S.A., Vetterling, W.T. & Flannery, B.P. (1992). Numerical Recipes in Fortran 90: The Art of Parallel Scientific Computing, 2nd edition. Cambridge: Cambridge Univeristy Press.
  • For further reading refer to:
    • Broydn, C.G. (1967). Quasi-Newton methods and their application to function minimisation. Mathematics of Computation, 19, 577-593.
    • Allen, M.B. & Isaacson, E.L. (1998). Numerical Analysis for Applied Science. Wiley Series in Pure and Applied Mathematics, New York: Wiley.
  • This routine is used in the following programs:
    • prog02_08.f90
    • prog02_14.f90
    • prog03_02.f90
    • prog03_03.f90
    • prog03_04.f90
    • prog03_05.f90
    • prog03_06.f90
    • prog03_07.f90
    • prog04_02.f90
    • prog04_09.f90
    • prog06_01.f90
    • prog06_02.f90
    • prog08_06.f90
    • prog09_01.f90
    • prog09_02.f90
    • prog09_03.f90
    • prog09_04.f90
    • prog09_05.f90
    • prog09_06.f90
    • prog09_07.f90
    • prog09_08.f90
    • prog09_08m.f90
    • prog09_09.f90
    • prog09_09m.f90
    • prog09_10.f90
    • prog09_10m.f90
    • prog10_01.f90
    • prog10_02.f90
    • prog10_03.f90
    • prog10_04.f90
    • prog10_05.f90
    • prog10_06.f90
    • prog11_01.f90
    • prog11_02.f90
    • prog11_03.f90
⚠️ **GitHub.com Fallback** ⚠️