# Minimize a function (minimize)

The minimum of an expression and the point where it is reached.

## How to write it

### minimize(expr, variables)

The least 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.

### minimize(expr, variables)

Under conditions: a linear program, whole unknowns written \[x, y\] : integer, abs and max, distances.

**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

- $\displaystyle \min_{x} (x^{2}-2 x) = \left[ -1, \left[ x \to 1 \right] \right]$

  `minimize(x^2 - 2x, x)`

  In the solver, `minimize(x^2 - 2x, x)` gives `[-1, [x -> 1]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28x%5E2%20-%202x%2C%20x%29)
- $\displaystyle \min_{x, y} (x^{4}+y^{4}-4 x y+1) = \left[ -1, \left[ x \to 1, y \to 1 \right] \right]$

  `minimize(x^4 + y^4 - 4x*y + 1, [x, y])`

  In the solver, `minimize(x^4 + y^4 - 4x*y + 1, [x, y])` gives `[-1, [x -> 1, y -> 1]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28x%5E4%20%2B%20y%5E4%20-%204x*y%20%2B%201%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle \min_{x, y} \left[ x+y, x+2 y \ge 4, 3 x+y \ge 6, x \ge 0, y \ge 0 \right] = \left[ \frac{14}{5}, \left[ x \to \frac{8}{5}, y \to \frac{6}{5} \right] \right]$

  `minimize([x + y, x + 2y >= 4, 3x + y >= 6, x >= 0, y >= 0], [x, y])`

  In the solver, `minimize([x + y, x + 2y >= 4, 3x + y >= 6, x >= 0, y >= 0], [x, y])` gives `[14/5, [x -> 8/5, y -> 6/5]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28%5Bx%20%2B%20y%2C%20x%20%2B%202y%20%3E%3D%204%2C%203x%20%2B%20y%20%3E%3D%206%2C%20x%20%3E%3D%200%2C%20y%20%3E%3D%200%5D%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle \min_{x, y} \left[ 2 x+3 y, x+y \ge \frac{7}{2}, x-y \le 1, x \ge 0, y \ge 0, \left[ x, y \right] \in \mathbb{Z} \right] = \left[ 10, \left[ x \to 2, y \to 2 \right] \right]$

  `minimize([2x + 3y, x + y >= 7/2, x - y <= 1, x >= 0, y >= 0, [x, y] : integer], [x, y])`

  In the solver, `minimize([2x + 3y, x + y >= 7/2, x - y <= 1, x >= 0, y >= 0, [x, y] : integer], [x, y])` gives `[10, [x -> 2, y -> 2]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28%5B2x%20%2B%203y%2C%20x%20%2B%20y%20%3E%3D%207%2F2%2C%20x%20-%20y%20%3C%3D%201%2C%20x%20%3E%3D%200%2C%20y%20%3E%3D%200%2C%20%5Bx%2C%20y%5D%20%3A%20integer%5D%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle \min_{x, y} \left[ \left| x-2 \right|+\left| y+1 \right|+\left| x+y-5 \right|, x \ge 0, y \ge 0 \right] = \left[ 4, \left[ x \to 5, y \to 0 \right] \right]$

  `minimize([abs(x - 2) + abs(y + 1) + abs(x + y - 5), x >= 0, y >= 0], [x, y])`

  In the solver, `minimize([abs(x - 2) + abs(y + 1) + abs(x + y - 5), x >= 0, y >= 0], [x, y])` gives `[4, [x -> 5, y -> 0]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28%5Babs%28x%20-%202%29%20%2B%20abs%28y%20%2B%201%29%20%2B%20abs%28x%20%2B%20y%20-%205%29%2C%20x%20%3E%3D%200%2C%20y%20%3E%3D%200%5D%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle \min_{x, y} \left[ \max(x+y, 2 x-y, 3-x), x \ge -5, x \le 5, y \ge -5, y \le 5 \right] = \left[ \frac{9}{5}, \left[ x \to \frac{6}{5}, y \to \frac{3}{5} \right] \right]$

  `minimize([max(x + y, 2x - y, 3 - x), x >= -5, x <= 5, y >= -5, y <= 5], [x, y])`

  In the solver, `minimize([max(x + y, 2x - y, 3 - x), x >= -5, x <= 5, y >= -5, y <= 5], [x, y])` gives `[9/5, [x -> 6/5, y -> 3/5]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28%5Bmax%28x%20%2B%20y%2C%202x%20-%20y%2C%203%20-%20x%29%2C%20x%20%3E%3D%20-5%2C%20x%20%3C%3D%205%2C%20y%20%3E%3D%20-5%2C%20y%20%3C%3D%205%5D%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle \min_{x, y} \left[ \left\| \left[ x-1, y-2 \right] \right\|+\left\| \left[ x+1, y \right] \right\|, x+y \ge 0 \right] = \left[ 2 \sqrt{2}, \left[ x \to 1, y \to 2 \right] \right]$

  `minimize([norm([x - 1, y - 2]) + norm([x + 1, y]), x + y >= 0], [x, y])`

  In the solver, `minimize([norm([x - 1, y - 2]) + norm([x + 1, y]), x + y >= 0], [x, y])` gives `[2sqrt(2), [x -> 1, y -> 2]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28%5Bnorm%28%5Bx%20-%201%2C%20y%20-%202%5D%29%20%2B%20norm%28%5Bx%20%2B%201%2C%20y%5D%29%2C%20x%20%2B%20y%20%3E%3D%200%5D%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle \min_{x, y} \left[ x y-3 x+2 y, x \ge -2, x \le 3, y \ge -1, y \le 4, \left[ x, y \right] \in \mathbb{Z} \right] = \left[ -14, \left[ x \to 3, y \to -1 \right] \right]$

  `minimize([x*y - 3x + 2y, x >= -2, x <= 3, y >= -1, y <= 4, [x, y] : integer], [x, y])`

  In the solver, `minimize([x*y - 3x + 2y, x >= -2, x <= 3, y >= -1, y <= 4, [x, y] : integer], [x, y])` gives `[-14, [x -> 3, y -> -1]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28%5Bx*y%20-%203x%20%2B%202y%2C%20x%20%3E%3D%20-2%2C%20x%20%3C%3D%203%2C%20y%20%3E%3D%20-1%2C%20y%20%3C%3D%204%2C%20%5Bx%2C%20y%5D%20%3A%20integer%5D%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle \min_{x} \left[ \tan(x), x \ge 0, x \le 2 \right] = \left[ -\infty, \left[ x \to \frac{\pi}{2} \right] \right]$

  `minimize([tan(x), x >= 0, x <= 2], x)`

  In the solver, `minimize([tan(x), x >= 0, x <= 2], x)` gives `[-inf, [x -> pi/2]]`.

  [Open in the solver](https://hilberon.com/?q=minimize%28%5Btan%28x%29%2C%20x%20%3E%3D%200%2C%20x%20%3C%3D%202%5D%2C%20x%29)

## Functions its examples use

- [abs](https://hilberon.com/library/abs)

  Absolute value of a number, or modulus of a complex one.
- [max](https://hilberon.com/library/max)

  The largest of some numbers.
- [norm](https://hilberon.com/library/norm)

  Length of a vector.
- [tan](https://hilberon.com/library/tan)

  Tangent of an angle in radians.

## Related functions

- [numeric_minimize](https://hilberon.com/library/numeric_minimize)

  The minimum of an expression found numerically, with the point where it is reached.
- [numeric_maximize](https://hilberon.com/library/numeric_maximize)

  The maximum of an expression found numerically, with the point where it is reached.
- [min_value](https://hilberon.com/library/min_value)

  The minimum value of an expression.
- [maximize](https://hilberon.com/library/maximize)

  The maximum of an expression and the point where it is reached.
- [max_value](https://hilberon.com/library/max_value)

  The maximum value of an expression.

---
Source: https://hilberon.com/library/minimize
