simple symbolic differentiator that takes simple expressions and gives their derivatives
expr = term (('+' | '-') term)*
term = factor (('*' | '/') factor)*
factor = base ('^' factor)?
base = NUMBER | VARIABLE | '(' expr ')' | '-' base
- expr => handles addition and subtraction
- term => handles multiplication and division
- factor => handles exponentiation
- base handles => numbers, variables, parentheses, and unary minus
I initially thought of using libraries to evaluate the mathematical expressions using libraries but since i'll be dealing with symbols of some sort, maybe it's feasible if i wrote a parser/tokenizer from scratch since I had some idea on how to write a tokenizer or parser from previous small projects. So...
- I'll be writing a tokenizer and parser from scratch lets see how that goes (it did not go well)
- sum rule
- power rule
- multiplication by a constant
- product rule(simples ones tho)
- difference rule
- chain rule
- trignonometric functions [not yet implemented]
currently working on the tokenizer (still) i focused more on writing better code instead of just programming it outI'm taking references from the docs and existing tokenizers lets see how this goes
I've taken the tokenizer present on mkdb as reference for this and modified itI've followed the Recursive Descent Parsing parsing method for this project
was kinda stuck on parser when it failed to include the variable 'x' in parse tree(AST), well it was a simple mistake, I forgot the BinaryOperator in betweencurrently working on the parser(still)
# install cargo
sudo pacman -S cargo
git clone https://github.com/razzat008/derivative_calculator
cd derivative_calculator
cargo build # installing dependencies
cargo runrustyline = "16.0.0" # To handle the input from user- (Structure and Interpretation of Computer Programs)[https://web.mit.edu/6.001/6.037/sicp.pdf]
- (An implementation of a database from scratch in rust)[https://github.com/antoniosarosi/mkdb]
