# Ejercicio 11.19

kill(all)$

f(x,y):=x^2 + y^2;
g(x,y):=4*x^2 + 5*x*y + 4*y^2 - 8;
L(x,y):= f(x,y)+ a*g(x,y);

load(draw)$
wxdraw2d(   
   grid = true,    line_type = solid,  line_width = 2, color = blue,
    implicit(4*x^2 + 5*x*y + 4*y^2 - 8=0, x, -4,4 , y, -2, 2)   );

Eq1a: diff(L(x,y) , x) = 0;
Eq1b: diff(L(x,y) , y) = 0;
Eq1c: g(x,y) = 0;

algsys([Eq1a, Eq1b, Eq1c], [x,y,a]);

x1 = x1 : 2^(3/2)/sqrt(13)$         y1 = y1 : 2^(3/2)/sqrt(13)$
x2 = x2 : - 2^(3/2)/sqrt(13)$       y2 = y2 : - 2^(3/2)/sqrt(13)$
x3 = x3 : 2^(3/2)/sqrt(3)$           y3 = y3 : - 2^(3/2)/sqrt(3)$
x4 = x4 : - 2^(3/2)/sqrt(3)$         y4 = y4 :  2^(3/2)/sqrt(3)$

P1 = [x1, y1], numer;
P2 = [x2, y2], numer;
P3 = [x3, y3], numer;
P4 = [x4, y4], numer;

D(x,y):=sqrt (f(x,y));

D1 = D1 : D(x1, y1);
D2 = D2 : D(x2, y2);
D3 = D3 : D(x3, y3);
D4 = D4 : D(x4, y4);

min (D1, D2, D3, D4);
max (D1, D2, D3, D4);