Skip to content

Ninhache/EML-Operator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EML Symbolic Regression Prototype

"All elementary functions from a single operator" Odrzywołek (2026) — arXiv:2603.21852

A single binary operator eml(x, y) = exp(x) − ln(y), together with the constant 1, generates every standard elementary function via the grammar

S → 1 | eml(S, S)

This prototype implements gradient-based symbolic regression over EML trees (the "master formula"), reproducing the exact recovery experiments from §4.3.

Quick start

python -m venv .venv
.venv/bin/pip install torch numpy
.venv/bin/python demo.py

Structure

Path Purpose
eml/core.py Scalar operator + closed-form constructions
eml/formula.py EMLMasterFormula — parameterised binary tree
eml/train.py Adam + entropy hardening + weight snapping
demo.py Verification, gradient SR, manual wiring

Visualization companion

Start the companion server, then open http://localhost:8765/ in a browser:

.venv/bin/python -m eml.viz_server   # terminal A
.venv/bin/python demo.py             # terminal B — trees appear live

The browser shows an SVG composition tree for every recovered formula. Use the expression + x input in the top bar to explore interactively:

Expression x f(x) What it is
eml(x, 1) 0 1 exp(0) = 1
eml(x, 1) 1 2.718 exp(1) = e
eml(1, eml(eml(1, x), 1)) 1 0 ln(1) = 0 exactly
eml(1, eml(eml(1, x), 1)) 2.718 1 ln(e) = 1 exactly
eml(1, eml(eml(1, x), 1)) 7.389 2 ln(e²) = 2 exactly
eml(eml(1, eml(eml(1,x),1)), 1) 5 5 exp(ln(x)) = x identity
eml(eml(1, eml(eml(1,x),1)), 1) 42 42 works for any x

Shape labels in the stats bar:

  • chain — depth = leaves; pure linear composition (e.g. ln(x): depth 4, leaves 4)
  • branching — some depth, more leaves; mixed
  • wide — leaves ≥ 2 × depth; balanced, short and broad

Key results

  • exp(x) recovered exactly (depth 1, 4 params) in every random restart.
  • ln(x) recovered exactly (depth 3, 34 params) in 9/10 perturbed restarts; post-snap MSE ≈ 1.5 × 10⁻³² (machine epsilon squared for complex128).
  • Manual wiring of eml(1, eml(eml(1,x), 1)) confirms exact symbolic identity.

About

PyTorch prototype for Odrzywołek (2026) | Symbolic regression using `eml(x,y) = exp(x) - ln(y)` as a universal binary operator for all elementary functions

Resources

License

Stars

Watchers

Forks

Contributors

Languages