🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.mac
Article #1522

Re: Harmonic Series Benchmark

#1522
From: brouille
Date: Mon, 27 May 1985 21:56
27 lines
1541 bytes
*** REPLACE THIS LINE WITH YOUR MESSAGE ***

Before starting to argue as to which machine has the exact result, we should
first discuss the algorithm.
 
Calculating the harmonic by:
 
    for  ( i=1; i <= 10000; i++ )
        j += ( 1.0 / i );
 
is clumsy. When i reaches the big numbers, a lot of small significant digits
will be lost when we perform the addition.    For example, lets suppose that
the machine has 8 decimal digits of accuracy, and that the sum for
i = 1 to 9499 is  9.7325632.   Adding 1.0/9500 (1.0526316E-4) to our sum
will be done by first adjusting the small number to 0.0001053, and then
adding it to 9.7325632.  We have lost quite a few significant digits in
the process.
 
A better way is to write:
 
    for  ( i=10000; i > 0; i-- )
        j += ( 1.0 / i );
 
In this case, the Vax/780 comes with the answer 9.787604 (and not 9.787613)!
I would be curious to see what are the results on other systems.

			Jean-Luc Brouillet
Technical Details
Message-ID: <5709@Shasta.ARPA>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!decwrl!Glacier!Shasta!brouille
References: <> <> <1363@amd.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site Shasta.ARPA
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!decwrl!Glacier!Shasta!brouille
From: brouille@Shasta.ARPA
Newsgroups: net.micro.mac
Subject: Re: Harmonic Series Benchmark
Message-ID: <5709@Shasta.ARPA>
Date: Mon, 27-May-85 17:56:01 EDT
Article-I.D.: Shasta.5709
Posted: Mon May 27 17:56:01 1985
Date-Received: Thu, 30-May-85 00:49:42 EDT
References: <> <> <1363@amd.UUCP>
Organization: Stanford University
Lines: 27