This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Minimization and Maximization

Minimize[expr,{x1,x2,...}]minimize expr
Minimize[{expr,cons},{x1,x2,...}]minimize expr subject to the constraints cons
Maximize[expr,{x1,x2,...}]maximize expr
Maximize[{expr,cons},{x1,x2,...}]maximize expr subject to the constraints cons

Minimization and maximization.

Minimize and Maximize yield lists giving the value attained at the minimum or maximum, together with rules specifying where the minimum or maximum occurs.
This finds the minimum of a quadratic function.
Click for copyable input
Applying the rule for x gives the value at the minimum.
Click for copyable input
This maximizes with respect to x and y.
Click for copyable input
Minimize[expr, x] minimizes expr allowing x to range over all possible values from - to +. Minimize[{expr, cons}, x] minimizes expr subject to the constraints cons being satisfied. The constraints can consist of any combination of equations and inequalities.
This finds the minimum subject to the constraint x≥3.
Click for copyable input
This finds the maximum within the unit circle.
Click for copyable input
This finds the maximum within an ellipse. The result is fairly complicated.
Click for copyable input
This finds the maximum along a line.
Click for copyable input
Minimize and Maximize can solve any linear programming problem in which both the objective function expr and the constraints cons involve the variables xi only linearly.
Here is a typical linear programming problem.
Click for copyable input
They can also in principle solve any polynomial programming problem in which the objective function and the constraints involve arbitrary polynomial functions of the variables. There are many important geometrical and other problems that can be formulated in this way.
This solves the simple geometrical problem of maximizing the area of a rectangle with fixed perimeter.
Click for copyable input
This finds the maximal volume of a cuboid that fits inside the unit sphere.
Click for copyable input
An important feature of Minimize and Maximize is that they always find global minima and maxima. Often functions will have various local minima and maxima at which derivatives vanish. But Minimize and Maximize use global methods to find absolute minima or maxima, not just local extrema.
Here is a function with many local maxima and minima.
Click for copyable input
Maximize finds the global maximum.
Click for copyable input
If you give functions that are unbounded, Minimize and Maximize will return - and + as the minima and maxima. And if you give constraints that can never be satisfied, they will return + and - as the minima and maxima, and Indeterminate as the values of variables.
One subtle issue is that Minimize and Maximize allow both nonstrict inequalities of the form x<=v, and strict ones of the form x<v. With nonstrict inequalities there is no problem with a minimum or maximum lying exactly on the boundary x->v. But with strict inequalities, a minimum or maximum must in principle be at least infinitesimally inside the boundary.
With a strict inequality, Mathematica prints a warning, then returns the point on the boundary.
Click for copyable input
Minimize and Maximize normally assume that all variables you give are real. But by giving a constraint such as xIntegers you can specify that a variable must in fact be an integer.
This does maximization only over integer values of x and y.
Click for copyable input
Minimize and Maximize can compute maxima and minima of linear functions over the integers in bounded polyhedra. This is known as integer linear programming.
This does maximization over integer values of x and y in a triangle.
Click for copyable input
Minimize and Maximize can produce exact symbolic results for polynomial optimization problems with parameters.
This finds the minimum of a general quadratic polynomial.
Click for copyable input