Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I Rediscovered Kepler's Third Law on a Phone, in 204 Lines

Description and use

A 204‑line Python symbolic regression engine running on an Android phone rediscovered Kepler’s Third Law in 11 ms.

Problem

Most machine‑learning models are black boxes; for physics, biology, or finance one needs interpretable laws rather than predictions.

Outcome

The engine successfully rediscovered y=x*sin(x) and T=a^(3/2) (Kepler’s Third Law) from numeric data, achieving MSEs of 5.36e-33 and 4.77e-31 in 18 ms and 11 ms respectively, on an Android phone.

Workflow

  • Build a library of candidate forms for each input variable (x, x^2, x^3, 1/x, 1/x^2, sqrt(x), sin(x), cos(x), exp(-x), log(x)).
  • Generate all pairwise products of candidate forms, yielding ~55 forms.
  • Apply Orthogonal Matching Pursuit (OMP) in pure NumPy to select the smallest subset of columns that best reconstructs the target, testing k=1..6 and keeping the best MSE.
  • Combine selected terms into a SymPy expression and simplify to obtain the final symbolic formula.

Evidence

The engine rediscovered it, from raw numbers, in 11 milliseconds, on an Android phone.

Source

Two targets didn't work. Newton's law of gravitation (F = m1*m2/r^2): MSE 1.6. Reason: the library only generates pairwise products.

Source

pip install numpy sympy rich
python flash.py kepler

Source

  • Record date: 2026-10-04T12:41:04.699Z