Skip to content

fminsearch

Fabian Kindermann edited this page Apr 2, 2021 · 6 revisions
subroutine fminsearch(xmin, fret, minimum, maximum, func)

Description:

This subroutine finds the minimum of a one or multi-dimensional function , meaning that it searches for a value such that

Note that in order to find the maximum of a function, you can just search for the minimum of . Note further that if the function has multiple local minima, there is no guarantee that fminsearch will find the global minimum of this function. For solving global minima problems, more sophisticated methods are needed.

Input arguments:

  • real*8 :: xmin    or    real*8 :: xmin(:)
    xmin can be either a scalar or a one-dimensional array, indicating whether fminsearch should find the minimum of a one or multi-dimensional function. The subroutine will use the values provided in xmin as starting guess for finding the minimum. Hence, the closer xmin is to the actual minimum of the function , the faster and the more reliable will be the minimization process.
  • real*8 :: minimum    or    real*8 :: minimum(:)
    minimum defines the lower bound of the interval in $\mathbb{R}^n$ on which fminsearch should search for the minimum of . If , then minimum is just the scalar lower bound of the search interval. If , minimum contains the lower bounds in each search dimension of and therefore marks the lower corner of an -dimensional hypercube. Note that minimum needs to have exactly the same size as xmin.
  • real*8 :: maximum    or    real*8 :: maximum(:)
    maximum defines the upper bound of the interval in $\mathbb{R}^n$ on which fminsearch should search for the minimum of . If , then maximum is just the scalar upper bound of the search interval. If , maximum contains the upper bounds in each search dimension of and therefore marks the upper corner of an -dimensional hypercube. Note that maximum needs to have exactly the same size as xmin.
  • function :: func
    The input func is the name of a Fortran function that provides the function that fminsearch should find a minimum of. 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 xmin is a scalar, this function must follow exactly the calling conventions:
    function func(p)
    implicit none
    real*8, intent(in) :: p
    real*8 :: func
    [......]
    end function func 
    

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

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

Output arguments:

  • real*8 :: xmin    or    real*8 :: xmin(:)
    Having successfully found the minimum of , the resulting solution will again be stored in the scalar or array xmin, such that no additional output argument is needed. xmin is hence of the type inout.
  • real*8 :: fret
    After the subroutine fminsearch has finished its iteration process, it stores the function value in the scalar variable fret.

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:
    • Brent, R.P. (2003). Algorithms for Minimization without Derivatives. Mineola: Dover Books on Mathematics.
    • Acton, F.S. (1997). Numerical Methods that Work. The Mathematical Association of America.
  • This routine is used in the following programs:
    • prog02_11.f90
    • prog03_01.f90
    • prog05_01.f90
    • prog05_02.f90
    • prog05_03.f90
    • prog05_04.f90
    • prog05_05.f90
    • prog08_05.f90
Clone this wiki locally