Mathematica > Mathematics and Algorithms > Optimization >

NMaxValue

NMaxValue[f, x]
gives the maximum value of f with respect to x.
NMaxValue[f, {x, y, ...}]
gives the maximum value of f with respect to x, y, ....
NMaxValue[{f, cons}, {x, y, ...}]
gives the maximum value of f subject to the constraints cons.
  • cons can contain equations, inequalities or logical combinations of these.
  • NMaxValue always attempts to find a global maximum of f subject to the constraints given.
  • By default, all variables are assumed to be real.
  • xElementIntegers can be used to specify that a variable can take on only integer values.
  • If f and cons are linear, NMaxValue can always find global maxima, over both real and integer values.
  • Otherwise, NMaxValue may sometimes find only a local maximum.
  • If NMaxValue determines that the constraints cannot be satisfied, it returns -Infinity.
Find the maximum value of a univariate function:
In[1]:=
Click for copyable input
Out[1]=
 
Find the maximum value of a multivariate function:
In[1]:=
Click for copyable input
Out[1]=
 
Find the maximum value of a function subject to constraints:
In[1]:=
Click for copyable input
Out[1]=
New in 7
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team