Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #57602

Re: real to rational number

Newsgroups comp.lang.forth
Date 2017-04-19 11:32 -0700
References <d34926ea-ca84-4918-aa2f-82ebb21c6470@googlegroups.com> <daeeeafd-106e-492d-b7dc-5d44192da42f@googlegroups.com> <e5142668-00d8-44f1-9508-b46a41c73545@googlegroups.com> <5285ee08-d994-446e-8801-effd45672589@googlegroups.com> <cc259d92-a0de-4f95-9a5d-74c0d6d54c24@googlegroups.com>
Message-ID <34cfba86-e235-4a9f-bd54-973749454e30@googlegroups.com> (permalink)
Subject Re: real to rational number
From hughaguilar96@gmail.com

Show all headers | View raw


On Wednesday, April 19, 2017 at 4:53:13 AM UTC-7, krishna...@ccreweb.org wrote:
> On Wednesday, April 19, 2017 at 1:42:55 AM UTC-5, hughag...@gmail.com wrote:
> > On Tuesday, April 18, 2017 at 7:17:07 PM UTC-7, krishna...@ccreweb.org wrote:
> > > On Tuesday, April 18, 2017 at 9:06:39 AM UTC-5, hughag...@gmail.com wrote:
> > > > I have rational numbers in the novice-package. This goes way back to 2010.
> > > > 
> > > > They don't work very well because the numerator and denominator are 32-bit, which is pretty small. They'll work a lot better in Straight Forth that requires a 64-bit cell and provides a double-stack that is separate from the single-stack.
> > > > 
> > > > I don't know what you mean by a "brute force search." I wrote code that determines the GCD --- isn't that the way that it is always done?
> > > 
> > > Take, for example, the following real number:
> > > 
> > > r = 7.61904761904762e-02
> > > 
> > > Find the fraction a/b, so that it agrees to 15 significant digits. It is a simple fraction. Can a double length GCD can do this in a reasonable time?
> > > 
> > > Krishna
> > 
> > When I said that I have code for GCD, I meant that this is used for adding ratios together --- they have to have a common denominator so you can add the numerators.
> > 
> > For converting a real number into a ratio, you need to use continued fractions. I have this in the novice-package, but I didn't write it --- it was written by Nathaniel Grossman and published in "Forth Dimensions" (Sep/Oct 1984) --- all I did was upgrade his program to work under 32-bit ANS-Forth rather than 16-bit Forth-83.
> > 
> > CF is very slow because ANS-Forth lacks a double-precision division --- this had to be written in high-level Forth --- this is UD/MOD which is in the support code.
> > 
> > Here is an example:
> > 
> > 00761904761904762.  ok-2 
> > 10000000000000000.  ok-4 
> > cf 
> > partial-quot             numerator           denominator
> >            0                     0                     1
> >           13                     1                    13
> >            8                     8                   105
> > ...
> 
> Very good. The continued fraction should truncate when we have achieve the same number of significant digits specified for r, in this case, 15. With regard to your question about what constitutes a brute-force search, please see my reply to lehs.
> 
> Krishna

You are right. I should make it stop after it has achieved maximum precision.

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

