x = -2.5:.01:1.5;
y = -1.1:.01:1.1;
user = 0;
n= 2;

[X,Y] = meshgrid(x,y);

Z = sin(3*Y-X.^2+1)+cos(2*Y.^2-2*X);

contour(x,y,Z,20)
colorbar
hold on

ibound = nag_int(0);  
bl = [-2;
     -1];
bu = [1;
     1];
 
plot(bl(1),y)
plot(bu(1),y)
plot(x,bl(2))
plot(x,bu(2))

st = [-1;  % bad starting point?
      0.6]; 

tic
[blOut, buOut, xOut, f, iw, w, user, ifail] = ...
    e04jy(ibound, 'func_e04jy', bl, bu, st)
toc

plot(xOut(1),xOut(2),'+')

tic
[blOut, buOut, xOut, f, g, iw, w, user, ifail] = ...
    e04ky(ibound, 'func_e04ky', bl, bu, st)
toc

plot(xOut(1),xOut(2),'o')
hold off
