Econ 407: An application of inequality constraint:
Maximize 26*x-3*x^2+5*x*y-6*y^2+12*y subject to:
170-3*x -y equal or greater than zero.
>
L:=26*x-3*x^2+5*x*y-6*y^2+12*y+lambda*(170.0-3*x-y);
>
>
Lx:=diff(L,x);
>
Ly:=diff(L,y);
>
Llambda:=diff(L,lambda);
>
solve({Lx,Ly, Llambda},{x,y,lambda});
Since lambda is negative, the constraint is binding--i.e. we have not reached the optimum point.
>
plot3d(26*x-3*x^2+5*x*y-6*y^2+12*y,x=0..60,y=0..35);
Let us increase the constraint to 180.
>
L:=26*x-3*x^2+5*x*y-6*y^2+12*y+lambda*(27.0-3*x-y);
>
Lx:=diff(L,x);
>
Ly:=diff(L,y);
>
Llambda:=diff(L,lambda);
>
solve({Lx,Ly,Llambda},{x,y,lambda});
>
L:=26*x-3*x^2+5*x*y-6*y^2+12.0*y;
>
Lx:=diff(L,x);
>
Ly:=diff(L,y);
>
solve({Lx,Ly},{x,y});
>
>
eval(26*x-3*x^2+5*x*y-6*y^2+12.0*y,{y = 25., x = 48.33333333, lambda = -46.33333333});
>
eval(26*x-3*x^2+5*x*y-6*y^2+12*y,{x = 7.914893617, y = 4.297872340});
Please note that by changing the value of the constraint from 170 to 30, the objective function went from -3160 to +128.