NMinValue
✖
NMinValue

Details and Options




- NMinValue is also known as global optimization (GO).
- NMinValue always attempts to find a global minimum of f subject to the constraints given.
- NMinValue is typically used to find the smallest possible values given constraints. In different areas, this may be called the best strategy, best fit, best configuration and so on.
- If f and cons are linear or convex, the result given by NMinValue will be the global minimum, over both real and integer values; otherwise, the result may sometimes only be a local minimum.
- If NMinValue determines that the constraints cannot be satisfied, it returns Infinity.
- NMinValue supports a modeling language where the objective function f and constraints cons are given in terms of expressions depending on scalar or vector variables. f and cons are typically parsed into very efficient forms, but as long as f and the terms in cons give numerical values for numerical values of the variables, NMinValue can often find a solution.
- The constraints cons can be any logical combination of:
-
lhs==rhs equations lhs>rhs, lhs≥rhs, lhs<rhs, lhs≤rhs inequalities (LessEqual, …) lhsrhs, lhsrhs, lhsrhs, lhsrhs vector inequalities (VectorLessEqual, …) {x,y,…}∈rdom region or domain specification - NMinValue[{f,cons},x∈rdom] is effectively equivalent to NMinValue[{f,cons&&x∈rdom},x].
- For x∈rdom, the different coordinates can be referred to using Indexed[x,i].
- Possible domains rdom include:
-
Reals real scalar variable Integers integer scalar variable Vectors[n,dom] vector variable in Matrices[{m,n},dom] matrix variable in ℛ vector variable restricted to the geometric region - By default, all variables are assumed to be real.
- 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 Automatic 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.
- NMinValue continues until either of the goals specified by AccuracyGoal or PrecisionGoal is achieved.
- The methods for NMinValue fall into two classes. The first class of guaranteed methods uses properties of the problem so that, when the method converges, the minimum found is guaranteed to be global. The second class of heuristic methods uses methods that may include multiple local searches, commonly adjusted by some stochasticity, to home in on a global minimum. These methods often do find the global minimum, but are not guaranteed to do so.
- Methods that are guaranteed to give a global minimum when they converge to a solution include:
-
"Convex" use only convex methods "MOSEK" use the commercial MOSEK library for convex problems "Gurobi" use the commercial Gurobi library for convex problems "Xpress" use the commercial Xpress library for convex problems - Heuristic methods include:
-
"NelderMead" simplex method of Nelder and Mead "DifferentialEvolution" use differential evolution "SimulatedAnnealing" use simulated annealing "RandomSearch" use the best local minimum found from multiple random starting points "Couenne" use the Couenne library for non-convex mixed-integer nonlinear problems

Examples
open allclose allBasic Examples (4)Summary of the most common use cases
Find the global minimum value of a univariate function:

https://wolfram.com/xid/0j47jhg6-faqf4h

Find the global minimum value of a multivariate function:

https://wolfram.com/xid/0j47jhg6-b6nuhh

Find the global minimum value of a function subject to constraints:

https://wolfram.com/xid/0j47jhg6-fcm1i7

Find the global minimum value of a function over a geometric region:

https://wolfram.com/xid/0j47jhg6-ewyjra

Scope (40)Survey of the scope of standard use cases
Basic Uses (12)
Find the minimum value of subject to constraints
:

https://wolfram.com/xid/0j47jhg6-edj208

Several linear inequality constraints can be expressed with VectorGreaterEqual:

https://wolfram.com/xid/0j47jhg6-pjuvi

Use v>=
or \[VectorGreaterEqual] to enter the vector inequality sign :

https://wolfram.com/xid/0j47jhg6-ivyhv5

An equivalent form using scalar inequalities:

https://wolfram.com/xid/0j47jhg6-ib8bsr


https://wolfram.com/xid/0j47jhg6-lu8fwi

The inequality may not be the same as
due to possible threading in
:

https://wolfram.com/xid/0j47jhg6-wfe84


https://wolfram.com/xid/0j47jhg6-cdrbb6

To avoid unintended threading in , use Inactive[Plus]:

https://wolfram.com/xid/0j47jhg6-i1qbdu

Use constant parameter equations to avoid unintended threading in :