real to rational number krishna.myneni@ccreweb.org - 2017-04-18 04:49 -0700
  Re: real to rational number lehs <skydda.barnen@gmail.com> - 2017-04-18 06:48 -0700
    Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-18 19:09 -0700
      Re: real to rational number lehs <skydda.barnen@gmail.com> - 2017-04-18 22:53 -0700
        Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-19 04:43 -0700
          Re: real to rational number rickman <gnuarm@gmail.com> - 2017-04-19 15:41 -0400
            Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-19 13:03 -0700
              Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-20 17:26 +0000
              Re: real to rational number hughaguilar96@gmail.com - 2017-04-20 14:29 -0700
      Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-19 23:44 +0000
        Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-19 19:30 -0700
          Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-20 17:08 +0000
            Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-20 11:46 -0700
              Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-21 09:47 +0000
            Re: real to rational number lehs <skydda.barnen@gmail.com> - 2017-04-20 20:49 -0700
    Re: real to rational number rickman <gnuarm@gmail.com> - 2017-04-19 15:36 -0400
      Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-20 18:44 -0700
  Re: real to rational number hughaguilar96@gmail.com - 2017-04-18 07:06 -0700
    Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-18 19:17 -0700
      Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-18 19:45 -0700
        Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-18 19:57 -0700
        Re: real to rational number anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-04-19 05:35 +0000
      Re: real to rational number hughaguilar96@gmail.com - 2017-04-18 23:42 -0700
        Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-19 04:53 -0700
          Re: real to rational number hughaguilar96@gmail.com - 2017-04-19 11:32 -0700
  Re: real to rational number minforth@arcor.de - 2017-04-18 08:23 -0700
    Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-18 19:24 -0700
      Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-18 19:48 -0700
        Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-18 20:01 -0700
  Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-18 19:39 -0700
    Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-18 19:56 -0700
      Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-19 00:41 -0700
        Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-19 04:48 -0700
        Re: real to rational number hughaguilar96@gmail.com - 2017-04-19 11:30 -0700
      Re: real to rational number albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-04-20 20:15 +0200
        Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-20 15:23 -0700
          Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-20 18:52 -0700
  Re: real to rational number Pablo Hugo Reda <pabloreda@gmail.com> - 2017-04-18 19:58 -0700
    Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-18 20:05 -0700
      Re: real to rational number Pablo Hugo Reda <pabloreda@gmail.com> - 2017-04-19 05:30 -0700
        Re: real to rational number Pablo Hugo Reda <pabloreda@gmail.com> - 2017-04-19 05:35 -0700
          Re: real to rational number Pablo Hugo Reda <pabloreda@gmail.com> - 2017-04-19 05:41 -0700
            Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-19 19:39 -0700
  Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-19 23:16 +0000
    Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-19 19:42 -0700
      Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-20 17:15 +0000
        Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-20 15:11 -0700
          Re: real to rational number hughaguilar96@gmail.com - 2017-04-20 15:49 -0700
            Re: real to rational number Alex <alex@rivadpm.com> - 2017-04-21 00:20 +0100
              Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-20 18:49 -0700
                Re: real to rational number The Beez <the.beez.speaks@gmail.com> - 2017-04-21 03:18 -0700
                Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-21 18:39 -0700
                Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-21 18:46 -0700
                Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-21 21:55 -0700
                Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-22 08:33 -0700
                Re: real to rational number Paul Rubin <no.email@nospam.invalid> - 2017-04-22 13:35 -0700
                Re: real to rational number The Beez <the.beez.speaks@gmail.com> - 2017-04-24 00:58 -0700
                Re: real to rational number minforth@arcor.de - 2017-04-24 01:08 -0700
                Re: real to rational number minforth@arcor.de - 2017-04-23 02:28 -0700
                Re: real to rational number hughaguilar96@gmail.com - 2017-04-21 18:43 -0700
                rationalising  reality,   was Re: real to rational number Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2017-04-22 10:28 +0100
                Re: rationalising  reality,   was Re: real to rational number Mark Wills <markwills1970@gmail.com> - 2017-04-22 02:33 -0700
            Re: real to rational number krishna.myneni@ccreweb.org - 2017-04-20 16:22 -0700
              Re: real to rational number hughaguilar96@gmail.com - 2017-04-20 22:02 -0700
                Re: real to rational number Julian Fondren <julian.fondren@gmail.com> - 2017-04-21 00:12 -0700
                Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-21 09:55 +0000
                Re: real to rational number hughaguilar96@gmail.com - 2017-04-25 10:52 -0700
                Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-29 03:16 +0000
              Re: real to rational number "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-04-21 09:52 +0000
              Re: real to rational number lehs <skydda.barnen@gmail.com> - 2017-04-21 05:35 -0700
                Re: real to rational number hughaguilar96@gmail.com - 2017-04-21 19:05 -0700
                Re: real to rational number The Beez <the.beez.speaks@gmail.com> - 2017-04-24 01:14 -0700
                Re: real to rational number Cecil Bayona <cbayona@cbayona.com> - 2017-04-24 11:31 -0500
                Re: real to rational number The Beez <the.beez.speaks@gmail.com> - 2017-04-25 00:52 -0700
                Re: real to rational number hughaguilar96@gmail.com - 2017-04-24 11:43 -0700
                Re: real to rational number The Beez <the.beez.speaks@gmail.com> - 2017-04-25 00:35 -0700
                Re: real to rational number The Beez <the.beez.speaks@gmail.com> - 2017-04-25 01:09 -0700
                Re: real to rational number minforth@arcor.de - 2017-04-26 01:55 -0700

csiph-web