Efficient Simplification of Mathematical Expressions
Project description
SimpliPy:
Efficient Simplification of Mathematical Expressions
Usage
pip install simplipy
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 efficacy and efficiency for different maximum pattern lengths (Engine:
dev_7-3). Original expressions sampled with the Lample-Charton Algorithm using the following parameters:
- 0 to 3 variables
- 0 to 20 operators (corresponding to lengths of 0 to 41)
- Operators:
- with relative weight 10:
+,-,*,/- with relative weight 1:
abs,inv,neg,pow2,pow3,pow4,pow5,pow1_2,pow1_3,pow1_4,pow1_5,sin,cos,tan,asin,acos,atan,exp,log,mult2,mult3,mult4,mult5,div2,div3,div4,div5Points show bootstrapped mean and 95% confidence interval (N = 10,000). Orange points are within the 95% confidence interval of the shortest simplified length for the respective original length. Using patterns beyond a length of 4 tokens does not yield significant improvements and comes at a cost of increased simplification time.
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
@software{simplipy-2025,
author = {Paul Saegert},
title = {Efficient Simplification of Mathematical Expressions},
year = 2025,
publisher = {GitHub},
version = {0.2.12},
url = {https://github.com/psaegert/simplipy}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simplipy-0.2.12.tar.gz.
File metadata
- Download URL: simplipy-0.2.12.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
731605aeb3bf3d42d65ce5c5a8456573fdd7eb9cca586dae78de48723e29d5aa
|
|
| MD5 |
181462f15fd5e9867f4868e9862a3c4d
|
|
| BLAKE2b-256 |
df5c6eef1263f18ca7d41a43a9e2a687b34ca409b6818fe06058a769f136c999
|
Provenance
The following attestation bundles were made for simplipy-0.2.12.tar.gz:
Publisher:
publish.yml on psaegert/simplipy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simplipy-0.2.12.tar.gz -
Subject digest:
731605aeb3bf3d42d65ce5c5a8456573fdd7eb9cca586dae78de48723e29d5aa - Sigstore transparency entry: 732637110
- Sigstore integration time:
-
Permalink:
psaegert/simplipy@3a55402e52d5c1b447a43a4518bae8c76d4a5eb4 -
Branch / Tag:
refs/tags/v0.2.12-hotfix-1 - Owner: https://github.com/psaegert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a55402e52d5c1b447a43a4518bae8c76d4a5eb4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file simplipy-0.2.12-py3-none-any.whl.
File metadata
- Download URL: simplipy-0.2.12-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
837193b13af0b5c160a5d7cec560129e50b07f93dd27b4836d9725fd20ea292d
|
|
| MD5 |
19985829510a6a18ff0bcb52fd92d816
|
|
| BLAKE2b-256 |
58bb286b91c2ce5d55cdc8bddaa5aae2c5aa90bbde6c3c01701e3d99cfe61d9c
|
Provenance
The following attestation bundles were made for simplipy-0.2.12-py3-none-any.whl:
Publisher:
publish.yml on psaegert/simplipy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simplipy-0.2.12-py3-none-any.whl -
Subject digest:
837193b13af0b5c160a5d7cec560129e50b07f93dd27b4836d9725fd20ea292d - Sigstore transparency entry: 732637112
- Sigstore integration time:
-
Permalink:
psaegert/simplipy@3a55402e52d5c1b447a43a4518bae8c76d4a5eb4 -
Branch / Tag:
refs/tags/v0.2.12-hotfix-1 - Owner: https://github.com/psaegert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a55402e52d5c1b447a43a4518bae8c76d4a5eb4 -
Trigger Event:
release
-
Statement type: