Skip to main content

Efficient Simplification of Mathematical Expressions

Project description

SimpliPy:
Efficient Simplification of Mathematical Expressions

PyPI version PyPI license Documentation Status

pytest quality checks CodeQL Advanced

Publications

  • Saegert & Köthe 2026, Breaking the Simplification Bottleneck in Amortized Neural Symbolic Regression (preprint, under review) https://arxiv.org/abs/2602.08885

Usage

pip install simplipy

As of 0.3.0 the inline phase (simplify, conversions, validation) is a compiled Rust extension (simplipy._core). Prebuilt wheels are published for Linux (x86_64/aarch64), macOS (x86_64/arm64) and Windows (x64) on CPython ≥ 3.11, so pip install simplipy does not compile anything for most users. Installing from the source distribution (an unsupported platform, or --no-binary) requires a Rust toolchain (rustup, MSRV 1.83). If the extension is unavailable at runtime, the package transparently falls back to a slower pure-Python implementation.

import simplipy as sp

engine = sp.SimpliPyEngine.load("dev_7-3", install=True)

# Simplify prefix expressions
engine.simplify(('/', '<constant>', '*', '/', '*', 'x3', '<constant>', 'x3', 'log', 'x3'))
# > ('/', '<constant>', 'log', 'x3')

# Simplify infix expressions
engine.simplify('x3 * sin(<constant> + 1) / (x3 * x3)')
# > '<constant> / x3'

More examples can be found in the documentation.

Performance

Simplification time and ratio ECDFs: SymPy vs SimpliPy (Python 0.2.15) vs SimpliPy (Rust 0.3.0)

Top row: SimpliPy 0.3.0 (Rust inline engine, green). Bottom row: SimpliPy 0.2.15 (pure Python, blue). Left: Empirical Cumulative Distribution Functions (ECDFs) of simplification wall-clock time across maximum pattern lengths Lmax = 0–7, with the SymPy [Meurer et al. 2017] baseline (orange, red). The Rust inline engine is roughly 5× to 100× faster than the pure-Python engine at the same Lmax (≈ 15× at Lmax = 4), and both are orders of magnitude faster than SymPy. Right: ECDF of the simplification ratio |τ ∗|/|τ | (inset: zoom on the low-ratio region where the Lmax curves separate); the Rust and Python engines produce near-identical simplification-ratio distributions, so the Rust rewrite buys the speed-up without sacrificing simplification quality. (0.3.0 does deliberately change behaviour on a small fraction of inputs via the conversion-quirk fixes and numeric folding; see the CHANGELOG.)
Source expressions are sampled with 0 to 17 unique variables and 1 to 35 symbols [Saegert & Köthe 2026]

Development

Setup

To set up the development environment, run the following commands:

pip install -e .[dev]
pre-commit install

Tests

Test the package with pytest:

pytest tests --cov src --cov-report html

or to skip integration tests,

pytest tests --cov src --cov-report html -m "not integration"

Citation

@misc{saegert2026breakingsimplificationbottleneckamortized,
  title   = {Breaking the Simplification Bottleneck in Amortized Neural Symbolic Regression},
  author  = {Paul Saegert and Ullrich Köthe},
  year    = {2026},
  eprint  = {2602.08885},
  archivePrefix =  {arXiv},
  primaryClass  = {cs.LG},
  url     = {https://arxiv.org/abs/2602.08885},
}

% Optionally
@software{simplipy-2025,
    author = {Paul Saegert},
    title = {Efficient Simplification of Mathematical Expressions},
    year = 2025,
    publisher = {GitHub},
    version = {0.3.0},
    url = {https://github.com/psaegert/simplipy}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplipy-0.3.1.tar.gz (750.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

simplipy-0.3.1-cp311-abi3-win_amd64.whl (451.5 kB view details)

Uploaded CPython 3.11+Windows x86-64

simplipy-0.3.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (578.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

simplipy-0.3.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (566.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

simplipy-0.3.1-cp311-abi3-macosx_11_0_arm64.whl (529.9 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

simplipy-0.3.1-cp311-abi3-macosx_10_12_x86_64.whl (543.7 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file simplipy-0.3.1.tar.gz.

File metadata

  • Download URL: simplipy-0.3.1.tar.gz
  • Upload date:
  • Size: 750.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simplipy-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a269385af0c110d9ef073cfdea56459c9ecd8f18d2f0538a7ae7663f9f07c71e
MD5 642e2397af2af2c35fd615bf46d46e7d
BLAKE2b-256 5f260d12f2f62508d9e96ada6b18b11e7104f2ca178d5fcce8105b7c59331bda

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.1.tar.gz:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.3.1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: simplipy-0.3.1-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 451.5 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for simplipy-0.3.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3ba6526827012c41e2c83354bb041122c32535800c09ba462673f182ec205389
MD5 a430ba72af3a5d3cb0cee9373e9dc51b
BLAKE2b-256 f85dc936901a935d9425a17db1ae22718d7c576d7134112fce34544b52a61a35

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.1-cp311-abi3-win_amd64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.3.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8e99887e2eb51d81091474864d4322c244dd66d63f4cda30fae89e976ccf29e
MD5 6a66382c35121bfea13ccc2fb2be183d
BLAKE2b-256 784bc698357de5ffdaf78b7477b50c8401910e653b636a834d54908c6959e468

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.3.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 da4315df469536d3587cc4b35121330e4cbe2ea967075e34932d2386ac9f0064
MD5 37969af59aa0e3e359568aa82598ccb0
BLAKE2b-256 dfee0e66c3d3749942e50e914aa62af65bb36735900928da426de1710006ba38

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.3.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24a2b49f99ea7e9244a4c814fb05271616b3d5e7024fd5cd619481eb570852f8
MD5 da98f0edc8e2311126211ebc74afaadc
BLAKE2b-256 45141d60a1a64b5ce6d7a46dd8fef64cbe78ff8586ed1ee72bcb588ee04d1f1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.1-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simplipy-0.3.1-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 053079766207e208d5a1aabf191665cf34d6904acf40d85c161d2b33584b47f6
MD5 cbaf8746ec40b93f633d14d95efa8a4d
BLAKE2b-256 448ee97002e541882780728202f3007330ab00e04b26b39530f6cfe0a81f3a29

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.1-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: publish.yml on psaegert/simplipy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page