This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / The Mathematica Book / Advanced Mathematics / Numerical Operations on Functions  /

3.9.8 Numerical Minimization

FindRoot gives you a way to find points at which a particular function is equal to zero. It is also often important to be able to find points at which a function has its minimum value. In principle, you could do this by applying FindRoot to the derivative of the function. In practice, however, there are much more efficient approaches.
FindMinimum gives you a way to find a minimum value for a function. As in FindRoot, you specify the first one or two points to try, and then FindMinimum tries to get progressively more accurate approximations to a minimum. If FindMinimum returns a definite result, then the result is guaranteed to correspond to at least a local minimum of your function. However, it is important to understand that the result may not be the global minimum point.
You can understand something about how FindMinimum works by thinking of the values of your function as defining the height of a surface. What FindMinimum does is essentially to start at the points you specify, then follow the path of steepest descent on the surface. Except in pathological cases, this path always leads to at least a local minimum on the surface. In many cases, however, the minimum will not be a global one. As a simple analogy which illustrates this point, consider a physical mountain. Any water that falls on the mountain takes the path of steepest descent down the side of the mountain. Yet not all the water ends up at the bottom of the valleys; much of it gets stuck in mountain lakes which correspond to local minima of the mountain height function.
You should also realize that because FindMinimum does not take truly infinitesimal steps, it is still possible for it to overshoot even a local minimum.

  • This finds the value of which minimizes , starting from

  • In[1]:= FindMinimum[Gamma[x], {x, 2}]


  • Here is a function with many local minima.
  • In[2]:= Plot[Sin[x] + x/5, {x, -10, 10}]

  • FindMinimum finds the local minimum closest to

    . This is not the global minimum for the function.
  • In[3]:= FindMinimum[Sin[x] + x/5, {x, 1}]


  • This finds the local minimum of a function of two variables. As in FindRoot, it is a good idea to choose starting values that are not too "special".
  • In[4]:= FindMinimum[x^4 + 3 x^2 y + 5 y^2 + x + y,
    {x, 0.1}, {y, 0.2}]


    Numerical minimization.