Optimización con restricciones de igualdad

ej 13.j

> f:=x*y*z;

f := x*y*z

> g1:=x+y-1;

g1 := x+y-1

> g2:=x+z;

g2 := x+z

> L:=f-a1*g1-a2*g2;

L := x*y*z-a1*(x+y-1)-a2*(x+z)

> solve({diff(L,x)=0,diff(L,y)=0,diff(L,z)=0,g1=0,g2=0});

{x = 0, a2 = 0, a1 = 0, y = 1, z = 0}, {x = 2/3, a2...

máximo para (0,1,0) mínimo para (2/3,1/3,-2/3)

ej 13.k

> f:=x^2+y^2+z^2+u^2+v^2;

f := x^2+y^2+z^2+u^2+v^2

> g:=x+y+z+u+v-5;

g := x+y+z+u+v-5

> L:=f-a*g;

L := x^2+y^2+z^2+u^2+v^2-a*(x+y+z+u+v-5)

> solve({diff(L,x)=0,diff(L,y)=0,diff(L,z)=0,diff(L,u)=0,diff(L,v)=0,g=0});

{y = 1, u = 1, v = 1, z = 1, x = 1, a = 2}

es un mínimo

ej 13.l

> f:=1/(x^2+y^2+z^2+u^2+v^2);

f := 1/(x^2+y^2+z^2+u^2+v^2)

> g1:=x+2*y+z-6;

g1 := x+2*y+z-6

> g2:=3*x+2*z+u-v-4;

g2 := 3*x+2*z+u-v-4

> L:=f-a1*g1-a2*g2;

L := 1/(x^2+y^2+z^2+u^2+v^2)-a1*(x+2*y+z-6)-a2*(3*x...

> solve({diff(L,x)=0,diff(L,y)=0,diff(L,z)=0,diff(L,u)=0,diff(L,v)=0,g1=0,g2=0});

{z = 58/65, x = 4/5, a2 = 65/13068, v = 6/65, a1 = ...

Optimización con restricciones de desigualdad

ej 14.a

> f:=x+y;

f := x+y

> g:=x^2+4*y^2-4;

g := x^2+4*y^2-4

> L:=f-a*g;

L := x+y-a*(x^2+4*y^2-4)

> evalf(solve({diff(L,x)=0,diff(L,y)=0,a*g=0,a>=0,g<=0}));

{y = .4472135954, a = .2795084971, x = 1.788854382}...

ej 14.b

> f:=x+y;

f := x+y

> g:=-x^2-4*y^2+4;

g := -x^2-4*y^2+4

> L:=f-a*g;

L := x+y-a*(-x^2-4*y^2+4)

> evalf(solve({diff(L,x)=0,diff(L,y)=0,a*g=0,a>=0,g>=0}));

{a = .2795084971, y = -.4472135954, x = -1.78885438...

ej 14.k

> f:=x*y;

f := x*y

> g:=x^2+y^2-1;

g := x^2+y^2-1

> L:=f-a*g;

L := x*y-a*(x^2+y^2-1)

> evalf(solve({diff(L,x)=0,diff(L,y)=0,a*g=0,a>=0,g<=0}));

{a = 0., y = 0., x = 0.}, {a = .5000000000, x = -.7...

>

ej 14.l

> f:=x*y*z;

f := x*y*z

> g1:=x+y+z-1;

g1 := x+y+z-1

> g2:=-x;

g2 := -x

> g3:=-y;

g3 := -y

> g4:=-z;

g4 := -z

> L:=f-a1*g1-a2*g2-a3*g3-a4*g4;

L := x*y*z-a1*(x+y+z-1)+a2*x+a3*y+a4*z

> evalf(solve({diff(L,x)=0,diff(L,y)=0,diff(L,z)=0,a1*g1=0,a2*g2=0,a3*g3=0,a4*g4=0,a1>=0,a2>=0,a3>=0,a4>=0,g1<=0,g2<=0,g3<=0,g4<=0}));

{z = 0., a1 = 0., 0. <= x, x <= 1., a3 = 0., a2 = 0...
{z = 0., a1 = 0., 0. <= x, x <= 1., a3 = 0., a2 = 0...
{z = 0., a1 = 0., 0. <= x, x <= 1., a3 = 0., a2 = 0...

>

ej 14.m

> f:=2*y-x^2;

f := 2*y-x^2

> g1:=-x^2-y^2+1;

g1 := -x^2-y^2+1

> g2:=x;

g2 := x

> g3:=y;

g3 := y

> L:=f-a1*g1-a2*g2-a3*g3;

L := 2*y-x^2-a1*(-x^2-y^2+1)-a2*x-a3*y

> evalf(solve({diff(L,x)=0,diff(L,y)=0,a1*g1=0,a2*g2=0,a3*g3=0,a1>=0,a2>=0,a3>=0,g1>=0,g2>=0,g3>=0}));

{a2 = 0., y = 0., x = 1., a1 = 1., a3 = 2.}, {x = 0...

>

>

Optimización con restricciones de igualdad y desigualdad combinadas

ej 15.a

> f:=x-y^2;

f := x-y^2

> h1:=x^2+y^2-4;

h1 := x^2+y^2-4

> g1:=-x;

g1 := -x

> g2:=-y;

g2 := -y

> L:=f-k1*h1-a1*g1-a2*g2;

L := x-y^2-k1*(x^2+y^2-4)+a1*x+a2*y

> evalf(solve({diff(L,x)=0,diff(L,y)=0,a1*g1=0,a2*g2=0,a1>=0,a2>=0,g1>=0,g2>=0,h1=0}));

{a1 = 0., a2 = 0., k1 = -1., x = -.5000000000, y = ...

>

ej 15.e

> f:=2*x^2+y^2-z*x;

f := x-y^2

> h1:=x+y+z-2;

h1 := x+y+z-2

> h2:=x+y-1;

h2 := x+y-1

> g1:=-x;

g1 := -x

> g2:=-y-1;

g2 := -y-1

> L:=f-k1*h1-k2*h2-a1*g1-a2*g2;

L := x-y^2-k1*(x+y+z-2)-k2*(x+y-1)+a1*x-a2*(-y-1)

> evalf(solve({diff(L,x)=0,diff(L,y)=0,diff(L,z)=0,a1*g1=0,a2*g2=0,a1>=0,a2>=0,g1<=0,g2<=0,h1=0,h2=0}));

{k1 = 0., k2 = 1., a1 = 0., y = -.5000000000, x = 1...

>

ej 15.f

> f:=x^2+y^2+z^2;

f := x^2+y^2+z^2

> h1:=x-y;

h1 := x-y

> h2:=y-z;

h2 := y-z

> g1:=-x;

g1 := -x

> g2:=-y;

g2 := -y

> g3:=-z;

g3 := -z

> g4:=x-2;

g4 := x-2

> L:=f-k1*h1-k2*h2-a1*g1-a2*g2-a3*g3-a4*g4;

L := x^2+y^2+z^2-k1*(x-y)-k2*(y-z)+a1*x+a2*y+a3*z-a...

> evalf(solve({diff(L,x)=0,diff(L,y)=0,diff(L,z)=0,a1*g1=0,a2*g2=0,a3*g3=0,a4*g4=0,a1>=0,a2>=0,a3>=0,a4>=0,g1<=0,g2<=0,g3<=0,g4<=0,h1=0,h2=0}));

{k1 = 0., a1 = 0., a2 = 0., y = 0., k2 = 0., x = 0....
{k1 = 0., a1 = 0., a2 = 0., y = 0., k2 = 0., x = 0....

>

ej 15.h

> f:=x*y;

f := x*y

> h1:=x+y-4;

h1 := x+y-4

> g1:=x-1;

g1 := x-1

> g2:=y-1;

g2 := y-1

> L:=f-k1*h1-a1*g1-a2*g2;

L := x*y-k1*(x+y-4)-a1*(x-1)-a2*(y-1)

> evalf(solve({diff(L,x)=0,diff(L,y)=0,a1*g1=0,a2*g2=0,a1>=0,a2>=0,g1>=0,g2>=0,h1=0}));

{y = 3., k1 = 1., a2 = 0., x = 1., a1 = 2.}, {a2 = ...

>