matlab lengd,计算方法的MATLAB实现

y1(k+1) = g1(y1(k));

y2(k+1) = g2(y2(k));

y3(k+1) = g3(y3(k));

y4(k+1) = g4(y4(k));

end

t=[1:iter_max+1];

plot(t,y1,'b.-',t,y2,'k.-',t,y3,'r.-',t,y4,'g.-','linewidth',1.5); legend('\phi_1','\phi_2','\phi_3','\phi_4');

______________________________

迭代的加速收敛方法

% 教材第 203 页例 7.8

clear all; close all;

syms x

g4 = (6*x^2 - 9*x +2)^(1/3);

dg4 = diff(g4,'x');

x0 = 3.5;

y4(1)=x0; y4n(1)=x0;

iter_max = 60;

for k = 1:iter_max

y4(k+1) = subs(g4,x,y4(k));

y4n_tmp = subs(g4,x,y4n(k))-subs(dg4,x,y4n(k))*y4n(k);

y4n(k+1) = y4n_tmp/(1-subs(dg4,x,y4n(k)));

end

t=[1:iter_max+1];

plot(t,y4,'g.-',t,y4n,'b.-','linewidth',1.5);

legend('old','new');

_______________________________

% Aitken 加速

clear all;

close all;

syms x

g4 = (6*x^2 - 9*x +2)^(1/3);

dg4 = diff(g4,'x');

x0 = 3.5;

y4(1)=x0; y4n(1)=x0; y5(1)=x0;

iter_max = 60;

for k = 1:iter_max

y4(k+1) = subs(g4,x,y4(k));

%

y4n_tmp = subs(g4,x,y4n(k))-subs(dg4,x,y4n(k))*y4n(k);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值