From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: Fun with Unbounded Rational Numbers Date: Sun, 09 Apr 2017 14:18:31 -0700 Organization: A noiseless patient Spider Message-ID: <87mvbp8el4.fsf@nightsong.com> References: <87zifq831u.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b16989435b88b0831ddb8cc29a2fc759"; logging-data="15948"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mo7J9aZMGBr4Fq094PZPw" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:gZOPdLgLketCTp48KNUNmGJaamk= sha1:MbZWpmZCvagkfuAOcGQ0w8E0smM= Xref: news.eternal-september.org comp.lang.ada:46558 Date: 2017-04-09T14:18:31-07:00 List-Id: "Jeffrey R. Carter" writes: > The implementation is > > X := R / Two; > All_Iterations : for I in 1 .. 15 loop > Y := X ** 2 - R; > exit All_Iterations when abs Y < A; ... Can you instrument this loop to check how many iterations are actually being executed, and preferably how long each one takes? The same calculation in compiled Haskell takes about 0.012 cpu seconds including printing the answer, which is about 50k chars (i.e. 25k digits for each of the numerator and denominator). Doing 25 iterations takes about 2 minutes and uses around 250MB of memory, giving an answer of around 50M chars. You should get within 1e-8 or whatever it was in less than 5 iterations.