% Numerical Mathematics and Computing, Fifth Edition
% Ward Cheney & David Kincaid
% Brooks/Cole Publ. Co.
% (c) 2003
%
% file: fmin1.m
%
% Minimizing the multivariate function
% myfcn1(x,y) = x^2+y^2-2x-2y+4 close to the  point (0.5,0.5):
% 
myfcn1 = inline('x(1)^2 + x(2)^2 - 2*x(1) - 2*x(2) + 4')
[xmin ymin] = fminsearch( myfcn1, [0.5, 0.5])
[a,b]=meshgrid(0:0.1:2, 0:0.1:2);
z = a.*a + b.*b - 2*a - 2*b +4;
surf(z);
title('x^2 + y^2 -2x - 2y + 4')
xlabel('x axis')
ylabel('y axis')


