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: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Fun with Unbounded Rational Numbers Date: Sun, 9 Apr 2017 10:56:29 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <87zifq831u.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 9 Apr 2017 08:53:26 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a97849d36a3c8ea2c5f5f919cb6231fd"; logging-data="8356"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MT7o2nCe3lbwDxfOKddOFFIbmYYch/Qw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <87zifq831u.fsf@nightsong.com> Cancel-Lock: sha1:cfYLaiNqoSvC/FPWO1f5oVD4qNI= Xref: news.eternal-september.org comp.lang.ada:46548 Date: 2017-04-09T10:56:29+02:00 List-Id: 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