Skip to main content

uninum

A symbolic-numeric expression runtime for Python with EML lowering.

Build mathematical expressions as Python objects, then evaluate, differentiate, simplify, compile to fast callables, or lower to a universal representation where every expression becomes a tree of a single binary operator.

Based off of the work and research presented in the paper "All elementary functions from a single operator" - (Odrzywolek, 2026) https://arxiv.org/pdf/2603.21852

Features

  • Expression building with natural Python syntax (+, -, *, /, **) and standard math functions (sin, cos, exp, ln, sqrt, ...)
  • Symbolic differentiation with automatic chain rule, product rule, and all standard derivatives
  • Algebraic simplification via identity elimination, constant folding, and inverse cancellation
  • Compilation to fast callables with a numpy (vectorized) or pure-Python backend
  • EML lowering -- rewrite any expression to a tree of a single operator eml(x, y) = exp(x) - ln(y) plus the constant 1

Install

Requires Python >= 3.10.

python -m venv .venv
source .venv/bin/activate      # Linux/macOS
# .venv\Scripts\activate       # Windows

pip install .                  # core
pip install .[numpy]           # with numpy backend support
pip install .[dev]             # with pytest for running tests

Quickstart

from uninum import var, sin, ln, compile_expr

x = var("x")
y = var("y")

# Build an expression
expr = (x + y) * sin(x) / ln(y)
print(expr)                              # (x + y) * sin(x) / ln(y)

# Evaluate numerically
print(expr.evaluate(x=1.2, y=3.4))      # 3.503404...

# Differentiate and simplify
df = expr.diff(x).simplify()
print(df)

# Compile to a fast callable
fn = compile_expr(expr, backend="python")
print(fn(x=1.2, y=3.4))

# Lower to pure EML form
lowered = expr.to_eml()
print(lowered.evaluate(x=1.2, y=3.4))   # same result

API Overview

Category Name Description
Node types Expr Base class for all expression nodes
Const(value, name=None) Numeric constant
Var(name) Variable
UnaryOp(op, arg) Unary function application
BinOp(op, left, right) Binary operation
Constructors var(name) Create a variable
exp, ln, log Exponential and natural log (log is alias for ln)
sin, cos, tan Trigonometric functions
asin, acos, atan Inverse trigonometric functions
sinh, cosh, tanh Hyperbolic functions
sqrt Square root
eml(x, y) The EML operator: exp(x) - ln(y)
Constants e, pi, I Euler's number, pi, imaginary unit
Methods .evaluate(**kwargs) Numeric evaluation with variable bindings
.diff(wrt) Symbolic derivative (accepts Var or str)
.simplify() Algebraic simplification
.to_eml() Lower to pure EML representation
.to_latex() Render as LaTeX math string
Compilation compile_expr(expr, backend) Compile to callable; "numpy" or "python"
Rendering to_latex(expr) Convert expression to LaTeX

EML in 30 Seconds

The EML operator eml(x, y) = exp(x) - ln(y) is a single binary function that, combined with the constant 1, can express all elementary mathematics. This was shown by Odrzywolek (2024).

from uninum import var, sin, exp

x = var("x")
f = sin(x) + exp(x)

lowered = f.to_eml()                     # pure eml(S, S) tree with leaves = 1 or x
print(lowered.evaluate(x=1.0))           # matches f.evaluate(x=1.0)

The grammar of every lowered expression is simply S -> 1 | x | eml(S, S). See docs/eml_explained.md for the full theory.

Examples

Script What it covers
01_expressions.py Building expressions, evaluation, named constants
02_differentiation.py Symbolic derivatives, chain rule, numerical verification
03_simplification.py Simplification rules, capabilities, and limitations
04_compilation.py Python and numpy backends, vectorized evaluation
05_eml_lowering.py EML operator, lowering process, correctness verification
06_full_workflow.py End-to-end: build, diff, simplify, compile, lower

Documentation

Running Tests

pip install .[dev]
pytest tests/ -v

Metadata

Release files for uninum 0.2.0

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

Source distribution (sdist)

Source distribution for uninum 0.2.0
File Size Uploaded
uninum-0.2.0.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uninum 0.2.0
File Interpreter ABI Platform
uninum-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.3 kB

Release files / uninum-0.2.0.tar.gz

Download URL uninum-0.2.0.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6f378acbc4b7d5e6dac6e4c11339841535b9dad848cf6b20d20eb3e63c54f58a
BLAKE2b-256 checksum
How to use checksums
95ccf36635b8e5880119d92af967fb918ba51a7301408e21321dcdde17d25bb8
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 Apr 14, 2026.

Transparency log

Release files / uninum-0.2.0-py3-none-any.whl

Download URL uninum-0.2.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2f708e82af6fb4202b352db26f1b61d6979ffae3381f6d00deb0d6c6cb748ab
BLAKE2b-256 checksum
How to use checksums
d85dec3c0c01a14f5d6c4e72c4698bd34115e30b49b9dc2be15c3602a93bbb52
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 Apr 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

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