A demo program for parsing and evaluating mathematical expressions using the Shunting Yard algorithm, implemented in Java.
It converts expressions from infix notation to postfix/Reverse Polish Notation (RPN) which can then be evaluated by a computer, taking into account the order of precedence of different operators such as parentheses, multiplication, division, subtraction (PEMDAS) etc.
This implementation of the algorithm has been extended to support:
- Variable declaration and evaluation
- Functions
- sin
- cos
- tan
- Numeric values greater than 9
- Negative values
- Decimal values
Graphs can be plotted using the plot
command in the CLI tool.
It produces image files in PPM (Portable Pixmap) format with points generated by the provided function.
Step 1) Build source files
javac src/main/java/io/girish/core/*.java src/main/java/io/girish/shuntingyard/*.java src/main/java/io/girish/shuntingyard/enums/*.java src/main/java/io/girish/cli/enums/*.java src/main/java/io/girish/cli/*.java src/main/java/io/girish/*.java -d bin
Step 2) Run the program
cd bin
java io.girish.Main
Optionally, you can create an executable JAR file:
cd bin
jar -cmvf ../META-INF/MANIFEST.MF ./notmatlab.jar .
java -jar notmatlab.jar
This project is licensed under the terms of the MIT License.