> On a similar note, is there a way to detect which numbers in a vector of
> rational fractions will result in infinitely repeating floating-point
> numbers?

All rational fractions result in infinitely repeating floating point
numbers.  They are the same sets.

On Wed, Jun 13, 2018 at 11:44 AM, Skip Cave <s...@caveconsulting.com> wrote:

> Ok. I see.
>
> We know pi is an irrational number. However, in J:
>
> x: o.1
>
> 1285290289249r409120605684
>
>
> J converts pi to a rational fraction approximation of pi. So I'm not sure
> how to generate a vector of truly irrational numbers in J. Can it be done,
> or is there no way to define/create true irrational numbers in J? I expest
> it would be hard to support irrational numbers on a finite word-size
> machine, but then I also thought extended integers would be impossible. I'm
> guessing you might have to create a new noun type - irrational?
>
>
> On a similar note, is there a way to detect which numbers in a vector of
> rational fractions will result in infinitely repeating floating-point
> numbers?
>
>
> Skip
>
>
> On Wed, Jun 13, 2018 at 1:17 PM Roger Hui <rogerhui.can...@gmail.com>
> wrote:
>
> > Mathematically, all finite precision floating point numbers (e.g. 64-bit
> > floats) are rational since they are all ratios of integers.  You have to
> > specify something (size of repeating pattern? size of denominator?
> relative
> > size of numerator/denominator? ??) before the question can be answered.
> >
> > For example, with your second vector a,
> >
> >    ]a=.(20?.20){(100*%1+i.10),(10?.20)*o.1
> > 15.708 18.8496 37.6991 9.42478 16.6667 50 25 100 14.2857 50.2655 10
> 11.1111
> > 3.14159 0 33.3333 43.9823 12.5 20 40.8407 56.5487
> >
> >    x: a
> > 5646741500662r359482728877 4414041858589r234172193603
> > 376716722090r9992721411 4414041858589r468344387206 50r3 50 25 100 100r7
> > 1681140150209r33445220617 10 100r9 1285290289249r409120605684 0 100r3
> > 10299431003375r234172193603 25r2 20 15619071123724r382438827...
> >
> >    x: 4 5$a
> >  5646741500662r359482728877 4414041858589r234172193603
> > 376716722090r9992721411  4414041858589r468344387206
> > 50r3
> >                          50                         25
> >   100                       100r7 1681140150209r33445220617
> >                          10                      100r9
> > 1285290289249r409120605684                           0
> >  100r3
> > 10299431003375r234172193603                       25r2
> >    20 15619071123724r382438827053   188358361045r3330907137
> >
> >    x:!.0 ]4 5$a
> > 4421398595017775r281474976710656 2652839157010665r140737488355328
> > 2652839157010665r70368744177664 2652839157010665r281474976710656
> > 2345624805922133r140737488355328
> >                               50                               25
> >                    100                            100r7
> >  884279719003555r17592186044416
> >                               10                            100r9
> > 884279719003555r281474976710656                                0
> > 2345624805922133r70368744177664
> >  3094979016512443r70368744177664                             25r2
> >                     20  1436954543380777r35184372088832
> > 1989629367757999r35184372088832
> >
> > Some are "obviously" rational and some aren't but all are mathematically
> > rational.
> >
> >
> >
> > On Wed, Jun 13, 2018 at 11:06 AM, Skip Cave <s...@caveconsulting.com>
> > wrote:
> >
> > > Roger,
> > > You're right. The array i generated was all rational numbers. I'll try
> > > again:
> > >
> > > ]a=.(20?20){(100*%1+i.10),(10?20)*o.1
> > >
> > > 6.28319 10 11.1111 16.6667 25.1327 100 0 21.9911 33.3333 56.5487 12.5
> > > 31.4159 53.4071 14.2857 25 43.9823 50 12.5664 59.6903 20
> > >
> > >
> > > Is that a better combination of rational and irrational numbers?
> > >
> > >
> > > I think I was originally thinking that floating-point numbers that have
> > > infinitely repeating patterns after the decimal are irrational. but
> that
> > is
> > > not the correct definition of irrational. However, a verb that could
> find
> > > those kinds of numbers (infinitely repeating pattern) in a vector of
> > > floating point numbers could be useful.
> > >
> > >
> > > Skip
> > >
> > >
> > >
> > >
> > > On Wed, Jun 13, 2018 at 12:44 PM Roger Hui <rogerhui.can...@gmail.com>
> > > wrote:
> > >
> > > > What's an irrational number in this context?  Your list a are
> > reciprocals
> > > > of integers and so are all rational.  On the other hand, going just
> by
> > > the
> > > > display, 0.5 is a rational number (1%2), but since the display is to
> 6
> > > > significant digits, for all you know 0.5 could be
> > > > 0.500000314159265358979... (0.5+ pi*1e_7) and irrational.
> > > >
> > > >
> > > > On Wed, Jun 13, 2018 at 10:29 AM, Skip Cave <s...@caveconsulting.com
> >
> > > > wrote:
> > > >
> > > > > Here's another problem similar to my previous one about finding
> > > integers
> > > > in
> > > > > a floating point array:
> > > > >
> > > > > Find the irrational numbers in a floating-point array:
> > > > >
> > > > > Given the vector a:
> > > > >
> > > > > ]a =. % 1+i.20
> > > > >
> > > > > 1 0.5 0.333333 0.25 0.2 0.166667 0.142857 0.125 0.111111 0.1
> > 0.0909091
> > > > > 0.0833333 0.0769231 0.0714286 0.0666667 0.0625 0.0588235 0.0555556
> > > > > 0.0526316 0.05
> > > > >
> > > > >
> > > > > Create a function that will generate a boolean array indicating the
> > > > > locations of the irrational numbers in a.
> > > > >
> > > > >
> > > > > Skip
> > > > >
> > ----------------------------------------------------------------------
> > > > > 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
> > ----------------------------------------------------------------------
> > 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

Reply via email to