RIES(1)

πŸ“¦
version 2018.08.05 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– RIES(1) πŸ’–

okay so bestie, you found a weird number and you wanna know what it is? this is the page for you. welcome to ries 🌸


✨ NAME ✨

ries β€” find algebraic equations, given their solution

πŸ¦‹ SYNOPSIS πŸ¦‹

ries [-ln] [-i[e]] [-s] [-x] [-Fn] [-Ssss] [-Nsss] [-Osss] [-Dxxx]
[-pfilename] [--extended-options [...]] value

ries --find-expression [expression [...]]

ries --eval-expression [expression [...]]

πŸ’… DESCRIPTION πŸ’…

So here's the vibe: you hand ries a number, and it goes hunting for algebraic equations in one variable that have a solution (a root) near that number. It's not gonna waste your time with trivial or reducible stuff like x/x = 1 β€” that's giving nothing, honestly. And if value is an integer, ries can straight up find an exact solution written out in terms of single-digit integers. iconic.

Like, say you feed it the value 2.5063. the first chunk of output will look something like this:

  $ ries 2.5063

      Your target value: T = 2.5063              mrob.com/ries

              2 x = 5              for x = T - 0.0063       {49}
              8 x = e^3            for x = T + 0.00439212   {66}
              x^2 = 2 pi           for x = T + 0.000328275  {55}
              x^x = 1+9            for x = T - 0.000115854  {69}
            x^2+e = 9              for x = T + 3.56063e-05  {63}
          ln(6) x = sqrt(pi)+e     for x = T + 2.73037e-05  {93}
            x/4+1 = 4,/7           for x = T + 6.24679e-06  {91}
   sinpi(ln(x))^2 = 1/(5 pi)       for x = T + 2.75665e-06  {92}

The output hands you progressively β€œmore complex” solutions (the whole complexity thing is explained below, keep reading bestie) that get progressively closer to matching your number. there are four columns and they are:

  • the equations in symbolic form (which is really two columns of expressions with a '=' in the middle)
  • the solution of the equation (the value of x expressed as T plus a small error term)
  • the total complexity score (again, described below πŸ‘‡)

