Maximize
Maximize[f,x]
maximizes f symbolically with respect to x.
Maximize[f,{x,y,…}]
maximizes f symbolically with respect to x, y, ….
Maximize[{f,cons},{x,y,…}]
maximizes f symbolically subject to the constraints cons.
Maximize[…,x∈rdom]
constrains x to be in the region or domain rdom.
Details and Options



- Maximize is also known as supremum, symbolic optimization and global optimization (GO).
- Maximize finds the global maximum of f subject to the constraints given.
- Maximize 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.
- Maximize returns a list of the form {fmax,{x->xmax,y->ymax,…}}.
- If f and cons are linear or polynomial, Maximize 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 - Maximize[{f,cons},x∈rdom] is effectively equivalent to Maximize[{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.
- Maximize will return exact results if given exact input. With approximate input, it automatically calls NMaximize.
- Maximize will return the following forms:
-
{fmax,{xxmax,…}} finite maximum {-∞,{xIndeterminate,…}} infeasible, i.e. the constraint set is empty {∞,{xxmax,…}} unbounded, i.e. the values of f can be arbitrarily large - If the maximum is achieved only infinitesimally outside the region defined by the constraints, or only asymptotically, Maximize will return the supremum and the closest specifiable point.
- Even if the same maximum is achieved at several points, only one is returned.
- N[Maximize[…]] calls NMaximize for optimization problems that cannot be solved symbolically.
- Maximize[f,x,WorkingPrecision->n] uses n digits of precision while computing a result. »

Examples
open allclose allBasic Examples (5)
Scope (36)
Basic Uses (7)
Univariate Problems (7)
Unconstrained univariate polynomial maximization:
Constrained univariate polynomial maximization:
Analytic functions over bounded constraints:

Combination of trigonometric functions with commensurable periods:
Combination of periodic functions with incommensurable periods:

Unconstrained problems solvable using function property information:
Multivariate Problems (9)
Multivariate linear constrained maximization:
Linear-fractional constrained maximization:
Unconstrained polynomial maximization:
Constrained polynomial optimization can always be solved:
The maximum value may not be attained:

The objective function may be unbounded:

There may be no points satisfying the constraints:

Quantified polynomial constraints:
Bounded transcendental maximization:
Maximize concave objective function such that
is positive semidefinite and
:
Parametric Problems (4)
Optimization over Integers (3)
Optimization over Regions (6)
Options (1)
WorkingPrecision (1)
Finding the exact solution takes a long time:
With WorkingPrecision->200, you get an exact maximum value, but it might be incorrect:
Applications (13)
Basic Applications (3)
Geometric Distances (9)
The largest distance of a point in a region ℛ to a given point p and a point q realizing the largest distance is given by Maximize[EuclideanDistance[p,q],q∈ℛ]. Find the largest distance and the farthest point from {1,1} in the unit Disk[]:
Find the largest distance and the farthest point from {1,3/4} in the standard unit simplex Simplex[2]:
Find the largest distance and the farthest point from {1,1,1} in the standard unit sphere Sphere[]:
Find the largest distance and the farthest point from {-1/3,1/3,1/3} in the standard unit simplex Simplex[3]:
The diameter of a region ℛ is the maximum distance between two points in ℛ. The diameter and a pair of farthest points in ℛ can be computed through Maximize[EuclideanDistance[p,q],{p∈ℛ,q∈ℛ}]. Find the diameter and a pair of farthest points in Circle[]:
Find the diameter and a pair of farthest points in the standard unit simplex Simplex[2]:
Find the diameter and a pair of farthest points in the standard unit cube Cuboid[]:
The farthest points p∈ and q∈ and their distance can be found through Maximize[EuclideanDistance[p,q],{p∈,q∈}]. Find the farthest points in Disk[{0,0}] and Rectangle[{3,3}] and the distance between them:
Find the farthest points in Line[{{0,0,0},{1,1,1}}] and Ball[{5,5,0},1] and the distance between them:
Geometric Centers (1)
If ℛ⊆n is a region that is full dimensional, then the Chebyshev center is the center of the largest inscribed ball of ℛ. The center and the radius of the largest inscribed ball of ℛ can be found through Maximize[-SignedRegionDistance[ℛ,p], p∈ℛ]. Find the Chebyshev center and the radius of the largest inscribed ball for Rectangle[]:
Find the Chebyshev center and the radius of the largest inscribed ball for Triangle[]:
Properties & Relations (4)
Maximize gives an exact global maximum of the objective function:
NMaximize attempts to find a global maximum numerically, but may find a local maximum:
FindMaximum finds local maxima depending on the starting point:
The maximum point satisfies the constraints, unless messages say otherwise:
The given point maximizes the distance from the point {2,}:
When the maximum is not attained, Maximize may give a point on the boundary:

Here the objective function tends to the maximum value when y tends to infinity:

Maximize can solve linear programming problems:
LinearProgramming can be used to solve the same problem given in matrix notation:
This computes the maximum value:
Use RegionBounds to compute the bounding box:
Possible Issues (1)
Maximize requires that all functions present in the input be real-valued:
Values for which the equation is satisfied but the square roots are not real are disallowed:
Text
Wolfram Research (2003), Maximize, Wolfram Language function, https://reference.wolfram.com/language/ref/Maximize.html (updated 2021).
CMS
Wolfram Language. 2003. "Maximize." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/Maximize.html.
APA
Wolfram Language. (2003). Maximize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Maximize.html