function test_rosenbrock(x1,y1);
x=-1:0.01:2;        % grid points along x-axes         
y=-0.5:0.01:3;      % grid points along y-axes

nx=length(x);       % size of grid along x-axes 
ny=length(y);       % siye of grid along y-axes

%
% evaluate Rosenbrock function in grid points
%

[f,g,h] = feval(@rosenbrock,[x1;y1]);


fz=zeros(nx,ny);    % intiliaze matrix size to grid size and set to zero  
lm=zeros(nx,ny);    % intiliaze matrix size to grid size and set to zero  
qm=zeros(nx,ny);    % intiliaze matrix size to grid size and set to zero  
for i=1:nx
  for j=1:ny
    % compute f(x(i),y(j)) and store in fz(i,j)
    fz(i,j)= 100*(y(j)-x(i)^2)^2+(1-x(i))^2;
    lm(i,j)=f+g'*[x(i)-x1;y(j)-y1];
    qm(i,j)=f+g'*[x(i)-x1;y(j)-y1]+[x(i)-x1;y(j)-y1]'*h*[x(i)-x1;y(j)-y1]/2;
  end
end

%
% make a contour plot for prespecified contour levels
%

figure(2);               % output next plot on window of figure 1 
hold off;                % overwrite old plot in figure 1
contour(x,y,fz',[0.1,0.5,2.5,12.5,62.5,312.5]);     % plot the function
xlabel('x');             % output 'x' along x axis
ylabel('y');             % output 'y' along y axis
hold on;
plot([x1],[y1],'or');

figure(1);
clf;
hold off;
axis([min(x) max(x) min(y) max(y) -200 1000 -200 1000]);
view(3);
hold on;

mesh(x,y,fz');
mesh(x,y,lm');

pause 


figure(2);
hold on;


contour(x,y,qm',[0.1,0.5,2.5,12.5,62.5,312.5]);     % plot the quadratic model

%
% make a mesh plot
%

figure(1)
hold on;

mesh(x,y,qm');