Every single match gets checked by solving for x with the Newton-Raphson method, and how close the match is gets judged by the difference between the root (that's the value of x where the two sides are equal) and your target value T.

And then β€” the best part β€” the options let you have complete control over which symbols, constants and functions show up in your solutions, or let you limit solutions to integer, rational, constuctible, or algebraic values. obsessed. πŸ’–

πŸ”₯ OPTIONS πŸ”₯

okay so first rule of ries club: options must be separate. like ries -l1 -i -Ox 27, NOT ries -l1iOx 27. do not mash them together, she will not understand you. πŸ™ˆ

  • -pname β€” Profile (or Parameters): load one or more options from the file called name. -pname is literally equivalent to --include name, which is described down in the EXTENDED OPTIONS section. and -p all alone (no name after it) has ✨special meanings✨, also described under --include.
  • -ln β€” Level: sets the level of the search (default 2). every time you bump -l up by one, ries will search about 10 times as many equations, use 3.5 times as much memory, and take at least 4 times as long. use higher levels to add more factors of 10. the level can be fractional or negative, no judgment. here are the typical figures, measured on a Core i7 at 3.2 GHz (using only one thread) invoked by the command ries -ln 2.5063141592653589 for different values of searchlevel n:
                     memory    equations tested  digits    run time
                 -l0  1.2M           89,400,000    6+       0.025 sec
                 -l1  4.0M          932,000,000    7+       0.08 sec
                 -l2  14 M       11,400,000,000    8+       0.33 sec
                 -l3  45 M      134,000,000,000    9+       1.8 sec
                 -l4  158M    1,600,000,000,000   11+       8.8 sec
                 -l5  490M   15,000,000,000,000   12+      37.1 sec
                 -l6  1.7G  184,000,000,000,000   13+      190 sec

(these times are a little quicker than a 2.33-GHz Core 2 Duo; on a 733-MHz Pentium 3, the times were about 5 times longer. if compiled for an environment with 32-bit pointers, memory usage figures are about 20% lower. ries also works on much older and smaller systems, and can test billions of equations in less than a minute on 1990's hardware. we love a low-spec queen 🫢)

Use a fractional argument (like -l5.5) for more precise control of how much memory ries will use before stopping its search.

⚠️ When free memory is exhausted, performance will degrade significantly and ries might exit, depending on your operating system. Under Linux and Mac OS, ries keeps running but the system slows to a crawl. If you don't know what your OS will do, be careful before running ries with higher levels. In extreme cases your computer's response might slow down so much that you are unable to save your work in other applications. πŸ’€

The memory limits are not reached nearly as quickly when the symbolset is greatly limited with -S, -O and -N, or when -i is specified. -i in particular should allow about two more levels in any given amount of memory. Large arguments tend to lengthen runtime: for example, ries -l4 1058073667 takes about three times as long as ries -l4 1.058073667.


πŸŽ€ Options to Select Symbols πŸŽ€

Several options are used to choose which symbols (constants, operations, and functions) ries is allowed to use when searching for equations.

  • -Nsss β€” Never use these: -N followed by one or more characters specifies symbols (constants and operators) that ries should not use in its equations. The symbols are as follows:
    • 1-9 β€” The integers 1 through 9. (ries constructs all larger integers from combinations of these.)
    • p β€” pi = 3.14159...
    • e β€” e = 2.71828...
    • f β€” phi = (1+sqrt(5))/2 = 1.61803...
    • n β€” Negative
    • r β€” Reciprocal
    • s β€” Squared
    • q β€” Square root
    • S C β€” Sine, Cosine
    • T β€” Tangent
    • l β€” ln (natural logarithm, also called log)
    • E β€” e to the power of x
    • + - β€” Add, Subtract
    • * / β€” Multiply, Divide
    • ^ β€” Power: 2 ^ 3 = 8
    • v β€” Root (the β€œv” resembles part of the radical symbol): 3 v 27 = cube root of 27
    • L β€” Logarithm to base A of B
    • W β€” Lambert W function. Only available if using the stand-alone maths library, described in the section β€œSTAND-ALONE MATHS LIBRARY” below. In addition, one must explicitly choose it with -EW.

There are lots of potential uses for -N. For example, if you invoke ries on a small irrational number, you might get several solutions that involve the unary and binary logarithm operators 'ln' (natural logarithm) and 'log_' (log to base A of B). If you decide you aren't interested in such solutions you can just add -NlL to your command line, and all such solutions will be skipped. bye πŸ‘‹

If you are checking an unknown number that you found in the context of some larger problem, you probably have some idea what constants and operators may be involved, or not involved, in the phenomenon that produced your number. Use -N to rule out functions you don't think are relevant.

Note that ries will often run considerably slower when you limit it to a very small set of symbols, mainly because it cannot use its optimization rules (described below under ALGORITHM). Also, with fewer symbols the average length of expressions is longer, and that makes the search slower. 😭
  • -Ssss β€” permitted Symbol Set: Specifies a symbol set, as with -N, but has the opposite effect: only these symbols will be used. A -S also cancels any -E, -N or -O options that were given; meaning that if you wish to combine these options, the -S should come first. order matters bestie!!

-S can be used to solve those old problems of the sort β€œHow can the number 27 be expressed using only the four basic operators and the digit 4?” The answer is given by:

ries '-S4+-*/' 27 -Ox

(The -Ox option is described next). To solve the same problem using the -N option, you'd have to type:

ries -Npef12356789rsqlL^v 27 -Ox

If you give the -S option with no symbols, ries will display a table of all available symbols (as modified by any -E, -N, -O and -S options) with their definition and weights. This lone -S can be given along with a normal -S option, but in any case ries will exit after showing the table.

  • -Esss β€” Enable: Enables (or re-enables) the use of symbols that may have been disabled by an earlier -S or -N option. This is mainly intended for use in combination with the --include option. If one include file disables some symbols, this option can be used to re-enable some or all of them. It is also required for use of the Lambert W function, which is disabled by default. See β€œSTAND-ALONE MATHS LIBRARY” for instructions and use the option -EW to request use of the Lambert W function in a ries command.
  • -Osss β€” Only One: Specifies symbols which should appear no more than once on each side of the equation. This option can be combined with -E or -N, in which case they augment each other. If used with -S with the same symbol, the latter option takes effect.

One additional symbol is available with -O:

  • x β€” The variable on the left-hand-side

Thus, you can use -Ox to limit ries's output to equations that have only one 'x' in them and are therefore easy to solve for x using only the most basic algebra techniques. This also makes ries's output more like that of traditional expression-finders, which search for expressions equal to x rather than equations in x. Here's an example: ries -i 16 gives the answer β€œx^2 - x = 3^5” with x very close to 16, because 16^2-16 is close to 3^5. ries -i 16 -Ox replaces that answer with β€œ5 x^2 = 6^4”. glow up ✨

πŸŽ€ Options Limiting the Type of Solutions πŸŽ€

okay so this whole little family of flags? they're the vibe check for your equations. like, they decide what kind of expression is even allowed to show up in the solutions ries hands you. pick your fighter πŸ’–


  • -i β€” Integer ✨ bestie this one is strict: every expression and every subexpression has to have an integer value. it's giving "I need an exact solution for a big ol' integer" energy. heads up tho β€” inexact solutions can still show up, it's just that both sides of the equation will be integers. classic example: 2 x = 7^3, where x=173. 🫢 also, plot twist: if the target value you gave isn't an integer, -i just gets reinterpreted as -r (which is coming up right below, don't worry).
  • -ie β€” Integer, Exact πŸ’… it's -i but make it final. it exits the moment it reports an exact match (if it finds one, no promises). this is literally the same as -i combined with --min-match-distance 0. and if you don't want it reporting any inexact matches at all? that's --max-match-distance 0 (more on that below, iykyk).
  • -r β€” Rational πŸ¦‹ requires that all equations have a single x, and that all subexpressions not involving x are rational (aka an exact ratio of two integers). obsessed with this one for hunting rational approximations. fr fr it's basically shorthand for using the -N and -E options to allow only addition, subtraction, multiplication and division β€” so no irrational constants, no transcendental functions, none of that. ✨
  • -re β€” Rational, "Exact" πŸ’€ it's -r but it bails after reporting an "exact" match (if found). equivalent to -r combined with --min-match-distance 0.
okay so real talk: computers are (famously, iconically, tragically) unable to make exact calculations with fractions as simple as 1/3. so to exit on a match within some "epsilon", use --max-match-distance with a nonzero epsilon; to reject inexact matches use --max-match-distance (these options are described in detail below). 😭
  • -c β€” Constructible 🌸 requires that all equations have a single x, and that all subexpressions are "constructible" in the sense of Euclid's Elements, given a unit interval. it's like -r but extra: squares, square roots, and the golden ratio phi are allowed too. every result will be easily solvable for x and will use only addition, subtraction, multiplication, division, and square roots. ate. πŸ‘‘ if you add the option -Ex, more than one x may appear in the solution. this gives answers that, when solved for x, are not constructible from the unit interval β€” but both sides of the (unsolved) equation are constructible given x and a unit interval. for example:
ries 1.3263524026321 -c -Ex

finds the solution x x^2 = 7/3; x is the cube root of 7/3, which is not itself constructible. ries's answer reflects the fact that 7/3 can be constructed from its cube root (although the opposite construction is impossible). mind = blown 🀯

  • -a β€” Algebraic πŸ”₯ generate equations whose roots are "algebraic numbers". similar to -c, but it also allows n^th powers and roots. the trigonometric functions (sine, cosine, and tangent) are allowed, but their arguments will always be rational multiples of pi. more than one x is allowed (unless you follow -a with the option -Ox) so ngl the equations might not be easy to solve. πŸ™ˆ
  • -Ox β€” using the -O option (described above) with the symbol 'x' tells ries to limit its search to solutions that can be expressed in "closed form" using the basic constants, elementary and transcendental functions. this concept of "closed-form number" is described by Timothy Chow in his 1998 paper What is a closed-form number?. ⭐
  • -l β€” Liouvillian 🌈 generate equations whose roots are "Liouvillian numbers", as described by Timothy Chow in his 1998 paper What is a closed-form number?. periodt.

✨ Options Affecting Output Format ✨

  • -s β€” Sorta Solve, by Shifting to right-hand side. With this one, ries shows you equations with literally just one lil x sitting on the left-hand side of the equal sign. Bestie, it is not "solving" anything, it's just doing algebraic transformations to yeet everything that isn't that one x over to the right-hand side: x(x+1) = 7 becomes x = 7/(x+1). You can pair this with -Ox to make that issue go away, but then ries will no longer find solutions that need more than one x, like x^x = 2 for 1.55961.
  • -x β€” X Values: print the actual values of x (the roots of the equations it found) instead of expressing x as T plus/minus a small number, where T is your target number. --absolute-roots is a synonym for -x.
  • -Fn β€” Format: this controls how expressions get formatted in the main output. If n is left out it's 3 (so -F means "FORTH Format", periodt); and if you don't specify -F at all, the format will be 2. Here are all the formats you can pick, each showing the output of ries 1.506591651 -Fn:

Format 0: Compressed FORTH-like postfix format. Every operator and constant is just a single symbol, and those symbols are the ones listed above under the -N option.

x1- = 2r         for x = T - 0.00659165  {50}
xlr = 6q         for x = T - 0.00241106  {62}
x4^ = p2+        for x = T - 0.000766951 {68}
x1+s = p2*       for x = T + 3.66236e-05 {69}

Format 1: Infix format, but with single-letter symbols. If you pick this format, a table of symbols gets printed after the main table of results. The rest of the expression syntax is the same as the normal format. So like, q(l(x)) = p-1 means sqrt(ln(x)) = pi - 1.

    x-1 = 1/2        for x = T - 0.00659165  {50}
 1/l(x) = q(6)       for x = T - 0.00241106  {62}
    x^4 = 2+p        for x = T - 0.000766951 {68}
(x+1)^2 = 2.p        for x = T + 3.66236e-05 {69}

Format 2: Standard infix expression format (this is the default, the main character).

    x-1 = 1/2        for x = T - 0.00659165  {50}
1/ln(x) = sqrt(6)    for x = T - 0.00241106  {62}
    x^4 = 2+pi       for x = T - 0.000766951 {68}
(x+1)^2 = 2 pi       for x = T + 3.66236e-05 {69}

Format 3: Prints solutions in postfix format, similar to the one used in FORTH and on certain old pocket calculators. This is close to the format ries uses internally (if you want the exact, condensed format, use -F0). It's meant mainly for scripts that use ries as an engine to generate equations and then do further manipulation on them. That said, this option also helps you clock which symbols were actually used internally to generate an answer. For example, 'squared' and 'to the power of 2' both show up as '^2' in the normal output, but in postfix they appear as "dup*" and "2 **" respectively.

     x 1 - = 2 recip    for x = T - 0.00659165  {50}
x ln recip = 6 sqrt     for x = T - 0.00241106  {62}
    x 4 ** = pi 2 +     for x = T - 0.000766951 {68}
x 1 + dup* = pi 2 *     for x = T + 3.66236e-05 {69}

Most of the symbols -F3 uses are pretty self-explanatory, ngl. The nonobvious ones are: neg for negate, recip for reciprocal, dup* for square, sqrt for square root, ** for power (A^B), root for Bth root of A, logn for logarithm (to base B) of A. For those last three, A is the first operand pushed on the stack and B is the second.

The setting of -F does not affect expressions displayed by the various -D diagnostic options (most of these use -F0, and -Ds ("show your work") uses -F2).

You may use the --symbol-names option (described below) to redefine the appearance of formats 2 and 3.

  • -Dxx β€” Display Diagnostic/Debugging Data: this one assumes you have a detailed understanding of the ries algorithms (described below). -D is followed by one or more letters specifying which messages you want to see. Options A through L and a through l (except E and e) apply to the LHS and RHS respectively. For each option, the number of lines of output you can expect from a command like ries -l2 2.5063141592653589 -Dx (with x swapped for a single letter) is shown:
    • A, a β€” [42836; 87770] show partial expressions that are "pruned" (ignored) because of arithmetic error (e.g. divide by zero)
    • B, b β€” [3173; 2714] show partial expressions pruned for being zero, or derivative nearly zero; or outside range given by --min-equate-value and --max-equate-value
    • C, c β€” [81056; 697227] show partial expressions pruned for being non-integer (and the -i option was given); or irrational (and -r option given); etc. (sample command is ries -l2 1047 -i -DC )
    • D, d β€” [1751; 4350] show partial expressions pruned because of overflow
    • E, e β€” [102356; 272746] show expressions pruned because their value matches one already in database
    • F, f β€” [349368; 848882] show --canon-reduction operations on expressions before adding to database (sample command is ries -l2 2.50631415926 --canon-reduction nr25 -DF )
    • G, g β€” [96112; 97337] show expressions added to database
    • H, h β€” [409175; 816240] show attributes of each partial expression tested
    • I, i β€” [3904331; 7759741] show each new symbol to be added before complexity pruning
    • J, j β€” [2579116; 5102516] show symbols skipped by complexity pruning
    • K, k β€” [257302; 558199] show symbols skipped by redundancy and tautology rules
    • L, l β€” [61994; 114453] show symbols skipped to obey the -O option (sample command is ries -l2 2.50631415926 '-O-+/^v*qsrlLeEpf' -DL )
    • m β€” [10247603] show all metastack operations
    • M β€” [46] show memory allocation benchmarks, and enable automatic exit when memory gets slow (see --memory-abort-threshold option)
    • n β€” [136] show Newton iteration values and errors if any
    • N β€” [461] show work in detail: operator/symbol, x and dx at each step
    • o β€” [539235] show match checks
    • p β€” [112] show preprocessing transformations prior to conversion to infix
    • Q β€” [51] show manipulations to remove --canon-reduction from equations before root-finding
    • q β€” [140] show close matches dispatched to Newton and results of test
    • r β€” [1806085] show results (value and derivative of operands and result) for each opcode executed
    • S β€” [100] show solve-for-x work: displays all operations performed by the --try-solve-for-x option to transform an equation into "solved" form
    • s β€” [277] show your work: displays values of each subexpression for every reported answer. Subexpressions are shown in normal (infix) syntax, which is useful in combination with -F0 to see the postfix format used with options like --eval-expression
    • t β€” [11017] show all abc-forms passed to expression generation
    • u β€” [48895] show steps of min/max complexity ranging for each abc-form
    • v β€” [5525] show number of expressions generated by each abc-form
    • w β€” [32922] show details of abc-form generation (pruning, weights, etc.)
    • x β€” [91] show all rules used (varies with the -N, -O, and -S options)
    • y β€” [736] statistics and decisions made in main loop
    • z β€” [55] initialization and other uncategorized messages
    • 0 β€” [1712490] list the entire expression database after every pass through the main loop

Of all of these, -Ds is probably the most useful and fun to look at, fr. -Dy gives you a nice top-level view of the statistics of the search. Most of the options that generate tons of output are useful if you filter them through grep; that can tell you why a certain subexpression is or isn't showing up in results. -DG and -Dg can be useful if you want to use ries to generate a massive list of expressions for processing by another program; for this reason its output uses infix notation. Most other -D options print subexpressions in the -F0 terse postfix format.


πŸ¦‹ EXTENDED OPTIONS πŸ¦‹

Longer names get used for options that are thought to be less commonly wanted, or that are more likely to only ever show up inside --include files. πŸ’…

  • --include filename
  • -pfilename
  • -p β€” Load one or more options from file filename. The options --include filename and -pfilename are equivalent; note that one needs a space before filename and the other can't have a space (-p all by itself has a related function, described below). ries will try to open the named file (which may be a plain filename or a path), or the given name with .ries appended. If either one is found, ries will scan it for parameters and arguments separated by whitespace. Any control characters count as whitespace. Any # character that lands at the beginning of a line or right after blank space is a comment, and the rest of that line gets ignored. So for example, if there's a file hst.ries containing this:
# hst.ries:  High School Trigonometry settings
--trig-argument-scale 1.74532925199433e-2    # pi/180
-NLleEv      # No log, ln, e, e^x or arbitrary roots
-Ox      # Only allow one 'x' on the left-hand-side
-x      # Show equation roots as "x = 123.456"
        #            rather than "x = T + 1.23e-4"

so like, giving ries the option -phst is literally the same as giving it --trig-argument-scale 1.74532925199433e-2 -NLleEv -Ox -x β€” in that order, bestie, order is everything πŸ’…

And a parameter file can be extra and pull in another parameter file with the --include option. When ries hits that option, it applies everything in the included file, then goes right back to the rest of the first file. These can nest up to 25 levels deep (iconic stacking, honestly). But if a file ends up including itself, directly or indirectly? ries exits with an error. No infinite loop shenanigans here, we're not doing that 🚫

It's also an error for --include β€” or the end of an included file β€” to land between an option and its arguments. So ries 1.2345 --eval-expression --include expressions.txt throws an error no matter what's inside expressions.txt, because --eval-expression has to be followed immediately by its argument(s), no interruptions, no side quests.

But flip it around and it works! If expressions.txt contains the --eval-expression option itself, like so:

# expressions.txt:  Useful functions of one argument
--eval-expression
  xsr    # 1/(x^2)
  1xq-r  # 1/(1-sqrt(x))
  2xl1+^ # 2^(ln(x)+1)

then the command ries 1.2345 --include expressions.txt totally works and shows you the values of those three expressions where x is 1.2345. slay ✨

Now, the ✨profile✨ situation. If you've got a file called .ries_profile or ries_profile.txt sitting in your home directory, ries loads it automatically, as if you'd typed --include at the very beginning of your parameters. Main character behaviour. If you have one of those files and you do not want it used, give a bare -p (no filename, just vibes) at the very beginning of your ries options. And if you want some parameters first and the profile after? Toss in -p again at the exact point where you want ries to use the profile. πŸŽ€

For example: say your .ries_profile contains --trig-argument-scale 1, and you've got a hst.ries with the contents shown above. Then giving the options -phst -p uses all the settings in hst.ries except the --trig-argument-scale. Chef's kiss, exactly what you asked for 🫢

Two more example profiles you can go peek at: the Latin and Mathematica settings files, linked from the top of the main RIES webpage.


  • --absolute-roots β€” it's a synonym for the -x option, described above. same energy, different name πŸ’–
  • --algebraic-subexpressions β€” synonym for the -a option, described above.
  • --any-exponents β€” this one cancels any restrictions on subexpressions being used as an exponent β€” like the ones set by --algebraic-subexpressions and --liouvillian-subexpressions. free the exponents, honestly 🌈
  • --any-subexpressions β€” cancels any restrictions on subexpressions, as imposed by options like --algebraic-subexpressions. This is lowkey useful if you're using one of the class selectors like -a or -c as shorthand for all the restrictions of that class, and then you want to re-enable a function like e^x using -EE. πŸ¦‹
  • --any-trig-args β€” cancels any restrictions on subexpressions used as an argument to one of the trigonometric functions, such as those set by the --algebraic-subexpressions and --liouvillian-subexpressions options. trig girlies stay unbothered πŸ’…
  • --canon-reduction symbols β€” applies simple transformations trying to make all expression values fall in the range [1 ... 2). This improves the efficiency of the ries algorithm (described in the ALGORITHM section below) by upping the chances that two expressions form a match. Which means less memory and less time for any given amount of precision. efficient queen πŸ‘‘

This option should be followed by one or more symbols representing the operations ries will try to apply to expressions:

  • n β€” negate expressions when possible to make all values positive.
  • r β€” take the reciprocal when possible to make all expressions fall outside the range (-1 ... 1).
  • 2 β€” multiply by 2 when possible to increase the magnitude of expressions in the range (-1 ... 1).
  • 5 β€” divide by 2 (i.e. multiply by 0.5) when possible to decrease the magnitude of expressions that fall outside the range (-2 ... 2).

In those descriptions, the words when possible mean that --canon-reduction respects any limits imposed by the symbolset options -N, -O and -S. So if you use -On together with --canon-reduction n, the negation operator still only gets used once per expression. rules are rules 🚧

okay so heads up β€” even though this option makes ries more efficient, it also makes the printed results have greater complexity scores, and those complexity scores go up somewhat more erratically. 😭 ries will try to simplify its printed results by undoing --canon-reduction transformations on both sides of the equal sign. For example, ries 2.50618 --canon-reduction nr25 might give you the result x^x/2 = (1+9)/2, which simplifies to x^x = 1+9. But when only one side has a /2, ries can't fix it β€” so the same example gives an overly complex 1/(pi-x) = pi/2. not ideal, but that's the trade-off, bestie πŸ’€
  • --canon-simplify β€” when reporting a match, remove common factors or terms from both sides of the equation. This is the default. as it should be ✨
  • --constructible-subexpressions β€” synonym for the -c option, described above.
  • --derivative-margin value β€” sets the limit on how small the derivative of any expression or subexpression containing x can be in relation to the expression's value. Default is 10^-6, so an expression containing x gets rejected if its value is more than a million times its derivative. For really large target values this doesn't work, because the expression x (derivative of 1.0) would get rejected. So if the magnitude of your target is larger than 10^5, ries sets this limit correspondingly lower. For example, if your target value is 10^8, ries automatically sets a --derivative-margin value of 10^-9. automatic, she's thoughtful like that 🧚

If those defaults aren't your vibe, use this option to pick your own value. For example, in the command ries 12345 --derivative-margin 8e-5, derivatives of expressions can be as small as 8x10^-5 times the expression's value. In calculating any possible answers, ries would allow x^2 because the ratio between d/dx x^2 and x^2 is about 1.62e-4, big enough to surpass the margin. But any answers involving sqrt(x) get rejected, because the ratio between d/dx sqrt(x) and sqrt(x) is only 4.05e-5:

      expression   value    d/dx(expr.)  ratio
          x^2    152399025     24690    1.62e-4
           x       12345        1.0     8.1e-5
        sqrt(x)   111.108     0.0045    4.05e-5

Fr fr: the results of ries 12345 include the equation 2(sqrt(x)-9) = (2 e)^pi, but with the option --derivative-margin 8e-5 that answer is left out. bye πŸ‘‹

  • --explicit-multiply β€” always use the * symbol when displaying results, instead of the default behaviour of omitting * when multiplication can be implied by writing the multiplicands next to each other. This is useful if you need to copy ries output into a calculator, computer program or spreadsheet formula. copy-paste girlies, this one's for you πŸ’–
  • --integer-subexpressions β€” synonym for the -i option, described above.
  • --match-all-digits
  • --mad β€” request that all reported matches should match all of the supplied digits. This is equivalent to adding a 5 to the end of your target value, along with a --max-match-distance value equal to the magnitude of this appended 5 digit. It also selects the --x option, unless the --wide option is also given. all digits or nothing, periodt πŸ’…

For example, the command ries 2.5063 --mad is equivalent to ries 2.50635 --max-match-distance 0.00005 -x, and the first reported match is x^2+e = 9, which is true for x = 2.506335... Without --mad it reports 2 x = 5 and a few other answers that do not match all of the digits in 2.5063. see the difference? iconic πŸ”₯

  • --max-equate-value value
  • --min-equate-value value β€” specify the maximum and minimum values for the LHS and RHS of any reported equations. For example, the command ries 2.50618 would normally give 2 x = 5 as the first solution; both sides of that equation are about 5. But the command ries 2.50618 --max-equate-value 3 instead gives x-2 = 1/2 as the first answer β€” an equivalent solution, but expressed as an equation where both sides of the equal sign are less than 3. Similarly, ries 2.50618 --min-equate-value 27 gives the answer (e^x)^2 = e^5. ✨
  • --max-match-distance value β€” bestie, this one sets the maximum distance between your target value T and the roots x of any equations ries reports. It's basically your minimum-accuracy dial, and it overrides the default, which is 1% of the size of your target value. πŸ’…

So for example, the command ries 2.5063 uses a threshold that's 1% of 2.5063, which is about 0.025. Its first answer is the equation 2x = 5, whose root (solution) is 2.5. That differs from the target 2.5063 by 0.0063. But if you set an initial threshold of 0.001 with ries 2.5063 --max-match-distance 0.001, then 2x = 5 is not reported, because 0.0063 is bigger than your threshold 0.001. Instead the first match becomes `x^2 = 2 pi` (which lands within about 0.0003 of the target 2.5063). ✨

Use a zero argument to say ries should only report an "exact" match, if any. And heads up: that "exact" match might actually be more complex than the obvious answer, because of roundoff errors β€” go peek at UNEXPECTED BEHAVIOR and BUGS below. 🫢 Note that this is different from --min-match-distance 0, which prints inexact matches and stops after the "exact" match.

Use a negative argument to set a match threshold in proportion to your target value. For example, --max-match-distance -0.001 says the first match must be within 1 part in 1000 (or 1/10 of one percent) of the magnitude of the target.

If your --max-match-distance is so stringent that the first match takes longer than 2 seconds, ries will show progress messages until a match is found. Use --no-slow-messages to hush those. πŸ™ˆ

There's also a --min-match-distance option (described below), which serves an entirely different purpose. iykyk.

  • --max-matches N
  • -nN β€” limit the number of reported matches to a positive integer N. This is especially useful with options like --no-refinement that generate a lot of matches. The default N is 100. πŸ’―
  • --max-memory size β€” tells ries not to use more than the given amount of memory (size specified in bytes). This is especially useful combined with a high -l (search level) option. Like, if you typically have about 2 gigabytes of free memory on your machine, you could invoke ries with --max-memory 1.0e9, so it never uses more than 1 gigabyte of memory regardless of the search level. 🌸

ries also has an (experimental) feature that can automatically detect when your system is slowing down; see the --memory-abort-threshold option for details.

  • --max-trig-cycles value β€” sets the maximum and minimum values for arguments to the trigonometric functions, in multiples of one half-period. The default is 1.0, which corresponds to an allowed range of -pi to pi. The option --max-trig-cycles 4 would allow arguments from -4pi to 4pi. In combination with --trig-argument-scale, this argument is applied after the scaling, so the number of "cycles", "periods" or "waves" stays the same. For example, if the value pi/180 is used for --trig-argument-scale and --max-trig-cycles is set to 2, then the allowed range for arguments to the trigonometric functions is -360 to +360 (interpreted as being in units of degrees), which corresponds to two full cycles of the trig functions. 🌈
  • --memory-abort-threshold N β€” this option is used with the -DM option, and it overrides the default slowness measurement after which ries automatically exits. With -DM, ries measures how fast it's running compared to an estimate of how fast it "should" be running. If this ratio is greater than --memory-abort-threshold for more than 3 of the past 10 measurements, ries will exit. The default --memory-abort-threshold is 2.0. The value must be at least 1.0, and values less than about 1.5 are unlikely to be of much use. πŸ’€
NOTE: --memory-abort-threshold is an experimental ries feature and is likely to change in future versions of ries. Don't get too attached, bestie. 😭
  • --min-match-distance value β€” sets the minimum distance between your target value T and the roots x of any reported equations. This is useful for finding approximate formulas for constants that have a known, simple formula. For example, with the command ries 3.141592653589 -x --min-match-distance 1e-8 -NSCT you can discover these approximate formulas for pi:
                                  x-3 = 1/6            for x = 3.16666666666667
                                  x-3 = 1/7            for x = 3.14285714285714
                            ln(ln(x)) = 1/e^2          for x = 3.14219183392327
                                x^2+1 = 4 e            for x = 3.14215329254258
                                e^x+2 = 8 pi           for x = 3.14124898321672
                              x/phi^2 = 1/5+1          for x = 3.14164078649987
                               e^x-pi = 4*5            for x = 3.14163154625921
                            e^(x^2)+1 = e^(pi^2)       for x = 3.14158442136535
                                 pi-x = 1/e^(4^2)      for x = 3.14159254105462
                         sqrt(1+pi) x = e^3/pi         for x = 3.14159272240341
                              x^2/e^3 = 1/sqrt(1+pi)   for x = 3.1415926879966
                              9(x-pi) = 1/-(e^(4^2))   for x = 3.14159264108588

Among these results (after solving for x) are the ancient approximations 19/6 and 22/7, and the more modern curiosity e^pi = 20 + pi (which is called "Gelfond's constant"). Other interesting results can be found by omitting symbols with -N or by using restricted classes. For example, ries 3.1415926 -NSCTlLfEevp --min-match-distance 1e-8 (excluding most of the scientific functions) gives the fraction approximation 355/113 in the form `1/(x-3)-1 = 1/4^2+6`; and ries 3.1415926 -r --min-match-distance 1e-8 (requesting only rational approximations) gives 355/113 in the form `1/(x-3)-3 = 1/(4*4)+4`. πŸ”₯

You'll often get multiple equivalent results. In the example above, the equations sqrt(1+pi) x = e^3/pi and x^2/e^3 = 1/sqrt(1+pi) can both be converted into the approximate relation:

     pi = sqrt(sqrt(e^6/(pi+1)))

(which does not converge on the true value of pi if iterated).

If you give a value of 0 β€” --min-match-distance 0 β€” and ries finds an "exact" match, it will exit and report no further results. Note that this is different from --max-match-distance 0, which only prints the "exact" match and won't print any inexact matches.

There's also a --max-match-distance option (described above), which serves an entirely different purpose. ✨

  • --min-memory size β€” if ries is given the debug option -DM, it will try to measure the responsiveness of the system and automatically exit if it gets very slow. This is meant as an automatic safeguard against virtual memory "thrashing" that'll happen if ries is allowed to use all of your system's memory. (This feature is only active with the -DM option because it's still being tested. πŸ§ͺ)

When --min-memory is given in combination with -DM, it ensures ries doesn't exit because of slow memory response until at least size bytes of memory have been used. For example, if you know you always have about 1 gigabyte of free memory on your machine, and your machine often gets slow for other compute-intensive tasks, you could invoke ries with -DM --min-memory 1.0e9, and slow-system detection would be enabled but wouldn't trigger (if at all) until a gigabyte of memory has been used.

For more direct control over ries' memory usage, use the --max-memory option (without -DM) or use a suitably small -l search level. 🫢

  • --no-canon-simplify β€” when reporting a match, don't remove common factors or terms from both sides of the equation. This is mainly useful in combination with --max-equate-value and --min-equate-value. For example, the command ries -Ox 2.6905 would normally give the answer `x-2 = ln(2)`, in which both sides of the equation are about 0.693. Adding the options --no-canon-simplify and --min-equate-value 1 reports the same answer as `1/(x-2) = 1/ln(2)`, in which both sides of the equation are about 1.443. πŸ’…
  • --no-refinement β€” after reporting a match, don't require that the next match come closer to the target. This makes ries emit so many more matches than it normally would. πŸ‘‘ The matches won't be given in order of closeness, but they'll still be (roughly) ordered by increasing "complexity". Many will be equivalent to one another β€” for example, the command ries 1.51301 --no-refinement yields the solutions e^(x^2) = pi^2 and x/sqrt(2) = sqrt(ln(pi)), both with the root 1.513096088.... This option is most effective in combination with --max-matches, along with --match-all-digits or --max-match-distance (using a stricter argument than the default -0.01).
  • --no-slow-messages β€” suppress the "Still searching" messages that ries would normally print if a search takes longer than 2 seconds without giving any results. ✨
  • --no-solve-for-x β€” this option cancels the --try-solve-for-x option.
  • --numeric-anagram digits β€” give a specific set of digits that can be used as constants in a solution; this forces the --one-sided option. It'll use only as many of each digit as you specify. For example, if you give 111223 as the digits, ries will use up to three 1's, two 2's, and/or a single 3. This is meant to help solve certain puzzles of the "four fours" variety: πŸ“
  ries 17 -ie --numeric-anagram 4444
       x = 4*4+4/4               ('exact' match)       {92}

  ries 17 -ie --numeric-anagram 111223
       x = 2^(1+3)+1             ('exact' match)       {77}

  ries 12 --numeric-anagram 44s
       x = 4^2-4

  ries 12 --numeric-anagram 442
       x = 2*4+4

okay so --numeric-anagram can be used to set hard limits on the digits, the constants e, phi, and pi, and the "squared" and "reciprocal" symbols ✨. When you use --numeric-anagram, any of these symbols that you don't list will be forbidden just as if you'd used the -N option β€” no cap. The last two examples here show the use of s to specify the squaring operation x^2 as distinguished from any use of 2. iykyk πŸ’…


  • --one-sided β€” Force ries to ignore all LHS expressions except x 😀. This results in "one-sided equations" with x on the left-hand side. This makes ries much slower, but all of its output will be "solved for x".

This option is intended as a convenience for very special problems (for example, --numeric-anagram automatically turns on --one-sided), but it's not generally useful because the speed advantage of the normal RIES bidirectional search algorithm is lost πŸ’€. If you want ries to give answers that are solved for x, use the --try-solve-for-x option possibly along with -Ox.

If you use this option, ries will be a lot slower and its solutions for a given search level will not be nearly as accurate. Whereas a normal ries search might quickly match your target value to the first 10 decimal places, a search with the --one-sided option, taking the same amount of computation time, will only match the first 5 decimal places 😭. Sometimes this is acceptable, particularly when used with other options that restrict the search, such as -i, -N, -O, and -S.

  • --rational-exponents β€” Require any exponent to be a rational subexpression. For example sqrt(2) is allowed because it's 2 to the power of 1/2, but 2 to the power of sqrt(2) is not allowed because sqrt(2) is not rational πŸ™…. This option exists mainly to support the -a or --algebraic-subexpressions option (described above).
  • --rational-subexpressions β€” This is a synonym for the -r option, described above.
  • --rational-trig-args β€” Require any argument to a trigonometric function to be a rational subexpression 🧚. The restriction applies to the argument's value before multiplying by the --trig-argument-scale (if any). This option exists mainly to support the -a or --algebraic-subexpressions option (described above).
  • --relative-roots β€” When printing each equation, show the root as T plus/minus a small number (where T is your target number) rather than as the actual value of the root. This is the default, so you'll only need to use --relative-roots to cancel a -x or --absolute-roots option in your .ries_profile or another --include file.
  • --ries-arguments-end β€” This option signals the end of options and arguments; any that come after it will be ignored 🚫. If it occurs within a profile (described under the --include option above) ries will ignore the rest of the contents of that file and continue with the next option after the --include or -p option that invoked the profile.
  • --show-work β€” This is a synonym for the -Ds option, described in the -D (debugging/diagnostic) option above.
  • --significance-loss-margin digits β€” Specify the number of significant digits that may be lost in a calculation. By default, ries tolerates a loss of 2 digits in any calculation. For example, if x is 0.906402477... (the value of Gamma[5/4]), ries would not use x+e^5 in any of its expressions, because e^5 is more than 100 times as large as x. Due to round-off, more than 2 digits of the value of x would be lost in the addition. This restriction applies to constant expressions too, so ries also avoids 1+e^5 and 1+e^-5. Similar restrictions apply to any function that can cause precision to be lost (if evaluated at a point where the function's derivative is very low) 😬.

The normal ries behavior corresponds to a --significance-loss-margin option with an argument of 2.0. Give a higher value to allow more digits to be lost in calculations.

Conversely, if you suspect ries is generating meaningless results due to round-off error, you can look at its calculations in detail with the options -Ds and -F0, then evaluate specific expressions with --eval-expression (described below). If it seems appropriate, make ries more strict by giving --significance-loss-margin with a lesser argument πŸ”.

  • --symbol-names :sym:name [ :sym:name ... ] β€” This option lets you set the "names" of individual symbols πŸ’–. This affects how the expressions and equations are printed in any of the -F formatting modes, and by special commands such as --eval-expression. In addition to the symbols listed above in the -N option, you may also define these symbols:
    • ( ) β€” brackets to group sub-expressions
    • = β€” equality symbol

Here are examples of the normal ries output, modified by changing the appearance of the exponentiation operator and parentheses. The single-quotes around each option are to avoid substitution by the shell 🐚:

                 ries -l0 2.5063
                                  2 x = 5                      for x = T -
              0.0063      {49}
                                  8 x = e^3                    for x = T +
              0.00439212  {66}
                                  x^2 = 2 pi                   for x = T +
              0.000328275 {55}
                                  x^x = 1+9                    for x = T -
              0.000115854 {69}
                                x^2+e = 9                      for x = T +
              3.56063e-05 {63}
                              ln(6) x = sqrt(pi)+e             for x = T +
              2.73037e-05 {93}
                 ries -l0 2.5063 --symbol-names ':^:**' ':(:[' ':):]'
                                  2 x = 5                      for x = T -
              0.0063      {49}
                                  8 x = e**3                   for x = T +
              0.00439212  {66}
                                 x**2 = 2 pi                   for x = T +
              0.000328275 {55}
                                 x**x = 1+9                    for x = T -
              0.000115854 {69}
                               x**2+e = 9                      for x = T +
              3.56063e-05 {63}
                              ln[6] x = sqrt[pi]+e             for x = T +
              2.73037e-05 {93}

More examples of the use of --symbol-names are found in the "Latin" and "Mathematica" settings files linked from the top of the main RIES webpage.

  • --symbol-weights N:sym [ N:sym ... ] β€” This option lets you adjust the "weights", or complexity ratings, of individual symbols βš–οΈ. Use the option -S to see the normal weights, then use this option to change one or more. Compare these two examples; in the second one the cost of the symbol x is reduced, and the costs of 2 and s (squared) are increased:
                 ries -l0 2.5063
                                  2 x = 5                      for x = T -
              0.0063      {49}
                                  8 x = e^3                    for x = T +
              0.00439212  {66}
                                  x^2 = 2 pi                   for x = T +
              0.000328275 {55}
                                  x^x = 1+9                    for x = T -
              0.000115854 {69}
                                x^2+e = 9                      for x = T +
              3.56063e-05 {63}
                 ries -l0 2.5063 --symbol-weights 5:x 25:2 15:s
                            x sqrt(x) = 4                      for x = T +
              0.0135421   {39}
                                 -x-x = -5                     for x = T -
              0.0063      {46}
                                x/x^x = 1/4                    for x = T +
              0.00150933  {49}
                                x x^x = 5^2                    for x = T -
              0.00118185  {57}
                                  x^x = 1+9                    for x = T -
              0.000115854 {49}
                            x (1/x-x) = e-8                    for x = T +
              3.56063e-05 {71}

With the smaller weight of 5, x is considered "less expensive", and ries uses x more often in its answers; and with the number 2 and squaring more expensive, these show up less often in the results. In many cases the new results are equivalent, and ries has simply found a different way to get there πŸŒ€.

Since the arguments of --symbol-weights start with a digit, your target value will be treated as a symbol-weight specifier unless you place it somewhere else in the parameter list (as shown in the example), or use a single dash - to signal the end of the parameters.

NOTE: Changing the symbol weights can greatly reduce ries's efficiency, causing it to run for a very long time and giving little or no output 😡. If this happens, it usually can be fixed by using weights closer to the default values. You can also experiment with changing just one symbol-weight at a time to find which is causing the problem.
  • --trig-argument-scale value β€” Specify a constant by which the argument of the sine, cosine and tangent functions should be multiplied 🌈. By default this value is pi and the trig functions are called sinpi, cospi and tanpi. sinpi(x) is the sine of pi times x; so for example sinpi(1/3) is the sine of pi/3, which is half the square root of 3. A full circle is 2 in these units: sinpi(x) = -sinpi(x+1) = sinpi(x+2) for all x.

If you give this option, arguments will be multiplied by the number you give instead of by pi. Useful values to give are:

  • 6.2831853071795864769 β€” This is "tau" (2 pi); use it to get units of 1 per "full turn": sin(1/16) will give 0.382683...
  • 1 β€” Use 1 to get natural units (radians): sin(pi/8) will give 0.382683...
  • 1.74532925199432957692e-2 β€” This is pi/180, and is used for degrees: sin(22.5) will give 0.382683...
  • 1.57079632679489661923e-2 β€” This is pi/200, and is used for grads (gradians or gons): sin(25) will give 0.382683...

If you use this option, ries will call the functions sin, cos and tan in its output, and the scale will be displayed after the function definitions at the end πŸ‘‘.

  • --try-solve-for-x
  • -s, --try-solve-for-x β€” bestie this is literally equivalent to -s, which is described up in the OPTIONS section above. that's it, that's the option πŸ’…
  • --version β€” serves the whole ~vibe report~: info about the version of ries, the calculation precision and math library, any optional module(s), the currently enabled profile (peep the --include option at the beginning of the EXTENDED OPTIONS section above 🫢), plus a brief copyright notice. the version is a date, like 2013 Jun 3.
  • --wide-output β€” switches to a wider (132-column) output format ✨. this shows the roots of equations (values of x) both in terms of the actual value of x, and as T plus/minus a delta; it also shows the ratio between this delta and x as (1 part in N) where N is the delta divided by x. for example, if x is 2.5 and target value is 2.501, the delta is 0.001, which is 1 part in 2500. math is mathing πŸ”₯

πŸŽ€ SPECIAL COMMANDS πŸŽ€

okay so ries also provides some functions that supplement its main purpose. but listen up: commands and their parameters must be separate: ries 1.23 --trig-argument-scale 0.5, not ries 1.23 --trig-argument-scale 0.5. because the parameters are given separately, your target value might get interpreted as a parameter if you give it right after a special command 😭. to avoid this, use a single dash - to signal the end of the parameters. no cap, that dash is your bestie.

  • --eval-expression forth-expr [forth-expr ...] β€” evaluate one or more expressions, showing intermediate values, derivatives, and the complexity score of the full expression. the expression(s) should be given in the FORTH-like postfix syntax that is displayed when you use the -F0 option. the symbols are as listed above under the -N option. for example, xxq- is the syntax for x-sqrt(x). syntax errors and computation errors such as overflow are reported; however successful execution by --eval-expression does not guarantee that the expression will be found in an actial ries search πŸ‘€. for example, an expression containing x only appears as the left-hand-side of an equation if the x is the first symbol in the postfix form: ries will use x2+ (x+2) but will not use 2x+ (2+x).
  • --find-expression forth-expr [forth-expr ...] β€” perform the normal equation-finding search algorithm, and report specific expressions when they are found, along with their value, derivative, and complexity πŸ’–. the expression(s) should be given in the FORTH-like postfix syntax that is displayed when you use the -F0 option. the symbols are as listed above under the -N option. for example, xxq- is the syntax for x-sqrt(x). this command is useful for diagnostics; an example is given below in the UNEXPECTED BEHAVIOR section. iykyk 🧚

🌈 STAND-ALONE MATHS LIBRARY 🌈

the ries source code includes an auxiliary file, msal_math64.c, which can be downloaded from the same place as the main RIES source code and this manual. it provides some of the standard trignonmetric functions, whose implementation have been found to vary across different releases of the standard libm 🫠. this is useful if you are running ries on a variety of newer or older systems and want to be able to rely on consistent results. consistency is the moment, periodt ✨

msal_math64.c also provides the Lambert W function, defined to the symbol 'W'.

to use msal_math64.c, compile ries in the normal way but with the additional compiler option -DRIES_USE_SA_M64. the resulting ries binary will report mathlib: stand-alone when given the --version option.

once ries has been compiled with the stand-alone maths library, the Lambert W function is available by giving the option -EW on the ries command-line. its default weight is set to make it occur a little more often than the two-argument exponential and root functions; use the --symbol-weights option if you want to change this πŸ’…


πŸ‘‘ ALGORITHM πŸ‘‘

ries begins its search with small, simple equations and proceeds to longer, more complex ones. it uses a set of complexity rules to compute a measure (similar to Kolmogorov complexity), which determines the order in which various candidate expressions are considered by ries. for example:

  1. if you add a symbol to an equation, the result is more complex:
x + 1 = 3   is more complex than     x = 3

x + 1 = ln(3) is more complex than   x + 1 = 3

 x - 7 = 4^2  is more complex than   x - 7 = 4
  1. if two equations are the same except for one number, the equation with the higher number is more complex:
x + 1 = 5   is more complex than   x + 1 = 3

x^3 + 1 = 3  is more complex than  x^2 + 1 = 3
  1. if two equations are the same except for one symbol, the equation with the "more exotic" symbol is more complex:
x ^ 5 = 3   is more complex than   x + 5 = 3

as ries searches it finds solutions β€” these are equations for which x is close to being an exact answer 🎯. each time it finds a solution it prints it out. then ries raises its standard for the next answer: the next answer ries prints must be a closer match to your supplied value than all the answers it has given so far. (the only exception to this rule is an 'exact' match, one for which both sides match to within the limits of numerical precision. ries will print at most one of these, and will then continue to print more inexact solutions. sometimes the approximations are of greater interest than the exact match πŸ‘€)

instead of trying complete equations, ries actually constructs half-equations, called left-hand-side expressions and right-hand-side expressions, abbreviated LHS's and RHS's. it keeps a list of LHS's and a list of RHS's, and it keeps these lists in numerical order at all times ✨. this enables ries to find matches much faster. all LHS's contain x and all RHS's do not. thus, 1000 LHS's and 1000 RHS's make a total of 1000000 possible equations, and all 1000000 combinations can be quickly checked just by scanning through the two lists in numerical order. this is why ries is able to check billions of equations in such a short time. it's giving efficiency queen πŸ‘‘

the closeness of an LHS match depends on the value of x, and also on the derivative with respect to x of the LHS expression. because of this, ries calculates derivatives of LHS's as well as their values πŸ“

there are dozens of optimization rules ries uses, like the following:

  • a+ β€” don't try K + K for any constant K because K * 2 is equivalent.
  • b+ β€” don't try 3 + 4 (or any two unequal integers from 1 to 5) because another single integer (in this case 7) is shorter.
  • a* β€” don't try 1 * K for any constant K because K is shorter.
  • b* β€” don't try both 2 * 4 and 4 * 2 because they are equivalent.
  • c* β€” don't try K * K because K ^ 2 is shorter.
  • ar β€” don't try 1 / (1 / expr)) for any expression expr because expr is shorter.
  • a^ β€” don't try 2 ^ 2 or 2 squared because 4 is shorter.
  • b^ β€” don't try expr ^ 2 for any expression expr because expr squared is shorter.

there are over 50 rules like this, and together they make the search about 10 times faster πŸ”₯. however, if the symbol set is limited via -N, -O or -S, some of these rules cannot be used. for each optimization rule there are one or more symbolset exclude rules like the following:

Don't use rule a+ if either of the symbols '*' or '2' is disabled.

in order to maintain maximum efficiency, ries checks each rule individually against the symbolset, and uses as many rules as it can πŸ’…. you can see this process in action by trying a command like ries 1.4142135, which gives the answer x^2 = 2. if you disable the 's' (squared) and '^' (power) symbols with ries 1.4142135 -Ns^, rule b^ goes away, and the answer becomes x x = 2. if you also disable '*' (multiplication) the answer becomes x = sqrt(2). disable 'q' (square root) and you get log_2(x) = 1/2 (the logarithm to base 2 of x is 1/2). disable 'L' and it becomes x = 2,/2 (square root of 2, this time using the generalized root function). disable 'v' and you get x/(1/x) = 2. disabling '/', we get a trignometric identity involving pi/4; disabling the trig functions as well, the command becomes ries 1.4142135 '-Ns^q*Lv/SCT' and we finally get an answer that most people probably would not guess: x-1/(x+1) = 1 (note that the '/' in this answer is actually part of '1/', which is the reciprocal operator 'r') 🌸. throughout this progression the complexity score of the equation increases as the solution becomes more and more obscure, and simpler but poorly matching solutions like 1/cos(x) = 6 begin to appear 😭

πŸ’… UNEXPECTED BEHAVIOR πŸ’…

okay so sometimes ries will hand you a more complex equation before the (simpler) equation you were expecting. For example, tan(sqrt(2)) = sin(sqrt(2))/cos(sqrt(2)) is 6.334119167042..., so you might expect the command ries 6.334119167042 --trig-argument-scale 1 -NT to report something like cos(sqrt(2)) x = sin(sqrt(2)). Instead, ries gives sqrt(x^2+1) = 1/cos(sqrt(2)), which is equivalent by trigonometric identity, because it considers this equation to be more balanced (complexity score 45+38) than the other (which has a score of 48+29). Please read the preceding section ALGORITHM for more details. ✨

Adding or changing the symbolset with the -S, -O and -N options often causes unexpected changes in the output. For example, ries 2.2772 yields the solution 1/(x-2) = 2+phi but ries 2.2772 '-N*/T' does not give this solution in any form. This seems counterintuitive: there was no *, /, or tan() in the 1/(x-2) = 2+phi solution, so why did ries decide not to report it? 😭

In fact, the solution is still generated internally, but because you have told it to exclude some operators, ries has to try other, more exotic expressions sooner than it otherwise would. As it happens, the next solution x+1/e = sqrt(7) (which matches the target value 2.2772 more closely than 1/(x-2) = 2+phi) ends up getting found earlier. πŸ¦‹

The mysterious behavior results from the fact that ries always tries to keep the number of LHS and RHS expressions equal as it performs its search. Eliminating operators with the -N option means that more complex expressions must be generated to reach the quota. In this particular case, the symbolset restriction has a greater effect on the LHS than on the RHS, so as the search is progressing, LHS complexity grows a little more quickly than RHS complexity. The complexity of 1/(x-2) is 40, while the complexity of x+1/e is only a little more complex at 42. But the right-hand-side sqrt(7) is considered less complex (27) than 2+phi (35). Since both pieces of an equation need to be found before an equation can be reported, ries is able to locate both pieces of x+1/e = sqrt(7) sooner when the -N option is given. πŸ’‘

This is all made plain with the --find-expression option, giving the expressions 1/(x-2), 2+phi, x+1/e and sqrt(7) in postfix form, to reveal the order in which they are generated by the search algorithm:

           ries 2.2772 --find-expression x2-r f2+ xer+ 7q
            [7q] = 2.64575131106459, complexity = {27}
            [x2-r] = 3.60750360750361, d/dx = -13.0141, complexity = {40}
            [f2+] = 3.61803398874989, complexity = {35}
            [xer+] = 2.64507944117144, d/dx = 1, complexity = {42}

Then, repeating the same command with '-N*/T' shows that the [xer+] is generated before [f2+]. πŸ‘‘

In the case of two equivalent solutions (like the 6.334119167042... example earlier in this section), both equations come equally close to the supplied value, but only one can be found first. Once the first one is reported, the other is not, because ries only reports solutions that are at least a 0.1% closer match than the previously-reported solution. πŸ’…

The -l option is meant to give control over the number of solutions searched, but it actually controls the number of LHS and RHS expressions generated. Because two RHS's often have the same value, and only one (the first) gets kept, the number of solutions checked (which is the RHS count times the LHS count) depends on how often you get two LHS's or RHS's with the same value. This happens particularly often when the symbol set is severely restricted. If ries tried to compensate for this, the result would be that severely limited symbolsets would take a very long time to run and would generate really long equations. This is an important issue for those using ries to solve special problems, like the four fours problem exemplified by the command ries --numeric-anagram 4444 -Ox 17. The current implementation represents the author's attempt at a reasonable tradeoff. 🫢


πŸ› BUGS πŸ›

🚨 BUG ALERT 🚨

Performance does not degrade gracefully when the physical memory limit is hit, because expression nodes are allocated in sequential order in memory, without regard to where they will end up in the tree. This could be improved in the future with percentile demographics and a sort performed one time only, after the tree reaches a healthy (but not excessive) size. πŸ’€

Although it tries to avoid it, ries will often print more than one equivalent solution. It misses the fact that the multiple solutions are equivalent because of roundoff error. For example, ries '-S4+-*/' -Ox 17 gives x-4*4 = 4/4 and (4/(4-4*4)) x+4 = (4*4+4)/(4-4*4) (or a similar long form), only recognizing the first as an exact match (the more complex one involves divisions by multiples of 3, which require rounding). 😭

This problem is common when the target is already known very precisely by the user. For example, ries 0.00088953230706449 gives the (correct) answer ln(x)/pi = -sqrt(5), followed by redundant/equivalent answers such as ln(x)/pi-2 = -(phi^3) (if ries was compiled with regular precision) or sqrt(5),/x+4 = 1/e^pi+4 (if compiled with the -DRIES_WANT_LDBL option); but ries 0.000889532307 only gives the first, simplest form of the answer. 🌸

Related to this, ries sometimes gives an overly-complex answer, again because of roundoff error. For example, ries gets slightly different values for 2/3 and 1-1/3, and stores both of these in its database of RHS values. When reporting a solution in which both sides of the equation equal 2/3, it might give 1-1/3 for the right-hand side if it is closer to the (rounded) value of the left-hand side. πŸ™ˆ

This is particularly common if you request an exact match with a zero or very small --max-match-distance value, while giving an imprecise target value. For example, ries 1.9739208802178 --max-match-distance 0 might give cospi(1/(5 x)^2) = cospi(1/pi^4) whereas ries 1.9739208802178715 --max-match-distance 0 gives the expected 5 x = pi^2. However, I've only gotten complaints about this from users who give ries a problem to which they already know an answer. 😌

If you know that 1.9739208802178... is pi^2/5, then you don't really need ries to tell you that, do you? And if you're searching for things that approximate pi^2/5, such as sqrt(sqrt(e^2+1)+1) = 1.9739267..., you can use the --min-match-distance option. πŸŽ€

In deeper searches or with target values larger than 10^5, ries might occasionally report solutions that are actually tautologies empty in meaning. A typical example is x^(4/ln(sqrt(x))) = sqrt(e)^(4^2) (which is true for any value of x), but ries handles that case and most others like it. If you suspect the solutions it gives, use the -Ds option to show all calculations behind each proposed solution. The options --derivative-margin, --min-match-distance, and --significance-loss-margin may help avoid meaningless results. πŸ”₯

You can also use -Ox to force ries to use only a single x in each equation, which will prevent these tautologies entirely, but will also prevent the discovery of interesting solutions like x^x = 10. ✨


πŸ”€ ACRONYM πŸ”€

ries (pronounced reese or reeze) is an acronym for RILYBOT Inverse Equation Solver. The expansion of RILYBOT includes two more acronyms whose combined length is greater than 11. The full expansion of ries grows without limit and is well-defined but not primitive-recursive. Contact the author for more information. 🧚


πŸ‘‘ AUTHOR πŸ‘‘

Robert P. Munafo (contact information on mrob.com) πŸ’–


πŸ“œ LICENSES πŸ“œ

okay legal bestie moment, here's the actual license tea, word for word: 🫢

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
ries itself is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ries and this document are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
If you got ries.c from the website mrob.com, the GNU General Public License may be retrieved at mrob.com/ries/COPYING.txt and the GNU Free Documentation License may be found at mrob.com/ries/FDL-1.3.txt ; you may also find copies of both licenses at www.gnu.org/licenses/

πŸ’– That's the whole manual, bestie! Manual version: 2018 Aug 05 and this is RIES(1), periodt. 🫢✨