1e9<1{"1]2 x: %:i.26
0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0
1{ is better than }. .
1{"1]2 x: %:14
6286063111
This denominator is <1e10
/Bo.
Den 11:44 torsdag den 14. juni 2018 skrev Skip Cave
<[email protected]>:
OK. Thanks to Bo, sizing the denominators looks like the way to go. Here's
a verb that looks at the denominators of extended/rational numbers and
determine if the denominator is too big, and thus the number is inexact:
NB. First generate some exact & inexact numbers:
]t=.x:%%:>:i.5
1 676982533219r957397879968 9943229281777r17222178307344 1r2
8728368286235r19517224820674
NB. Now get the denominators, & check the size - too big=0, small enough -
1:
-.,1e10<}."1(2&x:)t
1 0 0 1 0
NB. Use the selection vector to pick out the exact values:
t#~-.,1e10<}."1(2&x:)t
1 1r2
]b=.x:%%:>:i.15
1 676982533219r957397879968 9943229281777r17222178307344 1r2
8728368286235r19517224820674 250258529119r613005700122
12895459543967r34118178995231 1532495590117r4334552095641 1r3
16884524975r53393556131 535761049157r1776918377341
3208086930518r1111313911750...
b#~ -.,1e10<}."1(2&x:)b
1 1r2 1r3
Skip
On Thu, Jun 14, 2018 at 2: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.
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm