Local extrema: extrema

### 6.53.2 Local extrema: extrema

extrema attempts to find local extrema of a univariate/multivariate differentiable expression under equality constraints, using analytical methods.

- extrema which takes two mandatory arguments and two optional arguments:
  - expr, a differentiable expression.
  - Optionally, constr, a list of equality constraints, where each constraint is an equality or an expression assumed to be equal to zero, and the number of constraints must be strictly less than the number of variables. If there is only one constraint, it doesn’t have to be a list.

    Additionally, the Jacobian matrix of the constraints must be full rank (i.e., denoting the kth constraint by gk(x1,x2,…,xn)=0 for k=1,2,…,m and letting g=(g1,g2,…,gm), the Jacobian matrix of g must be equal to m).

  - vars, a list of variables. A variable can be specified with bounds, x=a..b, where a or b is allowed to be -infinity or infinity.

    If there is only one variable, it doesn’t have to be a list.

    The parameter vars can also be entered as a list of values of the variables; e.g. [x1=a1,x2=a2,…,xn=an], in which case the critical point close to a=(a1,a2,…,an) is computed numerically by , applying an iterative method with initial point a.

  - Optionally, opt, which can be order=n to make n the upper bound for the order of derivatives examined in the process (so if n=1 only critical points are found, by default order=5) or lagrange to specify the method of Lagrange multipliers.
- extrema(expr ⟨ constr ⟩, vars ⟨ opt ⟩) returns a list [min,max], where min is the list of local minima and max is the list of local maxima of expr.

  Saddle and unclassified points are reported in the message area. Also, information about possible (non)strict extrema is printed out. If lagrange is passed as an optional last argument, the method of Lagrange multipliers is used. Else, the problem is reduced to an unconstrained one by applying implicit differentiation.

If critical points are left unclassified you might consider repeating the process with larger value of n, although the success is not guaranteed.

Examples.

- Input:
  extrema(-2*cos(x)-cos(x)^2,x)
  Output:

  ⎡ ⎢ ⎣ |
  0
  π
  | ⎤ ⎥ ⎦

- Input:
  extrema(x/2-2*sin(x/2),x=-12..12)
  Output:

  ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
  − |
  10
  3
  | π
  2
  3
  | π
  − |
  2
  3
  | π
  10
  3
  | π
  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦

- Input:
  assume(a>=0);extrema(x^2+a*x,x)
  Output:

  ⎡ ⎢ ⎢ ⎣ | ⎡ ⎢ ⎢ ⎣ | − |
  1
  2
  | a | ⎤ ⎥ ⎥ ⎦ | , | ⎡ ⎣ | ⎤ ⎦ | ⎤ ⎥ ⎥ ⎦

- Input:
  extrema(exp(x^2-2x)*ln(x)*ln(1-x),x=0.5)
  Output:

  ⎡ ⎣ | ⎡ ⎣ | ⎤ ⎦ | , | ⎡ ⎣ | 0.277769149124 | ⎤ ⎦ | ⎤ ⎦

- Input:
  extrema(x^3-2x*y+3y^4,[x,y])
  Output:

  ⎡ ⎢ ⎢ ⎢ ⎢ ⎣ | ⎡ ⎢ ⎢ ⎢ ⎢ ⎣ |
  12 |
  1
  5
  3
  ⎛ ⎜ ⎝ | 12 |
  1
  5
  | ⎞ ⎟ ⎠ |
  2
  6
  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎦ | , | ⎡ ⎣ | ⎤ ⎦ | ⎤ ⎥ ⎥ ⎥ ⎥ ⎦

- Input:
  assume(a>0);extrema(x/a^2+a*y^2,x+y=a,[x,y])
  Output:

  ⎡ ⎢ ⎢ ⎣ | ⎡ ⎢ ⎢ ⎣ |
  2 a4−1
  2 a3
  1
  2 a3
  | ⎤ ⎥ ⎥ ⎦ | , | ⎡ ⎣ | ⎤ ⎦ | ⎤ ⎥ ⎥ ⎦

- Input:
  extrema(x^2+y^2,x*y=1,[x=0..inf,y=0..inf])
  Output:

  ⎡ ⎣ | ⎡ ⎣ |
  1 | 1
  | ⎤ ⎦ | , | ⎡ ⎣ | ⎤ ⎦ | ⎤ ⎦

- Input:
  extrema(x*y*z,x+y+z=1,[x,y,z],order=1)
  Output:

  ⎡ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎣ |
  0 | 1 | 0
  0 | 0 | 1
  1 | 0 | 0
  1
  3
  1
  3
  1
  3
  | ⎤ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎦