Maximize

Maximize[f,x]

maximizes f with respect to x.

Maximize[f,{x,y,}]

maximizes f with respect to x, y, .

Maximize[{f,cons},{x,y,}]

maximizes f subject to the constraints cons.

Maximize[,xreg]

constrains x to be in the region reg.

Maximize[,,dom]

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

Details and Options

  • Maximize returns a list of the form {fmax,{x->xmax,y->ymax,}}.
  • cons can contain equations, inequalities, or logical combinations of these.
  • The constraints cons can be any logical combination of:
  • lhs==rhsequations
    lhs!=rhsinequations
    lhs>rhs or lhs>=rhs inequalities
    {x,y,}regregion specification
    Exists[x,cond,expr]existential quantifiers
  • If f and cons are linear or polynomial, Maximize will always find a global maximum.
  • Maximize[{f,cons},xreg] is effectively equivalent to Maximize[{f,consxreg},x].
  • For xreg, the different coordinates can be referred to using Indexed[x,i].
  • Maximize will return exact results if given exact input.
  • If Maximize is given an expression containing approximate numbers, it automatically calls NMaximize.
  • 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.
  • If no domain is specified, all variables are assumed to be real.
  • xIntegers can be used to specify that a particular variable can take on only integer values.
  • If the constraints cannot be satisfied, Maximize returns {-Infinity,{x->Indeterminate,}}.
  • 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  (21)

Unconstrained univariate polynomial maximization:

Constrained univariate polynomial maximization:

Univariate transcendental maximization:

Univariate piecewise maximization:

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:

Algebraic maximization:

Bounded transcendental maximization:

Piecewise maximization:

Unconstrained parametric maximization:

Constrained parametric maximization:

Integer linear programming:

Polynomial maximization over the integers:

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:

Introduced in 2003
 (5.0)
 |
Updated in 2014
 (10.0)