# Tema 11
11-4  Extrems de funcions reals
          de diverses variables

## Extrems locals

kill(all)$

f1(x,y):=x^2+y^2;

wxplot3d(f1(x,y), [x,-5,5], [y,-5,5],
 [gnuplot_preamble, "set hidden3d"])$

f2(x,y):=1-x^2-y^2;

wxplot3d(f2(x,y), [x,-5,5], [y,-5,5],
 [gnuplot_preamble, "set hidden3d"])$

f3(x,y):=x^3+y^3;

wxplot3d(f3(x,y), [x,-5,5], [y,-5,5],
 [gnuplot_preamble, "set hidden3d"])$

f4(x,y):=+sqrt(x^2 + y^2);

wxplot3d(f4(x,y), [x,-5,5], [y,-5,5],
 [gnuplot_preamble, "set hidden3d"])$

Exemple 11.4.1

kill(all)$

f(x,y):=x^3+3*x*y^2-15*x-12*y;

diff(f(x,y),x);  diff(f(x,y), y);

Dxf(x,y):=3*y^2+3*x^2-15;       Dyf(x,y):=6*x*y-12;

Eq1:Dxf(x,y)=0;     Eq2:Dyf(x,y)=0;     algsys([Eq1, Eq2], [x,y]);

designem: P1(2,1);  P2(1,2);  P3(-1,-2);  P4(-2,-1)

'Hf(x,y) = Hf: hessian(f(x,y), [x,y]);

'Hf(2,1)= Hf_P1: subst([x=2,y=1],Hf);

determinant(Hf_P1);

'Hf(1,2)= Hf_P2: subst([x=1,y=2],Hf);

determinant(Hf_P2);

'Hf(-1,-2)= Hf_P3: subst([x=-1,y=-2],Hf);

determinant(Hf_P3);

'Hf(-2,-1)= Hf_P4: subst([x=-2,y=-1],Hf);

determinant(Hf_P4);

Exemple 11.4.2

kill(all)$

f(x,y):=(x+y)^2;    diff(f(x,y),x);    diff(f(x,y), y);

Dxf(x,y):=2*(x+y);      Dyf(x,y):=2*(x+y);

Eq1:Dxf(x,y)=0;     Eq2:Dyf(x,y)=0;
algsys([Eq1, Eq2], [x,y]);

'Hf(x,y)=Hfxy:hessian(f(x,y), [x,y]);

determinant(Hfxy);

wxplot3d(f(x,y), [x,-5,5], [y,-5,5],
 [gnuplot_preamble, "set hidden3d"])$

## Extrems absoluts sobre un compacte

Exemple 11.4.3

kill(all)$

f(x,y):=2*(x-1)^2+2*(y-1)^2;

Dxf=diff(f(x,y), x);   Dyf=diff(f(x,y), y);

P1(1,1)$

L1(x,y,a):=f(x,y)+a*(x^2+y^2-9);
Eq1a:diff(L1(x,y,a), x)=0;      Eq1b:diff(L1(x,y,a), y)=0;      Eq1c:diff(L1(x,y,a), a)=0;
algsys([Eq1a, Eq1b, Eq1c], [x,y,a]);

P2(3/sqrt(2),3/sqrt(2))$
P3(-3/sqrt(2),-3/sqrt(2))$

L2(x,y,b):=f(x,y)+b*x;
Eq2a:diff(L2(x,y,b), x)=0;      Eq2b:diff(L2(x,y,b), y)=0;      Eq2c:diff(L2(x,y,b), b)=0;
algsys([Eq2a, Eq2b, Eq2c], [x,y,b]);

P4(0,1)$

L3(x,y,c):=f(x,y)+c*y;
Eq3a:diff(L3(x,y,c), x)=0;      Eq3b:diff(L3(x,y,c), y)=0;      Eq3c:diff(L3(x,y,c), c)=0;
algsys([Eq3a, Eq3b, Eq3c], [x,y,c]);

P5(1,0)$

'f(1,1)=f(1,1);

'f(P2)=f(3/sqrt(2),3/sqrt(2)), numer;    
'f(P3)=f(-3/sqrt(2),-3/sqrt(2)), numer;

'f(P4)=f(0,1);    'f(P5)=f(1,0);

'f(P6)=f(0,0);    'f(P7)=f(3,0);    'f(P8)=f(0,3);
'f(P9)=f(-3,0);    'f(P10)=f(0,-3);

min(f(1,1), f(3/sqrt(2),3/sqrt(2)), f(-3/sqrt(2),-3/sqrt(2)), 
f(0,1), f(1,0), f(3,0), f(0,3), f(0,0), f(-3,0), f(0,-3)  ), numer;

max(f(1,1), f(3/sqrt(2),3/sqrt(2)), f(-3/sqrt(2),-3/sqrt(2)), 
f(0,1), f(1,0), f(3,0), f(0,3), f(0,0), f(-3,0), f(0,-3)   ), numer;