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[,xrdom]

constrains x to be in the region or domain rdom.

Maximize[,,dom]

constrains variables to the domain dom, typically Reals or Integers.

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==rhsequations
    lhs>rhs, lhsrhs, lhs<rhs, lhsrhsinequalities (LessEqual,)
    lhsrhs, lhsrhs, lhsrhs, lhsrhsvector inequalities (VectorLessEqual,)
    Exists[], ForAll[]quantified conditions
    {x,y,}rdomregion or domain specification
  • Maximize[{f,cons},xrdom] is effectively equivalent to Maximize[{f,consxrdom},x].
  • For xrdom, the different coordinates can be referred to using Indexed[x,i].
  • Possible domains rdom include:
  • Realsreal scalar variable
    Integersinteger 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 all

Basic Examples  (5)

Maximize a univariate function:

Maximize a multivariate function:

Maximize a function subject to constraints:

A maximization problem containing parameters:

Maximize a function over a geometric region:

Plot it:

Scope  (36)

Basic Uses  (7)

Maximize over the unconstrained reals:

Maximize subject to constraints :

Constraints may involve arbitrary logical combinations:

An unbounded problem:

An infeasible problem:

The supremum value may not be attained:

Use a vector variable and a vector inequality:

Univariate Problems  (7)

Unconstrained univariate polynomial maximization:

Constrained univariate polynomial maximization:

Exp-log functions:

Analytic functions over bounded constraints:

Periodic functions:

Combination of trigonometric functions with commensurable periods:

Combination of periodic functions with incommensurable periods:

Piecewise functions:

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:

Algebraic maximization:

Bounded transcendental maximization:

Piecewise maximization:

Convex maximization:

Maximize concave objective function such that is positive semidefinite and :

Plot the region and the minimizing point:

Parametric Problems  (4)

Parametric linear optimization:

The maximum value is a continuous function of parameters:

Parametric quadratic optimization:

The maximum value is a continuous function of parameters:

Unconstrained parametric polynomial maximization:

Constrained parametric polynomial maximization:

Optimization over Integers  (3)

Univariate problems:

Integer linear programming:

Polynomial maximization over the integers:

Optimization over Regions  (6)

Maximize over a region:

Plot it:

Find the maximum distance between points in two regions:

Plot it:

Find the maximum such that the triangle and ellipse still intersect:

Plot it:

Find the maximum for which contains the given three points:

Plot it:

Use to specify that is a vector in :

Find the maximum distance between points in two regions:

Plot it:

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)

Find the maximal area among rectangles with a unit perimeter:

Find the maximal area among triangles with a unit perimeter:

Find the maximum height reached by a projectile:

Find the maximum range of a projectile:

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[]:

Plot it:

Find the largest distance and the farthest point from {1,3/4} in the standard unit simplex Simplex[2]:

Plot it:

Find the largest distance and the farthest point from {1,1,1} in the standard unit sphere Sphere[]:

Plot it:

Find the largest distance and the farthest point from {-1/3,1/3,1/3} in the standard unit simplex Simplex[3]:

Plot it:

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[]:

Plot it:

Find the diameter and a pair of farthest points in the standard unit simplex Simplex[2]:

Plot it:

Find the diameter and a pair of farthest points in the standard unit cube Cuboid[]:

Plot it:

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:

Plot it:

Find the farthest points in Line[{{0,0,0},{1,1,1}}] and Ball[{5,5,0},1] and the distance between them:

Plot it:

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:

Use Maximize and Minimize to compute the same bounds:

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:

Wolfram Research (2003), Maximize, Wolfram Language function, https://reference.wolfram.com/language/ref/Maximize.html (updated 2021).

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

BibTeX

@misc{reference.wolfram_2024_maximize, author="Wolfram Research", title="{Maximize}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/Maximize.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_maximize, organization={Wolfram Research}, title={Maximize}, year={2021}, url={https://reference.wolfram.com/language/ref/Maximize.html}, note=[Accessed: 22-November-2024 ]}