%
function dummy
%
%  This version uses the Matlab builtin function fmincon
%
%  set some options
%
  options = optimset('MaxFunEvals',1000,'TolFun',1e-5,'TolX',1e-4,'MaxIter',100);
  options = optimset('GradObj','on','Hessian','on');
%
%  now solve for u
%
  u0 = rand(4,1);
  [u,fval,exitflag,output] = fmincon(@bob2_example,u0,[],[],[],[],[],[],@bobcon_example,options);
%
  fprintf(1,'\n');
  fprintf(1,' Exit Flag is %d \n', exitflag);
  fprintf(1,' The number of iterations is %d \n', output.iterations);
  fprintf(1,' The number of function evaluations is %d \n', output.funcCount);
  u
  fval
%
  return;
%  
%  This function also returns the derivative and second derivative
%
  function [L,Lu,Luu] = bob2_example(u);
%
% u = [x(1) y(1) x(2) y(2)]'
%
  x1 = u(1); x2 = u(2); y1 = u(3); y2 = u(4);
%
  L = (x1-x2)^2+(y1-y2)^2;
  if nargout > 1
      Lu = [2*(x1-x2) -2*(x1-x2) 2*(y1-y2) -2*(y1-y2)];
  end;
  if nargout > 2
      Luu = [2 -2 0 0; -2 2 0 0; 0 0 2 -2; 0 0 -2 2];
  end;
%
  return;
%
%  This function returns thenonlinear inequalities and the derivatives
%
function [c,ceq,Gc,Gceq] = bobcon_example(u) 
%
% u = [x(1) y(1) x(2) y(2)]'
%
  x1 = u(1); x2 = u(2); y1 = u(3); y2 = u(4);
%
  a = 10; b = 2;
%
  c = [];
  ceq = [(x1^2+y1^2-1); ((x2/a)^2 + (y2/b)^2 -1)];
  Gc = [];
  Gceq = [2*x1 0 2*y1 0; 0 2*x2/a^2 0 2*y2/b^2];
%
  return;
