On Thu, Feb 20, 2020 at 2:25 PM ToddAndMargo via perl6-users
<perl6-us...@perl.org> wrote:
>
> On 2020-02-19 23:21, Shlomi Fish wrote:
> > Hi Paul,
> >
>
> > Well, it is not unthinkable that a
> > https://en.wikipedia.org/wiki/Computer_algebra_system (CAS)-like system 
> > will be
> > able to tell that the abstract number sqrt(2) is irrational, as well as some
> > derivative numbers such as 3 + sqrt(2). E.g:
>
> Hi Shlomi,
>
> Those "academic exercises" where enterprising college
> students run pi out to a bazillion digits to see if they
> can find a repeating patterns came up with some
> way of handling an "unbounded" number.  A "Real" (Cap R)
> perhaps?
>
> -T

You can identify repeating patterns in decimal fractions using the
method "base-repeating":

mbook:~ homedir$ perl6 -e 'say (1/7).base-repeating();'
(0. 142857)
mbook:~ homedir$ perl6 -e 'say (1/7).base-repeating(10);'
(0. 142857)
mbook:~ homedir$ perl6 -e 'say (1/7).base-repeating(10).perl;'
("0.", "142857")
mbook:~ homedir$ perl6 -e 'say (5/2).base-repeating(10).perl;'
("2.5", "")
mbook:~ homedir$

According to the Raku docs, "If no repetition occurs, the second
string is empty... ."
And the docs say: "The precision for determining the repeating group
is limited to 1000 characters, above that, the second string is ???."
https://docs.raku.org/type/Rational#method_base-repeating

HTH, Bill.

PS For those following along at home--unless it's been added since
Rakudo 2019.07--I don't see the "is_irrational()" function in the Raku
language referred to by Shlomi Fish. Or maybe I/we was/were to
understand that there isn't an "is_irrational()" function in the Raku
language as of yet.

https://stackoverflow.com/questions/42302488/identify-a-irrational-or-complex-number
https://mathoverflow.net/questions/91915/detecting-recognizing-irrational-number-by-computers
https://reference.wolfram.com/language/guide/ContinuedFractionsAndRationalApproximations.html
https://www.wolframalpha.com/examples/mathematics/numbers/irrational-numbers/
https://www.wolframalpha.com/examples/mathematics/number-theory/continued-fractions/

Reply via email to