https://github.com/sertdfyguhi/meth
A Python library to parse and evaluate mathematical equations.
https://github.com/sertdfyguhi/meth
equation interpreter math math-library mathematics parser python
Last synced: 24 days ago
JSON representation
A Python library to parse and evaluate mathematical equations.
- Host: GitHub
- URL: https://github.com/sertdfyguhi/meth
- Owner: sertdfyguhi
- License: gpl-3.0
- Created: 2023-04-28T03:50:11.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-29T06:45:13.000Z (over 2 years ago)
- Last Synced: 2025-12-27T01:40:52.134Z (about 1 month ago)
- Topics: equation, interpreter, math, math-library, mathematics, parser, python
- Language: Python
- Homepage: https://pypi.org/project/meth/
- Size: 113 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# meth: A mathematical expression parser.
A python package to parse and evaluate mathematical expressions.
# Installation
```sh
pip install meth
```
or install it from source:
```sh
git clone https://github.com/sertdfyguhi/meth/
cd meth
python3 -m build
pip install dist/*.whl
```
# Examples
> _More examples in the [examples/](https://github.com/sertdfyguhi/meth/tree/master/examples) directory._
```py
import meth
# tokenizing equations
meth.tokenize("5 + 2") # INT(5), PLUS, INT(2)
# parsing equations
meth.parse("2 * 10") # BinaryOpNode(INT(2), MUL, INT(10))
# evaluating equations
meth.evaluate("2 + 2") # 4
meth.evaluate("sqrt(9)") # 3
# evaluation with variables
evaluator = meth.Evaluator()
evaluator.evaluate("x = 5")
evaluator.evaluate("x") # 5
```
# Todo
- [x] Lexer
- [x] Parser
- [x] Bracketing
- [x] Multiplication using brackets
- [x] Negative Numbers
- [x] Variables
- [x] Functions
- [x] Interpreter
- [x] Binary Operations
- [x] Unary Operations
- [x] Variables
- [x] Functions
- [x] Add mathematical functions
- [ ] Accurate float calculations
- [ ] Simplify an expression
- [ ] Expand an expression
- [x] AST to Equation String
- [ ] Documentation
- [x] Publish to PyPI