https://wolfram.com/xid/0j47jhg6-dd18z3

https://wolfram.com/xid/0j47jhg6-69739j

VectorGreaterEqual represents a conic inequality with respect to the "NonNegativeCone":

https://wolfram.com/xid/0j47jhg6-c8jcv

To explicitly specify the dimension of the cone, use {"NonNegativeCone",n}:

https://wolfram.com/xid/0j47jhg6-ej00nr


https://wolfram.com/xid/0j47jhg6-bhykun

Find the minimum value of subject to the constraint
:

https://wolfram.com/xid/0j47jhg6-6o2li

Specify the constraint using a conic inequality with "NormCone":

https://wolfram.com/xid/0j47jhg6-n3a57


https://wolfram.com/xid/0j47jhg6-jmkzci

Find the minimum value of the function subject to the constraint
:

https://wolfram.com/xid/0j47jhg6-v9guvz
Use Indexed to access components of a vector variable, e.g. :

https://wolfram.com/xid/0j47jhg6-p46cfv

Use Vectors[n,dom] to specify the dimension and domain of a vector variable when it is ambiguous:

https://wolfram.com/xid/0j47jhg6-9kphq



https://wolfram.com/xid/0j47jhg6-ev6iib

Specify non-negative constraints using NonNegativeReals ():

https://wolfram.com/xid/0j47jhg6-bsy75

An equivalent form using vector inequality :

https://wolfram.com/xid/0j47jhg6-uobom

Specify non-positive constraints using NonPositiveReals ():

https://wolfram.com/xid/0j47jhg6-domqhv

An equivalent form using vector inequalities:

https://wolfram.com/xid/0j47jhg6-bim93z

Or constraints can be specified:

https://wolfram.com/xid/0j47jhg6-5d9hck

Domain Constraints (4)
Specify integer domain constraints using Integers:

https://wolfram.com/xid/0j47jhg6-xi06kw

Specify integer domain constraints on vector variables using Vectors[n,Integers]:

https://wolfram.com/xid/0j47jhg6-df5n5z

Specify non-negative integer domain constraints using NonNegativeIntegers ():

https://wolfram.com/xid/0j47jhg6-2eforb

Specify non-positive integer domain constraints using NonPositiveIntegers ():

https://wolfram.com/xid/0j47jhg6-f0btvc

Region Constraints (5)
Find the minimum value of over a region:

https://wolfram.com/xid/0j47jhg6-q0zuo5

https://wolfram.com/xid/0j47jhg6-2td19x

Find the minimum distance between two regions:

https://wolfram.com/xid/0j47jhg6-pdj8lj

https://wolfram.com/xid/0j47jhg6-s3co46

Find the minimum of such that the triangle and ellipse still intersect:

https://wolfram.com/xid/0j47jhg6-lo12o0

https://wolfram.com/xid/0j47jhg6-zsebb7

Find the minimum radius of a disk that contains the given three points:

https://wolfram.com/xid/0j47jhg6-9e2uly

https://wolfram.com/xid/0j47jhg6-c8m024

Using Circumsphere gives the same result directly:

https://wolfram.com/xid/0j47jhg6-3up20f

Use to specify that
is a vector in
with
:

https://wolfram.com/xid/0j47jhg6-gf8ag3

https://wolfram.com/xid/0j47jhg6-sz8ksq

Linear Problems (5)
With linear objectives and constraints, when a minimum is found it is global:

https://wolfram.com/xid/0j47jhg6-rx665t

The constraints can be equality and inequality constraints:

https://wolfram.com/xid/0j47jhg6-7grjvm

Use Equal to express several equality constraints at once:

https://wolfram.com/xid/0j47jhg6-dkthbi

An equivalent form using several scalar equalities:

https://wolfram.com/xid/0j47jhg6-s527v9

Use VectorLessEqual to express several LessEqual inequality constraints at once:

https://wolfram.com/xid/0j47jhg6-s5e3zm

Use v<=
to enter the vector inequality in a compact form:

https://wolfram.com/xid/0j47jhg6-0mtyw2

An equivalent form using scalar inequalities:

https://wolfram.com/xid/0j47jhg6-b9pt3y

Use Interval to specify bounds on variable:

