y1 = -(x1-5)^2-(x2-5)^2+100+x3^2;
g=jacobian([y1;y2],[x1 x2 x3 x4]); %DH %求一阶导
A=jacobian(y1,[x1 x2 x3 x4]);
A=jacobian(A,[x1 x2 x3 x4]);
B=jacobian(y2,[x1 x2 x3 x4]);
B=jacobian(B,[x1 x2 x3 x4]); %二阶导是个2*4*4向量
y2 = y+x4^2;
g=jacobian([y1;y2],[x1 x2 x3 x4]); %DH %求一阶导
A=jacobian(y1,[x1 x2 x3 x4]);
A=jacobian(A,[x1 x2 x3 x4]);
B=jacobian(y2,[x1 x2 x3 x4]);
B=jacobian(B,[x1 x2 x3 x4]); %二阶导是个2*4*4向量
H=[A;B];
J = - (f(1) * H(1:4,:) + f(2)*H(5:8,:) )- g'*g ;