On Wed, 19 Feb 2020, Paul Procacci wrote:
>  >> Is there a test to see if a number is irrational
> There is no such thing as an irrational number in computing.
> 
> Surely there are "close approximations", but that's the best any computer
> language can currently do.
> 

It all depends on representation.  Of course there are ways to write
algebraic numbers as their minimal polynomials over the rationals.
You may not call that a "number", but you can do effective arithmetic
with such a representation, so for many purposes it's as good as a
"chunk of bits" number and it is an exact symbolic representation of
a (possibly irrational) number from which you can extract rational
approximations of any wanted precision.  And in that representation,
a number is irrational if and only if the minimal polynomial has
degree at least two, very easy to check.  (Note, however, that you
do not get all irrationals in this way. π and e are still out of
reach, for example.)

Granted, Todd would not have anticipated this answer if he calls
arbitrary length integers "magic powder" and the question "I have
computed this Int/Num/Rat in Raku, is it rational?" does indeed
not make any sense.  But there are computer languages that can do
better.  Given FatRats, such modules can be written for Raku today.

There seems to be a slogan of some sort that, if you search IRC logs
or the documentation, pops up a number of times: "Perl 6 (Raku) is not
a computer algebra system" ("RINACAS"?).  I don't know what happened
in the history of Perl 6 development, but it seems that irrationals
were sought in core at some point and it was Larry who stopped that
motion [1].

Regards,
Tobias

[1] https://github.com/Raku/problem-solving/issues/4#issuecomment-474892811

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

Reply via email to