https://wolfram.com/xid/0j47jhg6-d31yau

Convex Problems (7)
Use "NonNegativeCone" to specify linear functions of the form :

https://wolfram.com/xid/0j47jhg6-hazv2m

Use v>=
to enter the vector inequality in a compact form:

https://wolfram.com/xid/0j47jhg6-2347tx

Find the minimum value of a convex quadratic function subject to linear constraints:

https://wolfram.com/xid/0j47jhg6-16jara

Find the minimum value of a convex quadratic function subject to a set of convex quadratic constraints:

https://wolfram.com/xid/0j47jhg6-d5t5gt

Find the minimum distance between two convex regions:

https://wolfram.com/xid/0j47jhg6-q5zkfc

https://wolfram.com/xid/0j47jhg6-pegha4

Find the minimum value of such that
is positive semidefinite:

https://wolfram.com/xid/0j47jhg6-dysqdc

Minimize convex objective function such that
is positive semidefinite and
:

https://wolfram.com/xid/0j47jhg6-ml87f0

Find the minimum value of a convex objective function over a 4-norm unit disk:

https://wolfram.com/xid/0j47jhg6-9j1nn4

Transformable to Convex (4)
Find the minimum perimeter of a rectangle with area 1 such that the height is at most half the width:

https://wolfram.com/xid/0j47jhg6-kwgi5j

This problem is log-convex and is solved by making a transformation {hExp[],wExp[ ]} and taking logarithms to get the convex problem:

https://wolfram.com/xid/0j47jhg6-62ce3


https://wolfram.com/xid/0j47jhg6-forh8e

Find the minimum value of the quasi-convex function subject to inequality and norm constraints. The objective is quasi-convex because it is a product of a non-negative function and a non-positive function over the domain:

https://wolfram.com/xid/0j47jhg6-7xu2gh

Quasi-convex problems can be solved as parametric convex optimization problems for the parameter :

https://wolfram.com/xid/0j47jhg6-nz65dn

Plot the objective as a function of the level-set :

https://wolfram.com/xid/0j47jhg6-36x0u9

For a level-set value between the interval , the smallest objective is found:

https://wolfram.com/xid/0j47jhg6-2eal5r

The problem becomes infeasible when the level-set value is increased:

https://wolfram.com/xid/0j47jhg6-rlvnf0


Minimize subject to the constraint
. The objective is not convex but can be represented by a difference of convex function
where
and
are convex functions:

https://wolfram.com/xid/0j47jhg6-ybo4h2

Plot the region and the minimizing point:

https://wolfram.com/xid/0j47jhg6-f0dmil

Minimize subject to the constraints
. The constraint
is not convex but can be represented by a difference of convex constraint
where
are convex functions:

https://wolfram.com/xid/0j47jhg6-6vzg6m

Plot the region and the minimizing point:

https://wolfram.com/xid/0j47jhg6-2fcv6g

General Problems (3)
Find the minimum value of a linear objective subject to nonlinear constraints:

https://wolfram.com/xid/0j47jhg6-oy13fx

Find the minimum value of a nonlinear objective subject to linear constraints:

https://wolfram.com/xid/0j47jhg6-tryoht

Find the minimum value of a nonlinear objective subject to nonlinear constraints:

https://wolfram.com/xid/0j47jhg6-yuruh0

Options (7)Common values & functionality for each option
AccuracyGoal & PrecisionGoal (2)
This enforces convergence criteria and
:

https://wolfram.com/xid/0j47jhg6-05x0hq

This enforces convergence criteria and
, which is not achievable with the default machine-precision computation:

https://wolfram.com/xid/0j47jhg6-ykixh5


Setting a high WorkingPrecision makes the process convergent:

https://wolfram.com/xid/0j47jhg6-xk2rz

EvaluationMonitor (1)
Record all the points evaluated during the solution process of a function with a ring of minima:

https://wolfram.com/xid/0j47jhg6-cv023g
Plot all the visited points that are close in objective function value to the final solution:

https://wolfram.com/xid/0j47jhg6-di3rpr

Method (2)
Some methods may give suboptimal results for certain problems:

https://wolfram.com/xid/0j47jhg6-ukm3m

