查看单个帖子
旧 2009-03-25, 16:59   #2
laosam280
高级会员
 
注册日期: 2008-11-07
住址: 湖南长沙
帖子: 233
声望力: 21
laosam280 正向着好的方向发展
默认 回复: 解四元二次方程组

首先,编写一个不动点迭代法的求解程序。不动点解法比较简单,同样还有牛顿法,下山法。。。不一一类举了。
function [r,n]=stablepoint(x0,eps)
% 初始迭代点x0
% 迭代精度 eps
% 解 r
% 迭代步数 n
if nargin==1
eps=1.0e-4;
end
r=fun(x0);
n=1;
tol=1;
while tol>eps
x0=r;
r=fun(x0);
tol=norm(r-x0);
n=n+1;
if(n>100000)
disp('sum of steps is too much !');
return;
end
end

其中fun函数就是你需要求解的方程组。
laosam280 当前离线   回复时引用此帖