comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Fun with Unbounded Rational Numbers
Date: Sun, 9 Apr 2017 10:56:29 +0200
Date: 2017-04-09T10:56:29+02:00	[thread overview]
Message-ID: <occsq6$854$1@dont-email.me> (raw)
In-Reply-To: <87zifq831u.fsf@nightsong.com>

On 04/09/2017 09:15 AM, Paul Rubin wrote:
>
> did you remember to recompute Y in your loop?  i.e.
>
>          M := Two * X;
>          Y = X * X - 2     -- <---- this might have been missing?
>          X := X - Y / M;

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;

          M := Two * X;
          X := X - Y / M;
       end loop All_Iterations;

       return X;

where R is the argument and A the accuracy.

-- 
Jeff Carter
"This trial is a travesty. It's a travesty of a mockery of a
sham of a mockery of a travesty of two mockeries of a sham. ...
Do you realize there's not a single homosexual on that jury?"
Bananas
27

  reply	other threads:[~2017-04-09  8:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08 10:37 Fun with Unbounded Rational Numbers Jeffrey R. Carter
2017-04-08 11:19 ` Dmitry A. Kazakov
2017-04-08 14:14 ` Robert Eachus
2017-04-09  0:30 ` antispam
2017-04-09  8:47   ` Jeffrey R. Carter
2017-04-09 19:25     ` antispam
2017-04-10 17:18       ` Jeffrey R. Carter
2017-04-11 21:39         ` antispam
2017-04-09  7:15 ` Paul Rubin
2017-04-09  8:56   ` Jeffrey R. Carter [this message]
2017-04-09 21:18     ` Paul Rubin
2017-04-10 17:08       ` Jeffrey R. Carter
2017-04-10 19:39         ` Paul Rubin
2017-04-09 10:05   ` Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox