| RIES - Find Algebraic Equations, Given Their Solution |
ries is a program that takes any number (for example, 2.5063) and produces a list of equations very much like the following:
Notice the answers are ordered by increasing closeness to your number. It should also be apparent that the simplest equations come first and the more complex ones later on. ries follows the example of continued fractions as you go to longer equations, you get a closer approximaion to your number, and each approximation is the closest approximation that is available with an equation of that complexity.
ries is highly customizable. You can have it omit symbols (like the symbol for phi, the Golden Ratio) if you don't want it to use them in solutions. You can give it an integer and specify that it limit its search to calculations that come out to be exact integers, and it will figure out the shortest way to construct your number from the digits 1 through 9. ries can find the simplest way to (for example) express the value 27 using only the digit 4 and the four basic operators plus, minus, times and divide.
ries is also very fast. The above run takes less than 2 seconds on a 180-MHz P5 (586 clone) machine. You can specify a longer search to get more (and longer) equations, and it will try over 1010 equations in less than a minute. On a 733-MHz Pentium-III, ries -l4 tests over 1.4×1012 equations in 62 seconds and uses 115 megs of memory.
I wrote ries after I was frustrated by services such as Plouffe's Inverterand the Inverse Symbolic Calculator. In case you're wondering, the things that frustrated me are described here.
ries runs under Linux1, but is is easily ported to nearly any C compiler and OS. The source code is distributed under GPL 2.0. You can also get the manpage source. If you don't already have a copy, you should also retrieve the GNU General Public License version 2.0, which defines the terms under which this source code is made available to you, here.
Stupid Math Tricks
Here are a few cute and/or fun things you can do with ries:
Finding Exact Solutions
You can use ries to iterate Newton's Method. Suppose you know that the cube root of 3 starts with the digits 1.442, and want to find more digits. ries 1.442 yields the result:
x^3 = 3 for X = T + 0.00024957 {51}
Just add a few of the digits it gives:
ries 1.442249
x^3 = 3 for X = T + 5.70307e-07 {51}
ries 1.442249570
x^3 = 3 for X = T + 3.07408e-10 {51}
and so on.
Four Fours
At one time this type of problem was popular: How do you reach various values using four 4's and any number of symbols (for example: 44/44 = 1, 4/4+4/4 = 2, (4+4+4)/4 = 3, etc.). Solutions of this type of problem can be found with a command like:
ries '-S4+-*/' 17 -Ox
x-4*4 = 4/4 (exact match)
which corresponds to the solution 4/4+4×4 = 17.
See Also
If you like ries, you might also be amused by my web pages on numbers and large numbers. There is also Hypercalc (the calculator that doesn't overflow) and this program which computes the Riemann Zeta function and turns the real and imaginary components into left and right audio waveforms, so you can listen to the Zeta function on your stereo (it actually sounds pretty good :-)
© 1996-2008 Robert P. Munafo.
Email the author
This work is licensed under a
Creative Commons Attribution 2.5 License.
Back to my main page
s.13