comp.lang.ada
 help / color / mirror / Atom feed
* Fun with Unbounded Rational Numbers
@ 2017-04-08 10:37 Jeffrey R. Carter
  2017-04-08 11:19 ` Dmitry A. Kazakov
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Jeffrey R. Carter @ 2017-04-08 10:37 UTC (permalink / raw)


I decided to see what happens when you calculate square roots using Newton's 
method and the unbounded rational numbers in PragmARC.Rational_Numbers. Some 
interesting things happen.

For example, trying to calculate sqrt(2) to a small enough accuracy (0.000001 
will do it) results in the calculation of the next estimate

          M := Two * X;
          X := X - Y / M;

taking a Long Time (it does conclude eventually).

More alarming, though, is that for some values, even a fairly large accuracy 
will quickly result in Storage_Error. For example, sqrt(1.28) to an accuracy of 
0.01 will do it.

I realize that square roots are often irrational, but the accuracies seem so 
large that I didn't anticipate consuming GB of memory. Just naive, I guess.

-- 
Jeff Carter
"C++ is vast and dangerous, a sort of Mordor of
programming languages."
Jason R. Fruit
120


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-04-11 21:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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