format long
>> broyden3([0.5 0.5 0.5])
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 1.445765e-032.
> In broyden3 at 7
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 7.866780e-063.
> In broyden3 at 7
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 1.486740e-112.
> In broyden3 at 7
Warning: Matrix is singular, close to singular or badly scaled.
Results may be inaccurate. RCOND = NaN.
> In broyden3 at 7
其中 broyden3 at 7 指的语句为 x1=x0-ft(x0)/a;
可能是除以矩阵时舍入误差太大了 有没有什么办法减少舍入误差在矩阵中的叠加 编写的程序为:
function y=broyden3(x0) % y=broyden(x0) x0为初值.
a=eye(length(x0));
x1=x0-ft(x0)/a;
n=1;
while (norm(x1-x0)>=1.0e-6)&(n<=100000000)
x0=x1;
x1=x0-ft(x0)/a;
p=x1-x0;q=ft(x1)-ft(x0);
a=a+(q-p*a)'*p/norm(p);
n=n+1;
end
y=x1;
n