This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# NMaximize

 NMaximizemaximizes f numerically with respect to x. NMaximizemaximizes f numerically with respect to x, y, .... NMaximizemaximizes f numerically subject to the constraints cons.
• cons can contain equations, inequalities or logical combinations of these.
• NMaximize always attempts to find a global maximum 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, NMaximize can always find global maxima, over both real and integer values.
• Otherwise, NMaximize may sometimes find only a local maximum.
• 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 maximum, and the value of the function at the maximum.
• Possible settings for the Method option include , , , and .
Find the global maximum of an unconstrained problem:
Extract the maximizing argument:
Find the global maximum of problems with constraints:
Find the global maximum of an unconstrained problem:
 Out[1]=
Extract the maximizing argument:
 Out[2]=

Find the global maximum of problems with constraints:
 Out[1]=
 Out[2]=
 Scope   (3)
Or constraints can be specified:
Use NMaximize for linear objective and constraints:
Integer constraints can be imposed:
 Options   (6)
This enforces convergence criteria and :
This enforces 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 NMaximize in finding the maximum of a function:
With the working precision set to , by default AccuracyGoal and PrecisionGoal are set to :
NMaximize aims to find a global maximum, while FindMaximum attempts to find a local maximum:
Maximize finds a global maximum and can work in infinite precision:
For nonlinear functions, NMaximize may sometimes find only a local maximum:
Specifying a starting interval can help in achieving a better local maximum:
NMaximize finds a local maximum of a two-dimensional function on a disk:
Specifying a starting interval helps in achieving the global maximum:
Solve cannot work with this system of equations because they are highly nonalgebraic:
Use NMaximize with a trivial objective function to find a solution: