Study Programme: Tietojenkäsittelytieteen kandidiohjelma, TKTK
Topic: Scientific Calculator
Programming language: Python
Scope: A scientific calculator that can evaluate mathematical expressions written in infix notation.
Peer Reviews: I am able to review projects written in Python or Java.
All the project documentation will be written in English. No LLM's will be used in this project.
The calculator will be able to evaluate mathematical expressions written in infix notation. The calculator will support the following operators: +
, -
, *
, /
, ^
, (
, )
. It will also have support for variables, one-parameter functions (sqrt
, sin
) and two-parameter functions (min
, max
)
It is considered hard to evaluate mathematical expressions written in infix notation because of the operator precedence and the need to use parentheses to override the precedence. That is why we first need to convert the expression to Reverse Polish notation (RPN) using the Shunting-yard algorithm. After the expression is in RPN or postfix notation, we can evaluate the expression easily using a stack and applying the calculations to the top two elements.
The calculator will use the Shunting-yard algorithm to convert the infix notation to Reverse Polish notation (RPN) and then evaluate the expression and return the result.
The calculator will use a custom Stack and Queue data structures both built with Python's built-in deque
.
Stack and Queue are data structures that have O(1) time complexity for adding and removing elements while the shunting-yard algorithm has O(n) time complexity. The time will depend on the length of the expression, thus the calculator time complexity will be O(n).