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

1.6.5 Numerical Optimization


Numerical minimization functions.

The function ConstrainedMin allows you to solve linear programming problems in which you give a linear function f, then find its minimum over a domain specified by a list of linear inequalities. ConstrainedMin assumes that all the variables you give are constrained to be non-negative.













  • This gives the minimum value of in the specified domain, followed by the values of , and


    at which the value is attained.
  • In[1]:= ConstrainedMin[x - y - z, {y + z < 3, x > 7},
    {x, y, z}]

    Out[1]=

    When the function you want to minimize is linear, you can always use ConstrainedMin to find its global minimum. For more complicated functions, however, there is usually no systematic way to find a global minimum. Instead, you can use FindMinimum to search for local minima.







  • This searches for a local minimum of , starting at


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

    Out[2]=

  • With a different starting point, you may reach a different local minimum.
  • In[3]:= FindMinimum[x Cos[x], {x, 10}]

    Out[3]=




  • This finds a minimum of


    .
  • In[4]:= FindMinimum[Sin[x y], {x, 2}, {y, 2}]

    Out[4]=