Method notes

Inverse search with a scientific RPN calculator

The calculator reverses the usual numerical workflow. Instead of entering a formula and obtaining a number, one enters a numerical target, a list of independent targets, or a table of x,y observations—and searches for short calculator programs that reproduce the selected data.

Workflow

Use the tool the way one uses a numerical experiment: record the input, the assumptions, the search parameters, and the candidate expression. The result is not a proof.

  1. 1

    Choose the recognition task

    The opening wizard selects one numerical target, a batch of independent targets, or one function fitted to x,y observations.

  2. 2

    Enter data and uncertainty

    Use values produced by calculations or measurements. Give dz per numerical target or dy per function observation when the data are approximate.

  3. 3

    Set maximum code length K

    K bounds the length of the RPN button sequence. Each additional step increases the search space roughly by the calculator alphabet size.

  4. 4

    Verify candidates outside the search

    A returned expression is a numerical lead. Recompute at higher precision or prove the identity from the original mathematical problem.

RPN model

The search space is defined by a standard scientific RPN calculator. Button sequences are encoded as integer codes, then evaluated one after another. The original browser version describes this as a virtual calculator whose buttons are pressed sequentially by CPUs rather than randomly by people.

Consequence for runtime

K always counts RPN tokens; it is not a constant count, operation count, or thread count. For an active alphabet with T terminals, U unary functions, and B binary operators, the implementation counts stack-valid programs exactly. A valid structure with t terminal, u unary, and b binary positions contributes T^t U^u B^b candidates. Parallel CPU workers and WebGPU divide this same set without changing K or its cardinality.

For cross-calculator reporting, the fixed-width information cost is I_K = K log2(T+U+B) bits. Dataset size is separate again: a batch or fitted function evaluates each candidate against every target or observation. The calculator now reports all of these quantities before the search starts.

Recognition modes

The wizard fixes the input contract, available terminals, engine call, and result report before a search starts. The selected calculator buttons define the constants, unary functions, and binary operators in every mode.

ModeInputTerminalsExecutionReport
One constantz and global dzselected constants; x disabledone CPU/WASM or GPU searchranked candidates
Multiple constantsone z[,dz] per rowselected constants; x disabledshared CPU batch or verified GPU searchesone best result per target_id
Function f(x)one x,y[,dy] per rowx enabled; constants optionalone CPU/WASM or GPU fit searchformula and weighted MSE

Multiple-constant recognition

Enter at least two rows as zor z, dz. CPU/WASM enumerates each expression once and compares its value with every unfinished target. The report preserves the input-row identity and retains a separately verified best expression for every target.

CPU and GPU contract

  • CPU mode uses the native MODE_BATCH implementation.
  • GPU mode processes targets separately with the same selected calculator.
  • Every GPU candidate is recomputed in CPU double precision before reporting.
  • The UI distinguishes accepted matches, best approximations, and missing results.

Univariate function recognition

In Identify f(x) mode, enter one row per observation as x, yor x, y, dy. Every candidate must contain x and is evaluated against every row. CPU/WASM uses double precision; GPU candidates are screened in FP32 and then recomputed on the CPU before they are reported.

Acceptance contract

  • At least two finite data points are required.
  • dy is optional, but cannot be negative.
  • Residuals are divided by dy when dy is greater than zero.
  • A strict fit is accepted when weighted MSE is at most 10^-12.

Notation and ranking

Candidate formulas should be judged by both numerical accuracy and complexity. Long formulas can fit many decimal inputs by accident.

SymbolMeaning
ztarget numerical value
Delta zabsolute uncertainty of the input value
delta zrelative uncertainty Delta z / z
Klength of the RPN code being searched
T, U, Bcounts of terminals, unary functions, and binary operators in the active calculator
I_Kfixed-width description length K log2(T+U+B), used to compare calculator alphabets
RPNreverse Polish notation button sequence
CRcompression-style ranking signal balancing error and length
x, yinput and observed output for univariate function recognition
target_idstable input-row identifier in a multiple-constant report
dyoptional non-negative uncertainty used to scale a function residual
MSEmean squared residual; with dy, mean of ((f(x)-y)/dy)^2

Scientific examples

These examples are checks for numerical work and teaching: each one shows what was entered, what candidate was found, and what still has to be verified.

High-precision numerical calculation

z = 0.51404189589007076139762973957688candidate = 5*pi^2/96

A typical use case: a numerical integral or algebraic manipulation returns a decimal and the recognizer proposes a compact form.

Rational recognition

z = 0.22222222222candidate = 2/9

Useful for teaching why decimal representations can hide very simple exact values.

Exercise generation

z = 0.846153846153846candidate = tanh(log(sqrt(12))) = 11/13

An example of an identity that is not obvious from the decimal representation and can become a problem for students.

Recreational integer identity

z = 2026candidate = 1 + (9*5)^2

Integer and date-like inputs are not scientific evidence by themselves, but they are useful demonstrations of the search space.

Limitations

Constant recognition is exploratory. A very close numerical match can still be meaningless if the expression is too long, if the input precision is overstated, or if the expression has no connection with the original problem.

Minimum reporting checklist

  • Target value and number of significant digits.
  • Assumed Delta z or statement that the search was exact.
  • Maximum K and selected calculator/domain.
  • Candidate expression and independent verification method.
  • For f(x): all x,y[,dy] rows and the weighted MSE.
  • For a batch: all z[,dz] rows and each target_id result.

Citation and attribution

If the tool contributes to a publication, cite the repository or deployed version and include the search parameters needed to reproduce the candidate.

The stopping and compression criteria follow Andrzej Odrzywolek, Criteria for the numerical constant recognition.

Constant Recognition, A. Odrzywolek and K. Sroka.
Inverse RPN calculator for numerical constant recognition.
https://github.com/Klaudiusz321/ConstantRecognition1