home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math
- Path: sparky!uunet!news.univie.ac.at!chx400!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!sgiblab!daver!cylink!tedh
- From: tedh@cylink.COM (Ted Hadley)
- Subject: Real -> fraction algorithm needed
- Message-ID: <1992Oct16.171046.13025@cylink.COM>
- Sender: tedh@cylink.COM (Ted Hadley)
- Organization: Cylink Corp.
- Date: Fri, 16 Oct 92 17:10:46 GMT
- Lines: 34
-
- Greetings. I need an algorithm which I can code in 'C' which performs the
- following task. This, I feel, is the best place to ask. If this is a common
- request, please skip the details and cite a reference. Much appreciated. Here
- goes:
-
- Part 1: General case:
-
- Given an real number X, compute to integers A and B such that A/B most
- closely approximate X
-
- Part 2: First constraint:
-
- Repeat (1) such that the error, defined as the fractional part of A/(BX), is
- within a certain bound (say +/- E) AND A and B are minimized (i.e., the
- smallest possible values which produce a quotient with acceptible error).
-
- Part 3: Second contraint: (this is the preferred form)
-
- Given X, E, and Amax and Bmax, where Amax and Bmax are the maximum allowable
- integers for A and B, respectively, compute all values of A and B for which
- the error E is acceptible. For example: |A| < Amax and |B| < Bmax and some
- value for E, list all possible {A, B} for which |fract(A/(BX))| < E.
-
-
- ANY information is appreciated. I am not, however, a mathematician, and my
- math skills are quite rusty. I have no idea how to approach the problem in
- order to derive my own solution.
-
- Please E-mail responses. If there are other requests, I will post the
- responses. Thanks again.
- --
- Ted A. Hadley tedh@cylink.COM "Credo qvia absvrdvm est" -- Tertullian
- Cylink Corporation, 310 N. Mary Ave., Sunnyvale, CA 94086 USA 408-735-5847
- All opinions expressed are my own, and probably not liked by my employer.
-