[REBOL] Re: Math bug?
From: joel:neely:fedex at: 29-Jun-2001 16:12
Hi, mb,
I got 297 as well, on RedHat Linux 7.1 with View 1.2.0.4.2
installed. However, I'm a little leery of calling these
errors
as it is well known from numerical analysis that
trying to do floating-point with decimal-based values on
a binary-based machine is a fruitful source of rounding
fuzz
.
A fairly standard demonstration of round-off fuzz is the
pair of functions below. Although the calculations are
mathematically equivalent, one starts "at the big end" and
the other starts "at the small end" of the summation. As
a consequence, their results drift further apart as the
number of terms increases.
>> add-up: func [n /local i t s] [
[ t: 0 for i 1 n 1 [s: 1.0 / i t: s * s * s + t]
[ ]
>> add-down: func [n /local i t s] [
[ t: 0 for i n 1 -1 [s: 1.0 / i t: s * s * s + t]
[ ]
>> add-up 100 == 1.20200740065968
>> add-down 100 == 1.20200740065968
>> add-up 1000 == 1.20205640365934
>> add-down 1000 == 1.20205640365934
>> add-up 10000 == 1.2020568981601
>> add-down 10000 == 1.20205689816009
>> add-up 100000 == 1.20205690310973
>> add-down 100000 == 1.20205690310959
>> add-up 1000000 == 1.20205690315032
>> add-down 1000000 == 1.20205690315909
HTH!
-jn-
mb wrote:
> Hi,
> can you please test this code on your systems ?
>
...
> Any errors ?
> I've got 297 errors on my Amiga, and similar results with
> Windows 95/98 on work.
>
--
------------------------------------------------------------
Programming languages: compact, powerful, simple ...
Pick any two!
joel'dot'neely'at'fedex'dot'com