www.pudn.com > shuzhijisuanwendingxing.rar > p22_2.m, change:2009-09-25,size:434b


format long 
clear; 
clc; 
%p22实验二算法一 
I0=log(16/15); 
for n_1=1:20 
    if (n_1-1)==0 
        I_1(n_1)=-15*I0+1/n_1; 
    else 
        I_1(n_1)=-15*I_1(n_1-1)+1/n_1; 
    end 
end  
I_1=(I_1)' 
%p22实验二算法二 
I_2(20)=31/10080; 
for n_2=20:-1:2 
    I_2(n_2-1)=(1/15)*(-I_2(n_2)+1/n_2); 
end 
I_2=(I_2)' 
%算法一与算法二结果的差值 
for i=1:20 
    difference(i)=I_1(i)-I_2(i); 
end 
difference=difference' 
d=I_1(1)-I_2(1);