Math Interpreter is a web application that accurately evaluates mathematical expressions, visualizing the underlying abstract syntax tree for better understanding of the expression's structure.
Sample output of the Math Interpreter for sin(-3 * pi / 2).
- Tokenization: Converts the input mathematical expression into tokens.
- Parsing: Transforms the list of tokens into an abstract syntax tree (AST).
- Evaluation: Computes the result of the expression based on its AST.
- Visualization: Renders the AST as a graphical tree using Graphviz.
- Supported Operations: Basic arithmetic (
+
,-
,*
,/
,^
), trigonometric functions (sin
,cos
,tan
), and constants (pi
).
-
Clone the repository:
git clone https://github.com/lawsus/math-interpreter.git
-
Navigate to the project directory:
cd math-interpreter
-
Install the required dependencies:
pip install -r requirements.txt
-
Start the Flask application:
python main.py
The application should now be running on a local server.
- Navigate to the local server.
- Enter a valid mathematical expression in the input field.
- Click "Evaluate".
- View the resulting value of the expression, the inorder traversal, and the visualized AST.
Contributions are welcome.