%lagrangeandemo.m
clc;
clear all;
close all;
%demonstration for equality constraints
i=1;
j=1;
for x=-5:1:5
    i=1;
for y=-5:1:5
z(i,j)=2*x^2+4*y+3;
i=i+1;
end
j=j+1;
end
x=-5:1:5;
y=-5:1:5;
contour(x,y,z,150)
x=-5:1:5;
y=-3-x;
hold on
plot(x,y,'k')
for x=-5:1:5
plot([x 0],[ (-3-x) (-4-x) ],'r')
plot([x 0],[(-3-x) (-3-2*x)],'m')
hold on
end
