What Bo means is that if you execute

a =: irrational_number

and then convert the approximation a to rational, the denominator will be large.

Not necessarily true: first of all, x: uses tolerant comparison:

   x: 1.000000000000001
1

so to look at all the bits of a you need

   (x:!.0) 1.000000000000001
900719925474100r900719925474099

[and note: that was a perfectly respectable rational number, but it comes out with a large denominator]

Moreover,

   x: 1.000000000000000000014973485793   NB. It's an irrational number, I just got tired of typing
1

Henry Rich




On 6/14/2018 10:12 AM, William Tanksley, Jr wrote:
I have no idea why you're saying that. Irrationals don't have denominators;
they cannot be written as fractions. And no floating point numbers are
irrationals.

On Thu, Jun 14, 2018 at 12:18 AM 'Bo Jacoby' via Programming <
[email protected]> wrote:

If a floating point number (a) , is irrational, then (x:a) has a
denominator greater than 1e10.
Some rational and irrational numbers are:
    x:%%:>:i.5
1 676982533219r957397879968 9943229281777r17222178307344 1r2
8728368286235r19517224820674
The denominators are:
     1 957397879968 17222178307344 2 19517224820674
1 9.57398e11 1.72222e13 2 1.95172e13
So the problem of identifying irrational numbers is reduced to the problem
of finding the denominator in x:a
/Bo.

     Den 23:42 onsdag den 13. juni 2018 skrev Linda Alvord <
[email protected]>:



I wrote a definition with only one argument.

Linda

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Programming <[email protected]> on behalf of
Raul Miller <[email protected]>
Sent: Wednesday, June 13, 2018 4:36:31 PM
To: Programming forum
Subject: Re: [Jprogramming] Finding Irrational Numbers

So, something like this?

fe=:4 :0
   p=. 9!:10''
   vi=. _.
   ve=. y
   try.
     9!:11 x
     ve=. ":&.>y
     9!:11]15
     vi=. ":&.>y
   catch.
   end.
   9!:11 p
   ve=vi
)

Thanks,

--
Raul
On Wed, Jun 13, 2018 at 4:22 PM Skip Cave <[email protected]> wrote:
So I'm thinking something like this, to find exact numbers in a floating
point array:


pps 15 NB. Set the print precision.


Create a mixed floating point vector b:


    ]b=:(,3? 10^1+i.4),%a=:1+i.20

0 2 7 36 93 57 808 875 559 4674 8635 6196 1 0.5 0.333333333333333 0.25
0.2
0.166666666666667 0.142857142857143 0.125 0.111111111111111 0.1
0.0909090909090909 0.0833333333333333 0.0769230769230769
0.0714285714285714
0.0666666666666667 0.0625 0.0588235294117...


Create a "find exact" verb 'fe' where x=the number of digits max that can
be exact, and y is the vector to be tested (boolean result):


    fe=. 4 : 'x> ># each ": each <"1,.y'


    ]c=.9 fe b

1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 0 1 0 0 0 0 0 1 0 0 0 1


Show exact:

    c#b

0 2 7 36 93 57 808 875 559 4674 8635 6196 1 0.5 0.25 0.2 0.125 0.1 0.0625
0.05


Show inexact:

    (-.c)#b

0.333333333333333 0.166666666666667 0.142857142857143 0.111111111111111
0.0909090909090909 0.0833333333333333 0.0769230769230769
0.0714285714285714
0.0666666666666667 0.0588235294117647 0.0555555555555556
0.0526315789473684
    #b

32

    #c#b

20


I'm sure this scheme has some holes, but it is a reasonable first cut.


Skip
----------------------------------------------------------------------
For information about J forums see
https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C41ac47c72e1441cc1f0b08d5d16d6b12%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636645190246397362&sdata=C%2B8YZ2EAW533k4brRJj7gZXQzxUXVbnCthCXYM1YZ1I%3D&reserved=0
----------------------------------------------------------------------
For information about J forums see
https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C41ac47c72e1441cc1f0b08d5d16d6b12%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636645190246397362&sdata=C%2B8YZ2EAW533k4brRJj7gZXQzxUXVbnCthCXYM1YZ1I%3D&reserved=0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


---
This email has been checked for viruses by AVG.
https://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to