% contour plot for fig2_4, p 18 in 
% Nocedal and Wright
[X,Y] = meshgrid(-.1:.05:1.2,-.1:.05:1.2);
P1=X-1;
P2=Y-1;
Z = fex24(X,Y);
Mk = mkex24(P1,P2);
subplot(2,2,1)
surf(X,Y,Z)
%hold on
%surf(X,Y,Mk)
view(-10,30);
xlabel('x1')
ylabel('x2')
zlabel('f')
%hold on;
%surf(X,Y,2*Z)
subplot(2,2,2)
hold on;
plot(1,1,'x')
plot(0,1,'o')
contour(X,Y,Z,40)
xlabel('x1')
ylabel('x2')
subplot(2,2,3)
surf(X,Y,Mk)
view(-10,30);
xlabel('x1')
ylabel('x2')
zlabel('mk')
subplot(2,2,4)
contour(X,Y,Mk,40)
xlabel('x1')
ylabel('x2')
hold on;
plot(1,1,'x')
plot(0,1,'o')