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.0.tar.gz (748.4 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.0-cp311-abi3-win_amd64.whl (450.1 kB view details)

Uploaded CPython 3.11+Windows x86-64

simplipy-0.3.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.8 kB view details)

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

simplipy-0.3.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (564.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

simplipy-0.3.0-cp311-abi3-macosx_11_0_arm64.whl (528.5 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

simplipy-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl (541.9 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: simplipy-0.3.0.tar.gz
  • Upload date:
  • Size: 748.4 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.0.tar.gz
Algorithm Hash digest
SHA256 76775093032612cdca9786cac03234ca2a4e7f30b2b3e0f0b8a936cb85c7d18f
MD5 287c6052406be25d25e62f4de7c61e90
BLAKE2b-256 1163f7afb8a37b9a1e990a7ed36bc831f1509e8288be8a78cec2590641749f2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.0.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.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: simplipy-0.3.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 450.1 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.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2d0f8ab41603a5aeeb72b6900178d342fa1502a9f9e12487eae64034b50cdf21
MD5 c2c432cecd23c25bb6b564c394c71b2a
BLAKE2b-256 a5ca39a3d188b7e8baeaa495489ae8c39ea1e81b5eef0b55a0cee8d611a162f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.0-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.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 43fc757f6d983de14dfe5067f6e1f1e93b5a063a2def32c29f760e283d603e75
MD5 b391db37a6be96a94641a4dc824f2f43
BLAKE2b-256 ea5053430e465531bca1ed2e1ee160b2f14740fc9bb9f2eabe22e4e958614f10

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.0-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.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f77e4b79030fbff70c32b7bbb4e5a2264d2ea619a98cbcbcd66149920abbc8d
MD5 c3dd033b8999ceca71c8aa0f0da8910f
BLAKE2b-256 790ea0a74c2c9c4c312129a7423f5725d01a2bf5638c7d063aef7ca4d33f1887

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.0-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.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3bc07ff26fbe7b92bae96e5228ecf2d36c78521b60ec5f8334b62521999b71e6
MD5 d663da0654cb6e8550f3daa0b60c123e
BLAKE2b-256 8db2449bc05aaaf89b6a3a99434603deae8d7417058a0b3bf06a1e5d250650bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.0-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.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for simplipy-0.3.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0a0fc6a852d356c97731becd2acfda3361dbd987f3d10aae9d160ae317fa187d
MD5 f71078bfeaf7e4385b7ede973c5a05f2
BLAKE2b-256 fceeded4adf49a83a285d3b2b6dffbc59a4452746a7e07ab6b290401f751b808

See more details on using hashes here.

Provenance

The following attestation bundles were made for simplipy-0.3.0-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