FindArgMax[f,x]
gives the position xmax of a local maximum of f.
FindArgMax[f,{x,x0}]
gives the position xmax of a local maximum of f, found by a search starting from the point x=x0.
FindArgMax[f,{{x,x0},{y,y0},…}]
gives the position {xmax,ymax,…} of a local maximum of a function of several variables.
FindArgMax[{f,cons},{{x,x0},{y,y0},…}]
gives the position of a local maximum subject to the constraints cons.
FindArgMax[{f,cons},{x,y,…}]
starts from a point within the region defined by the constraints.
FindArgMax
FindArgMax[f,x]
gives the position xmax of a local maximum of f.
FindArgMax[f,{x,x0}]
gives the position xmax of a local maximum of f, found by a search starting from the point x=x0.
FindArgMax[f,{{x,x0},{y,y0},…}]
gives the position {xmax,ymax,…} of a local maximum of a function of several variables.
FindArgMax[{f,cons},{{x,x0},{y,y0},…}]
gives the position of a local maximum subject to the constraints cons.
FindArgMax[{f,cons},{x,y,…}]
starts from a point within the region defined by the constraints.
Details and Options
- FindArgMax[…,{x,y,…}] is effectively equivalent to {x,y,…}/.Last[FindMaximum[…,{x,y,…},…]].
- If the starting point for a variable is given as a list, the values of the variable are taken to be lists with the same dimensions.
- cons can contain equations, inequalities or logical combinations of these.
- The constraints cons can be any logical combination of:
-
lhs==rhs equations lhs>rhs or lhs>=rhs inequalities {x,y,…}∈reg region specification - FindArgMax first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically.
- FindArgMax has attribute HoldAll, and effectively uses Block to localize variables.
- FindArgMax[f,{x,x0,x1}] searches for a local maximum in f using x0 and x1 as the first two values of x, avoiding the use of derivatives.
- FindArgMax[f,{x,x0,xmin,xmax}] searches for a local maximum, stopping the search if x ever gets outside the range xmin to xmax.
- Except when f and cons are both linear, the results found by FindArgMax may correspond only to local, but not global, maxima.
- By default, all variables are assumed to be real.
- For linear f and cons, x∈Integers can be used to specify that a variable can take on only integer values.
- FindArgMax takes the same options as FindMaximum.
-
AccuracyGoal Automatic the accuracy sought EvaluationMonitor None expression to evaluate whenever f is evaluated Gradient Automatic the list of gradient functions {D[f,x],D[f,y],…} MaxIterations Automatic maximum number of iterations to use Method Automatic method to use PrecisionGoal Automatic the precision sought StepMonitor None expression to evaluate whenever a step is taken WorkingPrecision MachinePrecision the precision used in internal computations
List of all options
Examples
open all close allBasic Examples (4)
Find a point {x} at which the univariate function -2x^2-3x+5 has a maximum:
FindArgMax[-2x ^ 2 - 3x + 5, x]Find a point {x,y} at which the function Sin[x]Sin[2y] has a maximum:
FindArgMax[Sin[x]Sin[2y], {x, y}]Find a point at which a function is a maximum subject to constraints:
FindArgMax[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]Find a maximizer point for a function over a geometric region:
FindArgMax[{x + y, {x, y}∈Disk[]}, {x, y}]Show[ContourPlot[x + y, {x, y}∈Disk[]], Graphics[{Red, PointSize[Large], Point[%]}]]Scope (12)
With different starting points, get the locations of different local maxima:
FindArgMax[x Cos[x], {x, 5}]FindArgMax[x Cos[x], {x, 10}]Location of a local maximum of a two-variable function starting from x=2, y=2:
FindArgMax[Sin[x]Sin[2y], {{x, 2}, {y, 2}}]Location of a local maximum constrained within a disk:
FindArgMax[{Sin[x]Sin[2y], x ^ 2 + y ^ 2 < 3}, {{x, 2}, {y, 2}}]Starting point does not have to be provided:
FindArgMax[{Sin[x]Sin[2y], x ^ 2 + y ^ 2 < 3}, {x, y}]For linear objective and constraints, integer constraints can be imposed:
FindArgMax[{-x - y, 3x + 2y ≥ 7 && x ≥ 0 && y ≥ 0}, {x, y}]FindArgMax[{-x - y, 3x + 2y ≥ 7 && x ≥ 0 && y ≥ 0 && x∈Integers}, {x, y}]Or constraints can be specified:
FindArgMax[{x + y, x ^ 2 + y ^ 2 ≤ 1 || (x + 2) ^ 2 + (y + 2) ^ 2 ≤ 1}, {x, y}]ℛ = Cylinder[{{-1, 0, 1}, {1, 0, -1}}, 1];FindArgMax[{z, {x, y, z}∈ℛ}, {x, y, z}]Graphics3D[{{Opacity[0.5], Green, ℛ}, {Red, PointSize[Large], Point[%]}}]Find points in two regions realizing the maximum distance:
Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = Line[{{-(1/2), -(1/2)}, {-(1/2), (1/2)}, {(1/2), (1/2)}, {(1/2), -(1/2)}, {-(1/2), -(1/2)}}];FindArgMax[{(x - u)^2 + (y - v)^2, {{x, y}∈Subscript[ℛ, 1], {u, v}∈Subscript[ℛ, 2]}}, {x, y, u, v}]Graphics[{{LightBlue, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}, {Red, Point[Partition[%, 2]]}}]Find the maximum
such that the rectangle and ellipse still intersect:
Subscript[ℛ, 1] = Rectangle[];
Subscript[ℛ, 2] = Circle[{(1/3), (1/3)}, {2 r, r}];FindArgMax[{r, {x, y}∈Subscript[ℛ, 1] && {x, y}∈Subscript[ℛ, 2]}, {r, x, y}]Graphics[{{LightBlue, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}, {Red, Point[{x, y}]}} /. Thread[{r, x, y} -> %]]Find the maximum
for which
contains the given three points:
Subscript[ℛ, 3] = Disk[{a, b}, {r, 2 - r}];FindArgMax[{r, ({0, 0} | {1, 0} | {0, 1})∈Subscript[ℛ, 3]}, {a, b, r}]Graphics[{{LightBlue, Subscript[ℛ, 3]} /. Thread[{a, b, r} -> %], {Red, Point[{{0, 0}, {1, 0}, {0, 1}}]}}]Use
to specify that
is a vector in
:
ℛ = Sphere[];FindArgMax[{x.{1, 2, 3}, x∈ℛ}, x]Find points in two regions realizing the maximum distance:
Subscript[ℛ, 1] = Triangle[{{0, 0}, {1, 0}, {0, 1}}];
Subscript[ℛ, 2] = Disk[{2, 2}, 1];FindArgMax[{EuclideanDistance[x, y], {x∈Subscript[ℛ, 1], y∈Subscript[ℛ, 2]}}, {x, y}]Graphics[{{LightBlue, Subscript[ℛ, 1], Subscript[ℛ, 2]}, {Red, Point[%]}}]Options (7)
AccuracyGoal & PrecisionGoal (2)
This enforces convergence criteria
and
:
FindArgMax[Sin[x / 2], {x, 1}, AccuracyGoal -> 9, PrecisionGoal -> 8]This enforces convergence criteria
and
:
FindArgMax[Sin[x / 2], {x, 1}, AccuracyGoal -> 20, PrecisionGoal -> 18]Setting a high WorkingPrecision makes the process convergent:
FindArgMax[Sin[x / 2], {x, 1}, AccuracyGoal -> 20, PrecisionGoal -> 18, WorkingPrecision -> 40]EvaluationMonitor (1)
Gradient (1)
Use a given gradient; the Hessian is computed automatically:
FindArgMax[Sin[x]Sin[2 y], {x, y}, Gradient -> {Cos[x] Sin[2 y], 2 Cos[2 y] Sin[x]}, Method -> "Newton"]Supply both gradient and Hessian:
FindArgMax[Sin[x]Sin[2y], {x, y}, Gradient -> {Cos[x] Sin[2 y], 2 Cos[2 y] Sin[x]}, Method -> {"Newton", Hessian -> {{-Sin[x] Sin[2 y], 2 Cos[x] Cos[2 y]}, {2 Cos[x] Cos[2 y], -4 Sin[x] Sin[2 y]}}}]Method (1)
In this case the default derivative-based methods have difficulties:
FindArgMax[-RealAbs[x + 1] - RealAbs[x + 1.01] - RealAbs[y + 1], {x, y}]FindArgMax[-RealAbs[x + 1] - RealAbs[x + 1.01] - RealAbs[y + 1], {x, y}, Method -> "ConjugateGradient"]Direct search methods that do not require derivatives can be helpful in these cases:
FindArgMax[-RealAbs[x + 1] - RealAbs[x + 1.01] - RealAbs[y + 1], {x, y}, Method -> "PrincipalAxis"]NMaximize also uses a range of direct search methods:
NMaximize[{-RealAbs[x + 1] - RealAbs[x + 1.01] - RealAbs[y + 1]}, {x, y}]StepMonitor (1)
Steps taken by FindArgMax in finding the maximum of a function:
pts = Reap[FindArgMax[-(1 - x) ^ 2 - 100(-x ^ 2 - y) ^ 2 - 1, {{x, -1.2}, {y, 1}}, StepMonitor :> Sow[{x, y}]]][[2, 1]];
pts = Join[{{-1.2, 1}}, pts];ContourPlot[-(1 - x) ^ 2 - 100(-x ^ 2 - y) ^ 2 - 1//Minus//Log, {x, -1.3, 1.5}, {y, -1.5, 1.4}, Epilog -> {Red, Line[pts], Point[pts]}]WorkingPrecision (1)
Set the working precision to
; by default AccuracyGoal and PrecisionGoal are set to
:
FindArgMax[Cos[x ^ 2 - 3 y] + Sin[x ^ 2 + y ^ 2], {x, y}, Method -> "Newton", WorkingPrecision -> 20]Properties & Relations (1)
FindMaximum gives both the value of the maximum and the maximizer point:
FindMaximum[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindArgMax gives the location of the maximum:
FindArgMax[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]FindMaxValue gives the value at the maximum:
FindMaxValue[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]Possible Issues (4)
If the constraint region is empty, the algorithm will not converge:
FindArgMax[{x + y, x ^ 2 + y ^ 2 ≥ 2 && x ^ 2 + y ^ 2 ≤ 1}, {x, y}]If the maximum value is not finite, the algorithm will not converge:
FindArgMax[Tan[x], {x, 2}]FindArgMax[{x ^ 2 + y ^ 2, x ^ 2 + y ^ 2 > 10}, {x, y}]Integer linear programming algorithm is only available for machine-number problems:
FindArgMax[{-x - y, x + 2y ≥ 3 && x > 1 && y > 1 && x∈Integers}, {x, y}, WorkingPrecision -> 20]Sometimes providing a suitable starting point can help the algorithm to converge:
FindArgMax[-x * Sin[1 / x] ^ 2, {x}]FindArgMax[-x * Sin[1 / x] ^ 2, {x, .3}]Related Guides
Text
Wolfram Research (2008), FindArgMax, Wolfram Language function, https://reference.wolfram.com/language/ref/FindArgMax.html (updated 2014).
CMS
Wolfram Language. 2008. "FindArgMax." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/FindArgMax.html.
APA
Wolfram Language. (2008). FindArgMax. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindArgMax.html
BibTeX
@misc{reference.wolfram_2026_findargmax, author="Wolfram Research", title="{FindArgMax}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/FindArgMax.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_findargmax, organization={Wolfram Research}, title={FindArgMax}, year={2014}, url={https://reference.wolfram.com/language/ref/FindArgMax.html}, note=[Accessed: 12-June-2026]}