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


Groups > comp.lang.forth > #57606

Re: real to rational number

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.forth
Subject Re: real to rational number
Date Wed, 19 Apr 2017 13:03:25 -0700
Organization A noiseless patient Spider
Lines 20
Message-ID <87mvbcdv1u.fsf@nightsong.com> (permalink)
References <d34926ea-ca84-4918-aa2f-82ebb21c6470@googlegroups.com> <ca01c066-3b47-4138-8ff2-558bea6d1db8@googlegroups.com> <d9c00413-adf9-4d5f-a342-2b0e436b733a@googlegroups.com> <8c2f9ac1-9fb9-4dc4-a43e-66f50ea2b838@googlegroups.com> <4203a8d4-bd7f-45c4-8552-e6c916e85ee4@googlegroups.com> <od8ebi$531$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="47e0bd6af43efb397f12aac8c938d83c"; logging-data="8376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18su1LdZ9dTj4MXGjehNIfO"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
Cancel-Lock sha1:cTiM02a/nixUgDDpxMKSMm8mvKU= sha1:9K6hxBAYW5QPguIWdtLqeUET0vI=
Xref csiph.com comp.lang.forth:57606

Show key headers only | View raw


rickman <gnuarm@gmail.com> writes:
> I don't understand all of the language you are using, but there are an
> infinite number of integers and the solution can be found arbitrarily
> close to any real value by finding larger value integers.  To my
> understanding there is *no* single solution unless you restrict the
> magnitude of the integers you use.

There's two questions being conflated:

1) given a floating point number x, find the smallest pair of integers
   a,b such that a/b == x to the same precision that x is given in.

2) given an irrational number x, find rational approximations that are
   as close as possible to x given their size.  E.g. for pi, the
   approximants are 3/1, 22/7, 333/106, 355/113, 103993/33102,
   104348/33215, 208341/66317, 312689/99532, 833719/265381,
   1146408/364913, etc.

Both of these are done with the continued fraction algorithm that I
posted.  It helps if you have bignum arithmetic for this sort of thing.

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