   ### 6.55.2  Local extrema: extrema

Local extrema of a univariate or multivariate differentiable function under equality constraints can be obtained by using function extrema which takes four arguments :

• expr : differentiable expression
• constr (optional) : list of equality constraints
• vars : list of variables
• order_size=<positive integer> (optional) : upper bound for the order of derivatives examined in the process (defaults to 12)

Function returns sequence of two lists of points: local minima and maxima, respectively. Saddle and unclassified points are reported in the message area. Also, information about possible (non)strict extrema is printed out.

Number of constraints must be strictly less than number of variables. A single constraint/variable can be specified without list delimiters. A constraint may be specified as an equality or expression which is assumed to be equal to zero.

Variables may be specified with bounds, e.g. x=a..b. That is interpreted as x∈(a,b) . For semi-bounded variables use -infinity for a or +infinity for b . Also, to use numeric method to find critical point one may specify vars as [x1=a1,x2=a2,...,xn=an], where (a1,a2,…,an) is an initial point for the algorithm.

If order_size=<n> is specified as the fourth argument, derivatives up to order n are inspected to find critical points and classify them. For order_size=1 the function returns a single list containing all critical points found. The default is n=12 .

#### Examples

Input :

extrema(-2*cos(x)-cos(x)`^`2,x)

Output :

,[pi]

Input :

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

Output :

[2*pi/3,-10*pi/3],[10*pi/3,-2*pi/3]

Input :

assume(a>=0);extrema(x`^`2+a*x,x)

Output :

[-a/2],[]

Input :

extrema(exp(x`^`2-2x)*ln(x)*ln(1-x),x=0.5)

Output :

[],[0.277769149124]
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*a`^`4-1)/(2*a`^`3),1/(2*a`^`3)]],[]

Input :

extrema(x`^`2+y`^`2,x*y=1,[x=0..inf,y=0..inf])

Output :

[[1,1]],[]

Input :

extrema(x2`^`4-x1`^`4-x2`^`8+x1`^`10,[x1,x2])

Output :

[[6250`^`(1/6)/5,0],[-6250`^`(1/6)/5,0]],[]

Input :

extrema(x*y*z,x+y+z=1,[x,y,z],order_size=1)

Output :

[[1,0,0],[0,1,0],[0,0,1],[1/3,1/3,1/3]]   