Demo entry 6361890

1

   

Submitted by anonymous on May 05, 2017 at 15:58
Language: Matlab. Code size: 603 Bytes.

s=0;
s1=s;
s2=s;
sum1=single(s);
sum2=single(s);
for i= 1:10000
    j1=single(1/i^4);
     s1=s1+(1/i^4);%双精度顺向相加
   sum1=sum1+j1;%单精度顺向相加
end
for i= 10000:-1:1
    j2=single(1/i^4);
    s2=s2+(1/i^4);%双精度逆向相加
   sum2=sum2+j2;%单精度逆向相加
end
real=pi^4/90;
sum1
sum2
s1
s2
e1=(sum1-real)/real*100%;
e2=(sum2-real)/real*100%;
e3=(s1-real)/real*100%;
e4=(s2-real)/real*100%;

sum1 = 1.0823221

sum2 = 1.0823232

s1 = 1.082323233710861


s2 = 1.082323233710805


e1 = -1.0283846e-04


e2 = -3.7106315e-06


e3 = -2.558289554517808e-11


e4 = -3.077333064776834e-11

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).