ArgMax
Details and Options
- ArgMax finds the global maximum of f subject to the constraints given.
- ArgMax is typically used to find the largest 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 polynomial, ArgMax will always find a global maximum.
- 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,…) Exists[…], ForAll[…] quantified conditions {x,y,…}∈rdom region or domain specification - ArgMax[{f,cons},x∈rdom] is effectively equivalent to ArgMax[{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.
- ArgMax will return exact results if given exact input. With approximate input, it automatically calls NArgMax.
- If the maximum is achieved only infinitesimally outside the region defined by the constraints, or only asymptotically, ArgMax will return the closest specifiable point.
- Even if the same maximum is achieved at several points, only one is returned.
- If the constraints cannot be satisfied, ArgMax returns {Indeterminate,Indeterminate,…}.
- N[ArgMax[…]] calls NArgMax for optimization problems that cannot be solved symbolically.
Examples
open all close allBasic Examples (5)
Find a maximizer point for a univariate function:
ArgMax[-2x ^ 2 - 3x + 5, x]Find a maximizer point for a multivariate function:
ArgMax[1 - (x y - 3) ^ 2, {x, y}]Find a maximizer point for a function subject to constraints:
ArgMax[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]Find a maximizer point as a function of parameters:
ArgMax[a x ^ 2 + b x + c, x]Find a maximizer point for a function over a geometric region:
ArgMax[x + y, {x, y}∈Disk[]]Show[ContourPlot[x + y, {x, y}∈Disk[]], Graphics[{Red, PointSize[Large], Point[%]}]]Scope (36)
Basic Uses (7)
Maximize
over the unconstrained reals:
ArgMax[Sin[x] + Cos[x], {x}]If the single variable is not given in a list, the result is a value at which the maximum is attained:
ArgMax[Sin[x] + Cos[x], x]Maximize
subject to constraints
:
ArgMax[{x + 2y, x ^ 2 + 2y ^ 2 ≤ 3 && x + y == 2 && x ≥ 1}, {x, y}]Constraints may involve arbitrary logical combinations:
ArgMax[{x y, x ^ 2 + y ^ 2 ≤ 1 || (x + 1) ^ 2 + (y - 1) ^ 2 ≤ 2}, {x, y}]ArgMax[{x + y, x ≤ y ^ 2}, {x, y}]ArgMax[{x + y, x ^ 2 + y ^ 2 < 0}, {x, y}]The supremum value may not be attained:
ArgMax[-Exp[x], x]Use a vector variable and a vector inequality:
ArgMax[{{-1, -1}.v, {{1, 2}, {1, 0}}.v{3, -1}}, v]Univariate Problems (7)
Unconstrained univariate polynomial maximization:
ArgMax[-x ^ 4 + 2x ^ 3 + 5x - 7, x]Constrained univariate polynomial maximization:
ArgMax[{-3x ^ 2 - x + 9, 2x ^ 3 + 5x - 7 ≥ 0}, x]ArgMax[-E ^ (2E ^ x) + Log[x ^ 2 + 1] + 20x, x]Analytic functions over bounded constraints:
ArgMax[{AiryAi[x + Sin[x]] + Cos[x ^ 2], -5 ≤ x ≤ 5}, x]Plot[AiryAi[x + Sin[x]] + Cos[x ^ 2], {x, -5, 5}, Epilog -> {Red, Point[{%, AiryAi[x + Sin[x]] + Cos[x ^ 2] /. x -> %}]}]ArgMax[{BesselJ[2, x] / Gamma[x + 1] + (x + 1) ^ Sin[x], 0 ≤ x ≤ 10}, x]Plot[BesselJ[2, x] / Gamma[x + 1] + (x + 1) ^ Sin[x], {x, 0, 10}, Epilog -> {Red, Point[{%, BesselJ[2, x] / Gamma[x + 1] + (x + 1) ^ Sin[x] /. x -> %}]}]ArgMax[{Sin[x], -1 / 2 ≤ Cos[x] ≤ 1 / 2}, x]Combination of trigonometric functions with commensurable periods:
ArgMax[Sin[E ^ (x / 3) - 3 x] + 2 Cos[2 E ^ (x / 3) - 6 x + 1] ^ 2, x]ArgMax[{Floor[x + UnitStep[x - 1]] - x, Ceiling[Abs[x]] < 5}, x]Unconstrained problems solvable using function property information:
ArgMax[SinhIntegral[DawsonF[x]], x]ArgMax[BesselJ[7 / 4, x ^ 2 + x + 1], x]Multivariate Problems (9)
Multivariate linear constrained maximization:
ArgMax[{2x + 3y - z, 1 ≤ x + y + z ≤ 2 && 1 ≤ x - y + z ≤ 2 && x - y - z == 3}, {x, y, z}]Linear-fractional constrained maximization:
ArgMax[{(2x + y - z) / (5x - 7y + 3), 0 ≤ x + y + z ≤ 1 && 1 ≤ x - y + z ≤ 2 && x - y - z == 3}, {x, y, z}]Unconstrained polynomial maximization:
ArgMax[x ^ 2 - 2y - 1 - (x ^ 2 - 2y) ^ 2, {x, y}]Constrained polynomial optimization can always be solved:
ArgMax[{x y - 1, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]The maximum value may not be attained:
ArgMax[{1 - x ^ 2, x y ≥ 1}, {x, y}]The objective function may be unbounded:
ArgMax[{x, x y ≤ 1}, {x, y}]There may be no points satisfying the constraints:
ArgMax[{x, x ^ 2 + y ^ 2 < 0}, {x, y}]Quantified polynomial constraints:
ArgMax[{-(x + 7)^2 - (y - 8)^2, Subscript[∀, z]Subscript[∃, w]3 z^2 w + (x + y) z^4 - 1 == (x^3 - x y + y^2 - 1) w^2}, {x, y}]ArgMax[{-x - Sqrt[x + y] , x Sqrt[y] ≥ 1}, {x, y}]Bounded transcendental maximization:
ArgMax[{E ^ x + Log[y], x Log[y] == 2 && -10 ≤ x ≤ 10 && 1 / 10 ≤ y ≤ 10}, {x, y}]ArgMax[{-Max[x - y, Abs[y]], Min[x - 2, x - y ^ 2] ≥ Abs[x y - 1]}, {x, y}]ArgMax[v.{1, -1}, {VectorGreaterEqual[{{{1, 0}, {0, 1}, {-1, -2}}.v, {0, 0, -2}}, "ExponentialCone"]}, v]Maximize concave objective function
such that
is positive semidefinite and
:
res = ArgMax[{Log[x + y], (| | |
| ----- | ----- |
| x + y | 1 |
| 1 | x - y |)Underscript[, {"SemidefiniteCone", 2}]0 && 1 ≤ x ≤ 10 && -1 ≤ y ≤ 1}, {x, y}]Plot the region and the minimizing point:
Show[Plot3D[Log[x + y], {x, 1, 10}, {y, -1, 1}, ...], Graphics3D[{Red, PointSize[0.05], Point[Append[res, Log[x + y] /. Thread[{x, y} -> res]]]}]]Parametric Problems (4)
Parametric linear optimization:
ArgMax[{8x + 7y, -6 x - 4 y ≤ 8 - 5 a - 7 b && 7 x + 5 y ≤ a + 4 b && -x + y ≤ 6 + 4a - 5 b && -4 x + 7 y ≤ -1 - 2 a - 7 b && 5 y ≤ 6 - 9 b}, {x, y}]Coordinates of the minimizer point are continuous functions of parameters:
GraphicsRow[Plot3D[#, {a, -3, 3}, {b, 0, 3}, Axes -> False]& /@ %, ImageSize -> Medium]Parametric quadratic optimization:
ArgMax[{-(x - 1) ^ 2 - (2y - 1) ^ 2, x + 2y ≤ a + b && 2x - y ≤ a - b + 1 && x - 2y ≤ 2a - b + 1}, {x, y}]Coordinates of the minimizer point are continuous functions of parameters:
GraphicsRow[Plot3D[#, {a, -3, 3}, {b, 0, 3}, Axes -> False]& /@ %, ImageSize -> Medium]Unconstrained parametric polynomial maximization:
ArgMax[-x ^ 4 + a x ^ 2 + b, x]Constrained parametric polynomial maximization:
ArgMax[{-x ^ 2 - y ^ 2, x ^ 3 + y ^ 2 == a}, {x, y}]Optimization over Integers (3)
ArgMax[{x ^ 3 Log[x] - E ^ x, x > 0}, x, Integers]ArgMax[{2x + 3y - z, 1 ≤ x + y + z ≤ 2 && 1 ≤ x - y + z ≤ 2 && x - y - z == 3}, {x, y, z}, Integers]Polynomial maximization over the integers:
ArgMax[{-x ^ 2 - x y + 1, x y ≥ 1}, {x, y}, Integers]Optimization over Regions (6)
ℛ = Cylinder[{{1, 2, 3}, {3, 2, 1}}, 1];ArgMax[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)}}];ArgMax[(x - u)^2 + (y - v)^2, {{x, y}∈Subscript[ℛ, 1], {u, v}∈Subscript[ℛ, 2]}]//RootReduceGraphics[{{StandardBlue, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}, {Red, Point[Partition[%, 2]]}}]Find the maximum
such that the triangle and ellipse still intersect:
Subscript[ℛ, 1] = Triangle[{{0, 0}, {1, 0}, {0, 1}}];
Subscript[ℛ, 2] = Circle[{(1/3), (1/3)}, {2 r, r}];ArgMax[{r, {x, y}∈Subscript[ℛ, 1] && {x, y}∈Subscript[ℛ, 2]}, {r, x, y}]Graphics[{{StandardBlue, 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}];ArgMax[{r, ({0, 0} | {1, 0} | {0, 1})∈Subscript[ℛ, 3]}, {a, b, r}]Graphics[{{StandardBlue, Subscript[ℛ, 3]} /. Thread[{a, b, r} -> %], {Red, Point[{{0, 0}, {1, 0}, {0, 1}}]}}]Use
to specify that
is a vector in
:
ℛ = Sphere[];ArgMax[x.{1, 2, 3}, 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];ArgMax[(x - y).(x - y), {x∈Subscript[ℛ, 1], y∈Subscript[ℛ, 2]}]//RootReduceGraphics[{{StandardBlue, Subscript[ℛ, 1], Subscript[ℛ, 2]}, {Red, Point[%]}}]Options (2)
Method (1)
Specify that ArgMax should use cylindrical algebraic decomposition:
maxcad = ArgMax[{x ^ 2 - y ^ 3 + 2x y, x ^ 2 + y ^ 2 == 1}, {x, y}, Method -> "CAD"]maxlm = ArgMax[{x ^ 2 - y ^ 3 + 2x y, x ^ 2 + y ^ 2 == 1}, {x, y}, Method -> "LagrangeMultipliers"]maxdef = ArgMax[{x ^ 2 - y ^ 3 + 2x y, x ^ 2 + y ^ 2 == 1}, {x, y}]RootReduce[maxcad] === RootReduce[maxlm] === RootReduce[maxdef]WorkingPrecision (1)
Finding an exact maximum point can take a long time:
TimeConstrained[ArgMax[{x ^ 2 + y ^ 2 + z ^ 2, x ^ 2 - 3 x y z + 9 z ^ 2 + y ^ 2 == E && x y z ≤ Pi}, {x, y, z}], 60]With WorkingPrecision->200, you get an approximate maximum point:
ArgMax[{x ^ 2 + y ^ 2 + z ^ 2, x ^ 2 - 3 x y z + 9 z ^ 2 + y ^ 2 == E && x y z ≤ Pi}, {x, y, z}, WorkingPrecision -> 200]//TimingApplications (15)
Basic Applications (3)
Find the lengths of sides of a unit perimeter rectangle with the maximal area:
ArgMax[{x y, 2x + 2y == 1 && x > 0 && y > 0}, {x, y}]Find the lengths of sides of a unit perimeter triangle with the maximal area:
triangle = a > 0 && b > 0 && c > 0 && a + b > c && a + c > b && b + c > a;
s = 1 / 2(a + b + c);ArgMax[{Sqrt[s(s - a)(s - b)(s - c)], triangle && a + b + c == 1}, {a, b, c}]Find the time at which a projectile reaches the maximum height:
ArgMax[ {v Sin[α] t - 5 t ^ 2, t ≥ 0 && 0 < Sin[α] ≤ 1 && v > 0}, t]Refine[%, 0 < Sin[α] ≤ 1 && v > 0]Geometric Distances (9)
The point q in a region ℛ that is farthest from a given point p is given by ArgMax[{Norm[p-q],q∈ℛ},q]. Find the farthest point in Disk[] from {1,1}:
p = {1, 1};
ℛ = Disk[];q = Simplify@ArgMax[Norm[p - {q1, q2}], {q1, q2}∈ℛ]Graphics[{{StandardBlue, EdgeForm[Gray], ℛ}, {Red, Point[{p, q}]}, {Dashed, Line[{p, q}]}}]Find the farthest point from {1,2} in the standard unit simplex Simplex[2]:
p = {1, 2};
ℛ = Simplex[{{0, 0}, {1, 0}, {0, 1}}];q = Simplify@ArgMax[Norm[p - {q1, q2}], {q1, q2}∈ℛ]Graphics[{{StandardBlue, EdgeForm[Gray], ℛ}, {Red, Point[{p, q}]}, {Dashed, Line[{p, q}]}}]Find the farthest point from {1,1,1} in the standard unit sphere Sphere[]:
p = {1, 1, 1};
ℛ = Sphere[];q = Simplify@ArgMax[Norm[p - {q1, q2, q3}], {q1, q2, q3}∈ℛ]Graphics3D[{{Opacity[0.5], ℛ}, {Red, Point[{p, q}]}, {Dashed, Line[{p, q}]}}]Find the farthest point from {-1,1,1} in the standard unit simplex Simplex[3]:
p = {-1, 1, 1};
ℛ = Simplex[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}];q = Simplify@ArgMax[Norm[p - {q1, q2, q3}], {q1, q2, q3}∈ℛ]Graphics3D[{{Opacity[0.5], ℛ}, {Red, Point[{p, q}]}, {Dashed, Line[{p, q}]}}]The diameter of a region ℛ is given by the distance between the farthest points in ℛ, which can be computed through ArgMax[Norm[p-q],{q∈ℛ,p∈ℛ}]. Find the diameter of Circle[]:
ℛ = Circle[];{pt, qt} = ArgMax[Norm[p - q], {q∈ℛ, p∈ℛ}]Norm[pt - qt]//SimplifyGraphics[{{ℛ}, {Red, Point[{pt, qt}]}, {Dashed, Line[{pt, qt}]}}]Find the diameter of the standard unit simplex Simplex[2]:
ℛ = Simplex[{{0, 0}, {1, 0}, {0, 1}}];{pt, qt} = ArgMax[Norm[p - q], {q∈ℛ, p∈ℛ}]Norm[pt - qt]Graphics[{{StandardBlue, EdgeForm[Gray], ℛ}, {Red, Point[{pt, qt}]}, {Dashed, Line[{pt, qt}]}}]Find the diameter of the standard unit cube Cuboid[]:
ℛ = Cuboid[];{pt, qt} = ArgMax[Norm[p - q], {q∈ℛ, p∈ℛ}]Norm[pt - qt]//SimplifyGraphics3D[{{Opacity[0.5], ℛ}, {Red, Point[{pt, qt}]}, {Dashed, Line[{pt, qt}]}}]The farthest points p∈ and q∈ can be found through ArgMax[Norm[p-q],{p∈,q∈}]. Find the farthest points in Disk[{0,0}] and Rectangle[{3,3}]:
𝒫 = Disk[{0, 0}]; 𝒬 = Rectangle[{3, 3}];{pt, qt} = Simplify@ArgMax[Norm[p - q], {p∈𝒫, q∈𝒬}]Norm[pt - qt]//SimplifyGraphics[{{StandardBlue, EdgeForm[Gray], 𝒫, 𝒬}, {Red, Point[{pt, qt}]}, {Dashed, Line[{pt, qt}]}}]Find the farthest points in Line[{{0,0,0},{1,1,1}}] and Ball[{5,5,0},1]:
𝒫 = Line[{{0, 0, 0}, {1, 1, 1}}]; 𝒬 = Ball[{5, 5, 0}, 1];{pt, qt} = Simplify@ArgMax[Norm[p - q], {p∈𝒫, q∈𝒬}]Norm[pt - qt]//SimplifyGraphics3D[{{𝒫, {Opacity[0.5], 𝒬}}, {Red, Point[{pt, qt}]}, {Dashed, Line[{pt, qt}]}}]Geometric Centers (3)
If ℛ⊆n is a region that is full dimensional, then the Chebyshev center is the point p∈ℛ that maximizes -SignedRegionDistance[ℛ,p], i.e. the distance to the complement region. Find the Chebyshev center for Disk[]:
ℛ = Disk[];p = ArgMax[-SignedRegionDistance[ℛ, {p1, p2}], {p1, p2}∈ℛ]Graphics[{{StandardBlue, EdgeForm[Gray], ℛ}, {Red, Point[p]}}]Find the Chebyshev center for Rectangle[]:
ℛ = Rectangle[];p = ArgMax[-SignedRegionDistance[ℛ, {p1, p2}], {p1, p2}∈ℛ]Graphics[{{StandardBlue, EdgeForm[Gray], ℛ}, {Red, Point[p]}}]The analytic center of a region defined by inequalities ℛ=ImplicitRegion[f1[x]≥0∧⋯∧fm[x]≥0,x] is given by ArgMax[{Log[f1[x]⋯ fm[x]],x∈ℛ},x]. Find the analytic center for Triangle[{{0,0},{1,0},{0,1}}]:
RegionMember[Triangle[{{0, 0}, {1, 0}, {0, 1}}], {x, y}]From the conditions above you have an inequality representation:
{f1, f2, f3} = {x, y, 1 - x - y};c = ArgMax[Log[f1 f2 f3], {x, y}∈Triangle[{{0, 0}, {1, 0}, {0, 1}}]]Graphics[{{StandardBlue, EdgeForm[Gray], Triangle[{{0, 0}, {1, 0}, {0, 1}}]}, {Red, Point[c]}}]Find the analytic center for Cylinder[]:
RegionMember[Cylinder[], {x, y, z}]Hence you get the inequality representation:
{f1, f2, f3} = {(1 + z) / 2, 1 - (1 + z) / 2, 1 - (x^2 + y^2)};c = ArgMax[Log[f1 f2 f3], {x, y, z}∈Cylinder[]]Graphics3D[{{Opacity[0.3], Cylinder[]}, {Red, Point[c]}}]Properties & Relations (4)
Maximize gives both the value of the maximum and the maximizer point:
Maximize[{x - 2y, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]ArgMax gives an exact global maximizer point:
f = Expand[-Product[(x - i)(x - 100 - i), {i, 5}]];ArgMax[f, x]Plot[f, {x, 0, 100}, Epilog -> {PointSize[Medium], Green, Point[{%, f /. x -> %}]}]NArgMax attempts to find a global maximizer numerically, but may find a local maximizer:
NArgMax[f, x]Plot[f, {x, 0.5, 5.5}, Epilog -> {PointSize[Medium], Red, Point[{%, f /. x -> %}]}]FindArgMax finds a local maximizer point depending on the starting point:
FindArgMax[f, {x, #}]& /@ {1, 50}Plot[f, {x, 0, 100}, Epilog -> {PointSize[Medium], {Red, Point[{%[[1, 1]], f /. x -> %[[1, 1]]}]}, {Green, Point[{%[[2, 1]], f /. x -> %[[2, 1]]}]}}]The maximum point satisfies the constraints, unless messages say otherwise:
m = ArgMin[{(x - 2) ^ 2 + (y - 3 / 2) ^ 2, x ^ 2 + y ^ 2 ≤ 1}, {x, y}]x ^ 2 + y ^ 2 ≤ 1 /. Thread[{x, y} -> m]The given point maximizes the distance from the point {2,
}:
RegionPlot[x ^ 2 + y ^ 2 ≤ 1, {x, -1.2, 2.2}, {y, -1.2, 2.2}, Epilog -> {PointSize[Medium], {Red, Point[m]}, {Green, Point[{2, 3 / 2}]}}]When the maximum is not attained, ArgMax may give a point on the boundary:
ArgMax[{(x - 2) ^ 2 + (y - 3 / 2) ^ 2, x ^ 2 + y ^ 2 < 1}, {x, y}]Here the objective function tends to the maximum value when y tends to infinity:
ArgMax[{1 - x, x y == 1 && x > 0}, {x, y}]ArgMax can solve linear optimization problems:
res = ArgMax[{2x + 3y - z, 1 ≤ x + y + z ≤ 2 && 1 ≤ x - y + z ≤ 2 && x - y - z == 3}, {x, y, z}]LinearOptimization can be used to solve the same problem by negating the objective:
LinearOptimization[-(2x + 3y - z), {1 ≤ x + y + z ≤ 2 && 1 ≤ x - y + z ≤ 2
&& x - y - z == 3}, {x, y, z}]Possible Issues (2)
The maximum value may not be attained:
ArgMax[{1 - x ^ 2, x y ≥ 1}, {x, y}]The objective function may be unbounded:
ArgMax[{x, x y ≤ 1}, {x, y}]There may be no points satisfying the constraints:
ArgMax[{x, x ^ 2 + y ^ 2 < 0}, {x, y}]ArgMax requires that all functions present in the input be real valued:
ArgMax[{-x - y, Sqrt[x] - Sqrt[y] == 0}, {x, y}]Values for which the equation is satisfied but the square roots are not real are disallowed:
{Sqrt[x] - Sqrt[y] == 0, Sqrt[x], Sqrt[y]} /. {x -> -1, y -> -1}Related Guides
History
Introduced in 2008 (7.0) | Updated in 2014 (10.0) ▪ 2021 (12.3)
Text
Wolfram Research (2008), ArgMax, Wolfram Language function, https://reference.wolfram.com/language/ref/ArgMax.html (updated 2021).
CMS
Wolfram Language. 2008. "ArgMax." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ArgMax.html.
APA
Wolfram Language. (2008). ArgMax. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ArgMax.html
BibTeX
@misc{reference.wolfram_2026_argmax, author="Wolfram Research", title="{ArgMax}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ArgMax.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_argmax, organization={Wolfram Research}, title={ArgMax}, year={2021}, url={https://reference.wolfram.com/language/ref/ArgMax.html}, note=[Accessed: 13-June-2026]}