收敛点为什么是固定的?
function x=demoSSub(maxit,x0)% demoSSub Solve a 2-by-2 nonlinear system by successive
% The system is
% 1.4*x1-x2=0.6
% x1^2-1.6*x1-x2=4.6
%
% Symopsis:x=demoSSub(maxit,x0)
%
% Input:maxit=(optional)max number of iterations. Default:maxit=5
% x0=(optional)initional guess at solution. Default: x0=
%
% Output: x=extimate of solution after maxit iterations
if nargin<1
maxit=5
end
if nargin<2
x0=zeros(2,1)
end
%----Coefficients for the case of two distinct solutions
alpha=1.4;beta=-0.6;sigma=-1.6;tau=-4.6;
b=[-beta;-tau];
x=x0;
fprintf('\n k x(1) x(2) norm(f)\n');
for k=1:maxit
A=;
f=A*x-b;
x=A\b;
fprintf('%4d %9.5f %9.5f %10.2e\n',k,x(1),x(2),norm(f));
end
以上是编制的程序
x=demoSSub(10,[-1;-2])
k x(1) x(2) norm(f)
1-1.00000-2.000001.11e-016
2-1.00000-2.000003.33e-016
3-1.00000-2.000001.11e-016
4-1.00000-2.000003.33e-016
5-1.00000-2.000001.11e-016
6-1.00000-2.000003.33e-016
7-1.00000-2.000001.11e-016
8-1.00000-2.000003.33e-016
9-1.00000-2.000001.11e-016
10-1.00000-2.000003.33e-016
x =
-1
-2
x=demoSSub(10,)
k x(1) x(2) norm(f)
1 4.00000 5.000003.33e-016
2 4.00000 5.000003.33e-016
3 4.00000 5.000003.33e-016
4 4.00000 5.000003.33e-016
5 4.00000 5.000003.33e-016
6 4.00000 5.000003.33e-016
7 4.00000 5.000003.33e-016
8 4.00000 5.000003.33e-016
9 4.00000 5.000003.33e-016
10 4.00000 5.000003.33e-016
x =
4
5
x=demoSSub(10,)
k x(1) x(2) norm(f)
1 2.00000 2.200007.53e+000
2-4.00000-6.200006.00e+000
3-0.57143-1.400002.40e+001
4-1.12000-2.168001.96e+000
5-0.97087-1.959226.14e-001
6-1.00733-2.010271.45e-001
7-0.99817-1.997443.67e-002
8-1.00046-2.000649.15e-003
9-0.99989-1.999842.29e-003
10-1.00003-2.000045.72e-004
x =
-1.0000
-2.0000
(这个就不太明白了,为什么结果不收敛于(4,5)?)
请教各位高手,谢谢 x=A\b;
这个是基于高斯消元方法,是求解线性方程的
页:
[1]