The automatically chosen method gives the optimal solution for this problem:

https://wolfram.com/xid/0j47jhg6-yo3qc8

Plot the objective function along with the global minimum value:

https://wolfram.com/xid/0j47jhg6-lo8kgo

Use method "NelderMead" for problems with many variables when speed is essential:

https://wolfram.com/xid/0j47jhg6-cdle4a

StepMonitor (1)
Steps taken by NMinValue in finding the minimum of the classic Rosenbrock function:

https://wolfram.com/xid/0j47jhg6-znwwtn

https://wolfram.com/xid/0j47jhg6-mfc57g

WorkingPrecision (1)
With the working precision set to , by default AccuracyGoal and PrecisionGoal are set to
:

https://wolfram.com/xid/0j47jhg6-9rwm4o

Applications (6)Sample problems that can be solved with this function
Geometry Problems (3)
Find the minimum distance between two disks of radius 1 centered at and
. Let
be a point on disk 1. Let
be a point on disk 2. The objective is to minimize
subject to constraints
:

https://wolfram.com/xid/0j47jhg6-x0rc5a

Find the radius of a minimal enclosing ball that encompasses a given region:

https://wolfram.com/xid/0j47jhg6-1xi3kb
Find the minimum value of the radius subject to the constraints
:

https://wolfram.com/xid/0j47jhg6-fmr9yi

https://wolfram.com/xid/0j47jhg6-rvv1lu

The minimal enclosing ball can be found efficiently using BoundingRegion:

https://wolfram.com/xid/0j47jhg6-1dvvd5


https://wolfram.com/xid/0j47jhg6-uhd7v9

Find the smallest square that can contain circles of given radius
for
that do not overlap. Specify the number of circles and the radius of each circle:

https://wolfram.com/xid/0j47jhg6-m2255i
If is the center of circle
, then the objective is to minimize
. The objective can be transformed so as to minimize
and
:

https://wolfram.com/xid/0j47jhg6-t7gqfm

https://wolfram.com/xid/0j47jhg6-22nk9i

https://wolfram.com/xid/0j47jhg6-yemsm5
The circles are contained in the square . Find the bounds:

https://wolfram.com/xid/0j47jhg6-fazut5

Data-Fitting Problems (1)
Find the Gaussian width parameter that minimizes the residual for an
fit to nonlinear discrete data:

https://wolfram.com/xid/0j47jhg6-j5yzq8
Fit the data using the basis :

https://wolfram.com/xid/0j47jhg6-ialjsr
The function will be approximated by :

https://wolfram.com/xid/0j47jhg6-lylfvc
Construct a parametric function that gives the residual:

https://wolfram.com/xid/0j47jhg6-v27le5
Show the residual as a function of :

https://wolfram.com/xid/0j47jhg6-gtunrb

Find the scaling parameter that produces the minimum residual:

https://wolfram.com/xid/0j47jhg6-ccdtpu

Iterated Optimization (1)
Find parameter such that the distance from the ellipse
to the point (1,2) is as small as possible:

https://wolfram.com/xid/0j47jhg6-bxxiii
Show the distance as a function of :

https://wolfram.com/xid/0j47jhg6-bu8new

Find the optimal parameter that maximizes the reciprocal of the distance:

https://wolfram.com/xid/0j47jhg6-ex5rbu

Visualize the point with respect to the disk:

https://wolfram.com/xid/0j47jhg6-7y5j0

Trajectory Optimization (1)
Find the minimum length of a path between the start and end points while avoiding circular obstacles:

https://wolfram.com/xid/0j47jhg6-b7tj3j

The path is discretized into different points. The distance between these points must be less than
where
is the length to be minimized:

https://wolfram.com/xid/0j47jhg6-518i2b
The points cannot be inside the circular objects:

https://wolfram.com/xid/0j47jhg6-509nls
The start and end points are known:

https://wolfram.com/xid/0j47jhg6-7yhvw9

https://wolfram.com/xid/0j47jhg6-wofkjz
Minimize the length subject to the constraints:

https://wolfram.com/xid/0j47jhg6-7o04by

Properties & Relations (8)Properties of the function, and connections to other functions
NMinimize gives the minimum value and rules for the minimizing values of the variables:

