This project is a symbolic derivative calculator designed for the Numworks calculator, implemented in Python. It uses Reverse Polish Notation (RPN) to directly compute derivatives without expression trees. The calculator handles both basic arithmetic operations and advanced functions like trigonometry, logarithms, and exponentiation.
- Supports core operations:
+
,-
,*
,/
,^
. - Handles functions such as
sin
,cos
,tan
,log
,exp
,sqrt
, and more. - Efficient derivative computation without the use of expression trees, saving memory and processing time.
- Simplifies expressions involving implicit multiplication and redundant terms.
- Allowing users to input complex mathematical expressions and receive their symbolic derivatives.
This program is inspired by the paper “Symbolic Derivation without Using Expression Trees (2001)” by Predrag V. Krtolica and Predrag S. Stanimirović. Here's a high-level overview of the process:
- Tokenization: The mathematical expression is broken into manageable tokens, including numbers, operators, and functions.
- Reverse Polish Notation (RPN): Instead of creating an expression tree, the tokens are converted into RPN using the shunting yard algorithm. RPN ensures proper precedence of operations without the need for parentheses.
- Derivative Calculation: The program traverses the RPN in reverse order, applying derivative rules for each token. The recursive algorithm simplifies the derivative as it progresses, applying the chain rule and product rule where necessary.
- Simplification: After computing the derivative, the algorithm eliminates redundant terms (e.g.,
x * 0
,1 * x
, etc.) and outputs a simplified expression. - Infix Notation: Finally, the result is converted back into infix notation, making it easy to read.
This method is memory-efficient, as it avoids the creation of expression trees and requires only two arrays: one for the input expression (in RPN) and one for the derivative (also in RPN).
Given the input:
Expression: sin(x) + x^2
The program will return:
Derivative: cos(x) + 2*x
This program is intended for use on a Numworks calculator. Visit our official Numworks page to import easily the program.
You can also follow these steps to transfer the program to your Numworks device:
-
Connect the Calculator to Your Computer:
- Use the Numworks USB cable to connect your calculator to a PC.
- Open your browser and navigate to the official Numworks Python interface.
-
Install the Python Script:
- Click on "Upload a script" in the Python interface.
- Upload the
derivcalc.py
file from this repository.
-
Run the Program:
- On your Numworks calculator, navigate to the Python app.
- Run the
derivcalc.py
script. - Input the expression you want to differentiate when prompted, and the calculator will return the symbolic derivative.
- A Numworks calculator with Python enabled!
- Alternatively, you can run the program on any Python environment, such as on a desktop with Python 3.x installed.
-
Correct the derivative of the
^
operator. -
Fully implement
ctg
andtan
functions. -
Simplify the final output expression.
-
Correct bugs and make the program more robust.
-
Implement more test cases.
-
And more...
Created by Leys Kamil and Lebaube Gaspard.
Based on "Symbolic Derivation without Using Expression Trees" by Predrag V. Krtolica and Predrag S. Stanimirović.
This project is designed specifically for the Numworks calculator ^^
NUMWORKS, WE WANT A CAS ON YOUR CALCULATOR ! IT'S EASY TO IMPLEMENT WITH SYMPY !
- Numworks Python Interface
- Reverse Polish Notation (RPN)
- Shunting Yard Algorithm
- Symbolic Derivation without Using Expression Trees (2001)
This project is licensed under Gaskam.com © 2024. All rights reserved.
For more information, visit our GitHub page.