• g.m

    • function y=g(x)
      % g maps from R7 into R8
      % and is a sample function for M 516
      y(1)=105-4*x(1)-5*x(2)+3*x(7)^2;
      y(2)=-10*x(1)+8*x(3)+x(7);
      y(3)=8*x(1)-2*x(2)+12*x(5)-5;
      y(4)=-3*(x(1)-2)^2 -4*(x(2)-3)^2-2*x(3)^2+7*x(4)+100;
      y(5)=-5*x(1)^2-8*x(2)-(x(3)-6)^2+2*x(4)+40;
      y(6)=-.5*(x(1)-8)^2-2*(x(2)-4)^2-3*x(5)^2+x(6)+30;
      y(7)=-x(1)^2-2*(x(2)-2)^2+2*x(1)*x(2)-14*x(5)+6*x(6);
      y(8)=3*x(1)-6*x(2)-12*x(5)*x(6);
      y=y';
      

  • Jg.m

    • function m=Jg(x)
      % this one does the Jacobian of the
      % math 516 sample function g
      m=[-4 -5 0 0 0 0 6*x(7);
      -10 0 8 0 0 0 1;
      8 -2 0 0 12 0 0;
      -6*(x(1)-2) -8*(x(2)-3) -4*x(3) 7 0 0 0;
      -10*x(1) -8 -2*(x(3)-6) 2 0 0 0;
      -(x(1)-8) -4*(x(2)-4) 0 0 -6*x(5) 1 0;
      -2*x(1)+2*x(2) -4*(x(2)-2)+2*x(1) 0 0 -14 6 0;
      3 -6 0 0 -12*x(6) -12*x(5) 0];
      

  • Hg.m

    • function [h1,h2,h3,h4,h5,h6,h7,h8]=Hg(x)
      % this function file gives the Hessians of the
      % component functions of g, again g is the m516
      % sample function
      h1=[zeros(6,7);zeros(1,6),6];
      h2=  zeros(7,7);
      h3=  h2;
      h4=  [[-6,zeros(1,6);
      0,-8,zeros(1,5);
      0,0,-4,0,0,0,0];
      zeros(4,7)];
      h5=  [[-10,zeros(1,6);
      zeros(1,7);
      0,0,-2,0,0,0,0];
      zeros(4,7)];
      h6=  [-1,zeros(1,6);
      0,-4,0,0,0,0,0;
      zeros(2,7);
      0,0,0,0,-6,0,0;
      zeros(2,7)];
      h7=  [-2,2,0,0,0,0,0;
      2,-4,0,0,0,0,0;
      zeros(5,7)];
      h8=  [zeros(4,7);
      zeros(1,5),-12,0;
      zeros(1,4),-12,0,0;
      zeros(1,7)];
      

  • func.m

    • n y=func(x)
      % f is a mapping from R7 to R1.
      y=(0.5)*norm(g(x))^2;
      

  • gradf.m

    • function y=gradf(x)
      % gradf is the gradient of func(x)=norm(g(x))^2
      y=Jg(x)'*g(x);
      

  • hessf.m

    • function y=hessf(x)
      % hessf is the Hessian of the function func(x)=norm(g(x))^2
      [h1,h2,h3,h4,h5,h6,h7,h8]=Hg(x);
      z=g(x);
      y=Jg(x)'*Jg(x)+z(1)*h1+z(2)*h2+z(3)*h3+z(4)*h4+z(5)*h5+z(6)*h6;
      y=y+z(7)*h7+z(8)*h8;