# RIES - Find Algebraic Equations, Given Their Solution

First page . . . Back to page 3 . . . Forward to page 5 . . . Last page (page 6)

## Semiserious Math Tricks

### Wild Guessing

This is ostensibly the primary purpose of ries: using some approximate measurement or calculation as the basis of a "wild guess" at an exact solution.

Here is an example: xkcd 356 presents an "infinite grid of resistors" problem that looks like it should have a closed-form solution, but with no partucularly obvious way to find it.

Matthew Beckler performed circuit simulations of a number of grids ranging in size from the minimal set of 7 resistors up to 80 thousand. As the size of the simulated grid grows, the answer gets closer to what it should be for an infinite grid. His last 4 answers were: ..., 0.7743, 0.7735, 0.7733, 0.7733. One might guess that the limit, and true answer to the resistor problem, is somewhere around 0.7732 or 0.7733. Let's tell ries to search around 0.77325, with a maximum error of 0.0001:

ries 0.77325 --max-match-distance 0.0001 -x First match must be closer than 0.0001. Your target value: T = 0.77325 www.mrob.com/ries x+1/2 = 4/pi for x = 0.773239544735163 {74} (x+phi)^2 = 3+e for x = 0.773258931086369 {81} 1/x+1/3 = 4"/7 for x = 0.773249747663235 {89} ...Thus the simplest "wild guess" answer seems to be 4/π-1/2 = 0.773239... ohms. As others eventually showed, that is indeed the answer.

However this was a pretty lucky guess. We could have guessed that the answer is within 0.001 of the final measurement 0.7733, and ries would have told us the answer was √π-1 = 0.772453... To someone making a wild guess, this appears at least as believable as 4/π-1/2, which illustrates why wild guessing with ries isn't actually all that useful.

### Successive Refinement (Newton-Raphson Method)

Because ries uses derivatives to report how far an inequality deviates from an (exact) equality, you can use it 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}

To get a better approximation, add 1.442 and 0.00024957:

ries 1.44224957

(other answers not shown)

x^3 = 3 for x = T + 3.07408e-10 {51}

Then add 3.07408×10^{-10} (notice you have to add a zero):

ries 1.442249570307408

(other answers not shown)

x^3 = 3 for x = T + 2.22045e-16 {51}

(and so on...)

ries uses about 16 digits in its internal calculations, so this is
about as precise as you can get. The actual value of the cube root of
3 (to 25 digits) is 1.4422495703074083823216383... Although this
specific example is a case of extreme computational overkill, the same
method can be used for things that cannot be computed directly, such
as the value of x for which x^{x}=10.

### Forgotten Identities

If you're like most people who took Trigonometry in high school, you remember that there was something called "trigonometric identities", but nothing more. Maybe you remember that sine could be turned into cosine somehow, but that's about it.

With ries you can rediscover all the identities, and probably a few more you never knew existed. For this example we'll use a profile called "rad.ries":

# rad.ries: Use trigonometry functions in radians --trig-argument-scale 1 # radians -NLleEv # No log, ln, e, e^x or arbitrary rootsUsing a calculator (or a command like ries -prad.ries 1 --eval-expression 1S) you can find out the sine of 1 radian, which is 0.841470984807897. Naturally, if you give ries this number, it will tell you:

ries -prad.ries 0.841470984807897 x = sin(1) for x = T - 4.44089e-16 {38}We want to discover other ways to get the same value without using the sine function. To do this we simply tell ries that sin() is not allowed using the -NS option:

ries -prad.ries 0.841470984807897 -NS x/cos(1) = tan(1) for x = T - 4.44089e-16 {66}So ries has told us that our number x (which we know to be the sine of 1) divided by the cosine of 1 is equal to the tangent of 1. Therefore sin(1)/cos(1) = tan(1). Going back to your calculator, you can verify that sin(x)/cos(x) = tan(x) for lots of values of x. This is our first trigonometric identity.

Let's find another one: while still using the target value 0.841470984807897, exclude the tangent function too:

ries -prad.ries 0.841470984807897 -NST x^2-1 = -(cos(1)^2) for x = T - 4.44089e-16 {78}
Move things around a bit with a little algebra, and this tells us that
sin(1)^{2} + cos(1)^{2} = 1, which generalizes into another identity:
sin^{2}x+cos^{2}x=1. (The square of a trig function is usually
written "sin^{2}x" rather than "sin(x)^{2}" or "(sin(x))^{2}"
because the latter is a bit cluttered and the other might be confused
with "sin(x^{2})").

First page . . . Back to page 3 . . . Forward to page 5 . . . Last page (page 6)

Contents: ries overview Benchmarks History Stupid Math Tricks Semiserious Math Tricks Links and miscellaneous

s.11