A compact Python utility that parses mathematical equations written in LaTeX, solves them both symbolically and numerically, and returns a step‑by‑step solution in LaTeX format.
- Supports single equations and systems of equations.
- Symbolic simplification, solving, and numeric approximation.
- Full LaTeX output (original input, simplified form, symbolic solution, numeric approximation).
- Command‑line interface (
main.py) and importable engine (engine.py). - Powered by SymPy – no external mathematics engines required.
-
Clone the repository (or copy the files into your project):
git clone https://github.com/alexkolesnikov08/Math cd Math -
Install the required dependencies for the interpreter you plan to use. The project provides a
requirements.txtthat fixes the versions required by the LaTeX parser (sympy≥1.12andantlr4-python3-runtime==4.11).# Homebrew‑installed Python 3.11 on macOS /opt/homebrew/bin/python3.11 -m pip install --upgrade pip /opt/homebrew/bin/python3.11 -m pip install -r requirements.txtIf you prefer an isolated environment, create a virtualenv with the same interpreter and install from
requirements.txtinside it. -
Make the CLI executable (optional).
main.pynow starts with a shebang that points to the interpreter above, so you can run it directly:chmod +x main.py ./main.py "x^2 - 5x + 6 = 0"The code works with Python 3.10+ but the shebang guarantees it runs with the interpreter you installed the dependencies for.
Run the solver directly via the module entry point:
# Pass the equation as an argument
python -m Math.main "x^2 - 5x + 6 = 0"
# Or pipe the equation via stdin
echo "x^2 - 5x + 6 = 0" | python -m Math.mainThe program prints each solution step on a separate line, e.g.:
x^2 - 5x + 6 = 0
x^{2} - 5 x + 6 = 0
x = 2,\; x = 3
x \approx 2.00000000000000,\; x \approx 3.00000000000000
Import the engine in your own Python code:
from engine import generate_solution_steps
latex_eq = r"\begin{cases} x + y = 3 \\ 2x - y = 0 \end{cases}"
steps = generate_solution_steps(latex_eq)
for step in steps:
print(step)The returned steps list contains LaTeX strings representing each stage of the solution.
Math/
├── engine.py # Core solving logic (importable)
├── main.py # CLI entry point
├── README.md # You are reading it now
└── documentation.md # Detailed engine documentation
- Fork the repository.
- Create a feature branch (
git checkout -b feature/my‑feature). - Ensure code follows Google Python Style Guide and passes linting.
- Submit a pull request with a clear description of the changes.
This project is released under the MIT License. Feel free to use, modify, and distribute it.
Generated on 2026‑05‑01 by the Math Equation Solver project.