3 回答

TA贡献1785条经验 获得超8个赞
我现在确定 python 代码有问题。我决定在 Matlab 中实现该算法,它似乎工作正常。这是代码:
clear; clc;
x=[-1.1, 1.1]';
t=1;
count=1;
xvalues=[];
temp = x - inv([(-400*x(2)+1200*x(1)^2+2), -400*x(1); -400*x(1), 200]);
disp(x-inv([(-400*x(2)+1200*x(1)^2+2), -400*x(1); -400*x(1), 200])*[-400*x(1)*x(2)+400*x(1)^3+2*x(1)-2; 200*(x(2)-x(1)^2)])
while count<10
xvalues(count,:)= x;
temp = x - inv([(-400*x(2)+1200*x(1)^2+2), -400*x(1); -400*x(1), 200]) * [-400*x(1)*x(2)+400*x(1)^3+2*x(1)-2; 200*(x(2)-x(1)^2)];
x = temp;
count = count+1;
end
disp(xvalues)
输出:
-1.1000 1.1000
-1.0087 1.0091
-0.2556 -0.5018
-0.2446 0.0597
0.9707 -0.5348
0.9708 0.9425
1.0000 0.9991
1.0000 1.0000
1.0000 1.0000
添加回答
举报