Skip to content

Latest commit

 

History

History
52 lines (41 loc) · 1.88 KB

README.md

File metadata and controls

52 lines (41 loc) · 1.88 KB

Shunting Yard Demo

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.

Demo Video

Shunting Yard Algorithm Demonstration

Implementation Features

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

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.

Example graph for a sine wave function (f(x) = 40 * sin(10*x))

Sine wave plot for f(x) = 40 * sin(10*x)

Build Instructions

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

License

This project is licensed under the terms of the MIT License.