NMinimize

NMinimize[f,x]
minimizes f numerically with respect to x.

NMinimize[f,{x,y,}]
minimizes f numerically with respect to x, y, .

NMinimize[{f,cons},{x,y,}]
minimizes f numerically subject to the constraints cons.

NMinimize[,xreg]
constrains x to be in the region reg.

Details and OptionsDetails and Options

  • NMinimize returns a list of the form .
  • cons can contain equations, inequalities, or logical combinations of these.
  • The constraints cons can be any logical combination of:
  • lhs==rhsequations
    or inequalities
    {x,y,}regregion specification
  • NMinimize[{f,cons},xreg] is effectively equivalent to NMinimize[{f,consxreg},x].
  • For , the different coordinates can be referred to using Indexed[x,i].
  • NMinimize always attempts to find a global minimum of f subject to the constraints given.
  • By default, all variables are assumed to be real.
  • xIntegers can be used to specify that a variable can take on only integer values.
  • If f and cons are linear, NMinimize can always find global minima, over both real and integer values.
  • Otherwise, NMinimize may sometimes find only a local minimum.
  • If NMinimize determines that the constraints cannot be satisfied, it returns {Infinity,{x->Indeterminate,}}.
  • The following options can be given:
  • AccuracyGoalAutomaticnumber of digits of final accuracy sought
    EvaluationMonitorNoneexpression to evaluate whenever f is evaluated
    MaxIterations100maximum number of iterations to use
    MethodAutomaticmethod to use
    PrecisionGoalAutomaticnumber of digits of final precision sought
    StepMonitorNoneexpression to evaluate whenever a step is taken
    WorkingPrecisionMachinePrecisionthe precision used in internal computations
  • The default settings for AccuracyGoal and PrecisionGoal are WorkingPrecision/2.
  • The settings for AccuracyGoal and PrecisionGoal specify the number of digits to seek in both the value of the position of the minimum, and the value of the function at the minimum.
  • NMinimize continues until either of the goals specified by AccuracyGoal or PrecisionGoal is achieved.
  • Possible settings for the Method option include , , , and .

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Find the global minimum of an unconstrained problem:

In[1]:=
Click for copyable input
Out[1]=

Extract the minimizing argument:

In[2]:=
Click for copyable input
Out[2]=

Find the global minimum of problems with constraints:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Minimize a function over a geometric region:

In[1]:=
Click for copyable input
Out[1]=

Plot it:

In[2]:=
Click for copyable input
Out[2]=
Introduced in 2003
(5.0)
| Updated in 2014
(10.0)