This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 BUILT-IN MATHEMATICA SYMBOL Tutorials »| See Also »| More About »

NMinimize

 NMinimizeminimizes f numerically with respect to x. NMinimizeminimizes f numerically with respect to x, y, .... NMinimizeminimizes f numerically subject to the constraints cons.
• cons can contain equations, inequalities, or logical combinations of these.
• 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.
• The following options can be given:
 AccuracyGoal Automatic number of digits of final accuracy sought EvaluationMonitor None expression to evaluate whenever f is evaluated MaxIterations 100 maximum number of iterations to use Method Automatic method to use PrecisionGoal Automatic number of digits of final precision sought StepMonitor None expression to evaluate whenever a step is taken WorkingPrecision MachinePrecision the precision used in internal computations
• 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.
• Possible settings for the Method option include , , , and .
Find the global minimum of an unconstrained problem:
Extract the minimizing argument:
Find the global minimum of problems with constraints:
Find the global minimum of an unconstrained problem:
 Out[1]=
Extract the minimizing argument:
 Out[2]=

Find the global minimum of problems with constraints:
 Out[1]=
 Out[2]=
 Scope   (3)
Or constraints can be specified:
Use NMinimize for linear objectives and constraints:
Integer constraints can be imposed:
 Options   (6)
This enforces a convergence criteria and :
This enforces a convergence criteria and , which is not achievable with the default machine-precision computation:
Setting a high WorkingPrecision makes the process convergent:
Record all the points evaluated during the solution process of a function with a ring of minima:
Plot all the visited points that are close in objective function value to the final solution:
Specifying a non-default method could give a better solution:
Steps taken by NMinimize in finding the minimum of the classic Rosenbrock function:
With the working precision set to , by default AccuracyGoal and PrecisionGoal are set to :
NMinimize aims to find a global minimum, while FindMinimum attempts to find a local minimum:
Minimize finds a global minimum and can work in infinite precision:
FindFit can use NMinimize to find the global optimal fit. This sets up a model:
Create a function from the model and parameters, and generate sample points:
By default FindFit only finds the local optimal fit:
Using the NMinimize method finds the global optimal fit:
For nonlinear functions, NMinimize may sometimes find only a local minimum:
Specifying a starting interval can help in achieving a better local minimum:
NMinimize finds a local minimum of a two-dimensional function on a disk:
Specifying a starting interval helps in achieving the global minimum:
Solve cannot work with this system of equations because they are highly nonalgebraic:
Use NMinimize with a trivial objective function to find a solution:
New in 5 | Last modified in 6