https://wolfram.com/xid/0j47jhg6-cq0ogw

NArgMin gives a list of the minimizing values:

https://wolfram.com/xid/0j47jhg6-dggssc

NMinValue gives only the minimum value:

https://wolfram.com/xid/0j47jhg6-bsp96p

Maximizing a function f is equivalent to minimizing -f:

https://wolfram.com/xid/0j47jhg6-cszj9i


https://wolfram.com/xid/0j47jhg6-0l7ax

For convex problems, ConvexOptimization may be used to obtain additional solution properties:

https://wolfram.com/xid/0j47jhg6-dxo13c


https://wolfram.com/xid/0j47jhg6-mlkbfu


https://wolfram.com/xid/0j47jhg6-bpwocb

For convex problems with parameters, using ParametricConvexOptimization gives a ParametricFunction:

https://wolfram.com/xid/0j47jhg6-omnnb3

The ParametricFunction may be evaluated for values of the parameter:

https://wolfram.com/xid/0j47jhg6-hfii5a

Define a function for the parametric problem using NMinValue:

https://wolfram.com/xid/0j47jhg6-ek8e0c

Compare the speeds of the two approaches:

https://wolfram.com/xid/0j47jhg6-hck5xu

Derivatives of the ParametricFunction can also be computed:

https://wolfram.com/xid/0j47jhg6-fewdju

For convex problems with parametric constraints, RobustConvexOptimization finds an optimum that works for all possible values of the parameters:

https://wolfram.com/xid/0j47jhg6-dgv79

NMinValue may find a smaller minimum value for particular values of the parameters:

https://wolfram.com/xid/0j47jhg6-cm1b9c

The minimizer that gives this value does not satisfy the constraints for all allowed values of and
:

https://wolfram.com/xid/0j47jhg6-gvxgxo


https://wolfram.com/xid/0j47jhg6-dlad5x

The minimum value found for particular values of the parameters is less than or equal to the robust minimum:

https://wolfram.com/xid/0j47jhg6-b0rws

https://wolfram.com/xid/0j47jhg6-e1wtev

NMinValue can solve linear programming problems:

https://wolfram.com/xid/0j47jhg6-mm3mtp

LinearProgramming can be used to solve the same problem given in matrix notation:

https://wolfram.com/xid/0j47jhg6-i8n5ly

https://wolfram.com/xid/0j47jhg6-b7q2kw

Use RegionDistance to compute the minimum distance from a point to a region:

https://wolfram.com/xid/0j47jhg6-f4g5uc

https://wolfram.com/xid/0j47jhg6-lbd2cp

Compute the distance using NMinValue:

https://wolfram.com/xid/0j47jhg6-cl3cvc

Use RegionBounds to compute the bounding box:

https://wolfram.com/xid/0j47jhg6-eqkvxp


https://wolfram.com/xid/0j47jhg6-jf4d0

Use NMaxValue and NMinValue to compute the same bounds:

https://wolfram.com/xid/0j47jhg6-gkt1lb


https://wolfram.com/xid/0j47jhg6-ckoox0

Wolfram Research (2008), NMinValue, Wolfram Language function, https://reference.wolfram.com/language/ref/NMinValue.html (updated 2024).
Text
Wolfram Research (2008), NMinValue, Wolfram Language function, https://reference.wolfram.com/language/ref/NMinValue.html (updated 2024).
Wolfram Research (2008), NMinValue, Wolfram Language function, https://reference.wolfram.com/language/ref/NMinValue.html (updated 2024).
CMS
Wolfram Language. 2008. "NMinValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/NMinValue.html.
Wolfram Language. 2008. "NMinValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/NMinValue.html.
APA
Wolfram Language. (2008). NMinValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NMinValue.html
Wolfram Language. (2008). NMinValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NMinValue.html
BibTeX
@misc{reference.wolfram_2025_nminvalue, author="Wolfram Research", title="{NMinValue}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/NMinValue.html}", note=[Accessed: 31-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_nminvalue, organization={Wolfram Research}, title={NMinValue}, year={2024}, url={https://reference.wolfram.com/language/ref/NMinValue.html}, note=[Accessed: 31-May-2025
]}