Maximize a function (maximize)
The maximum of an expression and the point where it is reached.
How to write it
maximize(expr, variables)
The greatest value over every real value of the variables.
- expr
- Any expression: a number, a formula, a list or a matrix. Takes an expression.
- variables
- A variable, or a list of variables such as [x, y]. Takes a variable, or a list of variables.
maximize(expr, variables)
Under conditions, over whole unknowns too, and with the least of several linear pieces.
- expr
- The objective first, then its conditions, in brackets. Takes a list.
- variables
- A variable, or a list of variables such as [x, y]. Takes a variable, or a list of variables.
Examples
maximize(-x^2 + 2x, x)In the solver,
Open in the solvermaximize(-x^2 + 2x, x)gives[1, [x -> 1]].maximize([5x + 4y, 6x + 4y <= 24, x + 2y <= 6, x >= 0, y >= 0, [x, y] : integer], [x, y])In the solver,
Open in the solvermaximize([5x + 4y, 6x + 4y <= 24, x + 2y <= 6, x >= 0, y >= 0, [x, y] : integer], [x, y])gives[20, [x -> 4, y -> 0]].maximize([min(x, y, 6 - x - y), x >= 0, y >= 0], [x, y])In the solver,
Open in the solvermaximize([min(x, y, 6 - x - y), x >= 0, y >= 0], [x, y])gives[2, [x -> 2, y -> 2]].maximize([x^2 + y^2, x + 2y <= 8, 3x + y <= 9, x >= 0, y >= 0, [x, y] : integer], [x, y])In the solver,
Open in the solvermaximize([x^2 + y^2, x + 2y <= 8, 3x + y <= 9, x >= 0, y >= 0, [x, y] : integer], [x, y])gives[16, [x -> 0, y -> 4]].maximize([x*y*z, x + y + z = 3, x > 0, y > 0, z > 0], [x, y, z])In the solver,
Open in the solvermaximize([x*y*z, x + y + z = 3, x > 0, y > 0, z > 0], [x, y, z])gives[1, [x -> 1, y -> 1, z -> 1]].
Functions its examples use
- min
The smallest of some numbers.
Related functions
- numeric_maximize
The maximum of an expression found numerically, with the point where it is reached.
- min_value
The minimum value of an expression.
- max_value
The maximum value of an expression.
- minimize
The minimum of an expression and the point where it is reached.
- numeric_minimize
The minimum of an expression found numerically, with the point where it is reached.