Skip to main content

exp-minus-log — all elementary functions from a single operator

pip install exp-minus-log
from eml import eml, parse_rpn, evalf

A Python implementation of the EML (Exp-Minus-Log) operator from

A. Odrzywołek, All elementary functions from a single operator, arXiv:2603.21852, April 2026.

The paper shows that the binary operator

eml(x, y) = exp(x) - ln(y)

paired with the constant 1, suffices to construct every primitive of a scientific calculator: integers and fractions, the constants e, π, i, the four arithmetic operations, the trig / inverse-trig / hyperbolic / inverse-hyperbolic family, exponentiation and logarithms to arbitrary base, √, sigmoid, and so on.

This package gives that operator the full Python toolchain: an expression-tree compiler, a single-instruction stack machine, a sympy bridge, gradient-based symbolic regression, exhaustive search for shortest chains, mpmath verification at arbitrary precision, and a matplotlib renderer that draws each chain as the EML circuit symbol from the paper.

Quickstart

from eml import eml, parse_rpn

# Two canonical identities:
eml(1, 1)          # 2.718281828459045  (the constant e)
parse_rpn("11xE1EE")(x=7.5)
# 2.0149030205422647  (== math.log(7.5); the ln chain from Eq. (5))

Every Table-1 primitive is one call away:

from eml.library import build_unary, build_constant
build_unary("sin",  "x")(x=1.0)        # sin(1)  via EML
build_constant("pi")()                  # π       via EML  (K=233)

Verify the whole library at 40-digit mpmath precision:

python examples/07_verify_library.py
# ...
# 41/41 passed

Modules

module what it does
eml.core scalar / NumPy ufunc / mpmath implementations of eml, edl, −eml
eml.tree AST for the grammar S → 1 | eml(S, S), RPN round-trip, sympy bridge
eml.library every primitive of Table 1 expressed as a concrete EML chain (verified)
eml.sympy_eml a SymPy Function EmlFn, with auto-eval, fdiff, evalf, rewrite
eml.vm single-instruction stack VM (compile / disassemble / trace / bytestream)
eml.search brute-force shortest-EML search (the Direct search column of Table 4)
eml.regression the level-n master formula (5·2ⁿ − 6 simplex parameters), Adam, snap-to-vertex
eml.verify Schanuel-witness verification (γ, A) at arbitrary mpmath precision
eml.viz ASCII tree + matplotlib EML-circuit renderer (Fig. 2)
eml.cousins EDL (exp/ln, paired with e) and −eml(y,x) (ln−exp, paired with −∞)

Examples

PYTHONPATH=. python examples/01_canonical_identities.py   # ln, exp, e, 0
PYTHONPATH=. python examples/02_compile_function.py       # build any primitive
PYTHONPATH=. python examples/03_visualise.py              # render Fig.-2-style trees
PYTHONPATH=. python examples/04_vm_bytecode.py            # run on the EML stack VM
PYTHONPATH=. python examples/05_search.py                 # find shortest chains
PYTHONPATH=. python examples/06_symbolic_regression.py    # recover exp(x) from data
PYTHONPATH=. python examples/07_verify_library.py         # verify all 41 primitives
PYTHONPATH=. python examples/08_sympy_calculus.py         # symbolic diff/simplify
PYTHONPATH=. python examples/09_cousins.py                # EDL and −EML in action

Tests

PYTHONPATH=. python -m pytest tests/
# 77 passed

Notes on numerical edge cases

EML chains intentionally route through ln(0) = −∞ and exp(−∞) = 0 when constructing the constant 0, the negation function −x, and a few of their dependents (cf. Table 4 column "without extended reals"). NumPy honours this via signed zeros and infinities, so the chains "just work" in IEEE-754; the core.eml implementation suppresses the benign divide-by-zero RuntimeWarning that the principal log(0) raises.

The principal-branch convention means the chain that the paper writes for i lands on −i — see §4.1 ("manually correct i sign"). The helper eml.core.fix_i_sign performs that one-line correction.

Why complex numbers?

The paper requires it (page 5):

"Computations must be done in the complex domain, e.g. generating constants like i and π requires evaluating ln(−1), so eml(x, y) internally operates over ℂ using the principal branch."

A real-only EML cannot:

  • generate i, π, −1, sin x, cos x, tan x, ... — every chain for these routes through ln(z) for some z < 0;
  • even compute ln 0 = −∞ portably (some platforms trap it).

So eml.core.eml always promotes to complex128 internally. When the inputs are real and the output is real (within numerical noise), the return value is silently demoted back to float64 so the API still feels "real" to the user. If you want explicit numpy floats end-to-end, restrict yourself to chains that don't pass through any negative-real log argument (essentially: +, *, exp, ln of positives) and unwrap with .real after each call.

Precision: bit-exact agreement with math.*

The natural floating-point evaluation of an EML chain accumulates ~0.5 ULP per node, so e.g. build_constant("pi")() lands ~2 ULPs away from math.pi. Most users don't need bit-exact, but if you do:

from eml.core import evalf
from eml.library import build_constant, build_unary
import math

evalf(build_constant("pi"), real=True) == math.pi          # True
evalf(build_unary("sin", "x"), {"x": 1.0}, real=True) == math.sin(1.0)   # True
evalf(build_unary("ln",  "x"), {"x": 2.0}, real=True) == math.log(2.0)   # True

evalf evaluates the chain at 30-digit mpmath precision and rounds once to complex128. Any chain that fits in 30 digits is then correctly rounded — no ULP slippage from intermediate evaluations.

"Should I just hard-code math.pi as a leaf?"

No. That would defeat the entire point of a single-operator system. The interesting fact about EML is that π = ln(−1)/i as an EML expression — exposing it as a leaf would erase that. Use evalf if you need bit-exact agreement; use the natural numpy path if you don't care about the last bit.

Use cases

See USECASES.md for fifteen concrete and speculative applications of the EML operator, grouped by maturity and pointing at the relevant module / example for each.

Metadata

Release files for exp-minus-log 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exp-minus-log 0.1.1
File Size Uploaded
exp_minus_log-0.1.1.tar.gz 42.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for exp-minus-log 0.1.1
File Interpreter ABI Platform
exp_minus_log-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 77.8 kB

Release files / exp_minus_log-0.1.1.tar.gz

Download URL exp_minus_log-0.1.1.tar.gz
Size 42.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cf9d7ccd4914a1dfe03e3a60d98074cff728e6036a3a6dc1b2858dcf71adc74a
BLAKE2b-256 checksum
How to use checksums
028b8f562b15c52d8dbbf23e5e38a7df1079ca7059227f92f7adbd308ca8261f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

Release files / exp_minus_log-0.1.1-py3-none-any.whl

Download URL exp_minus_log-0.1.1-py3-none-any.whl
Size 35.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58d5ba37a2663c4ebf9438f424e0a8b9d19eb6c3b8475faded1a54ba1545e930
BLAKE2b-256 checksum
How to use checksums
355b5abbcf1b27b33bb19b92174e26a492de7b40b798503a65eb4ad8d9649235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page