I've made a symbolic derivative solver quickly in C for the calculator. I'm posting it here if you want to use it: it solves for the derivative of an equation in Y1 and outputs the derivative to Y2, overwriting anything there. Even though the derivative is correct, it is often not in simplified form. Make sure you back up your programs, because if you enter too complicated or long of equation or with too many X variables, the calculator will run out of memory and crash. If you happen to find any bugs/wrong derivatives, please make an issue on github! The code is a little messy because I just made the program to show my teacher.
Simplification is easy if you use an AST and recursion. When you are simplifying a given node, first simplify all children nodes, then check if the given node can be simplified. If it can, replace the given node with the simplified version of itself. If a node (represented as [U operation V]), has an operation of '*', and U==1, replace the node with V, or if U==0, replace it with U(eg with zero). Just think of all the things that could be simplified (1*V, 0*V,0+V,ln(e) etc) and make test statements for it. If a node had an operation between two numbers, just apply the operation on those numbers. It's a bit tricky if your tree is something like 5*(8*X ), as the '8' is "stuck" in the same node as the 'X', and can't be multiplied with the 5. There might be better solutions, but what I did is write an algorithm to restructure the tree so that constants are lower in the tree, eg the previous example would be X*(5*8 ). (And use the "If a node had an operation between two numbers, just apply the operation on those numbers" rule.) You could also swap the order of the U and V in the node if U is for example 'X' and V is a constant, in order to make the result more pretty and have print a result of "6*X" instead of "X*6"
Ofc I made my simbolic derivator in java with OOP, might be a pain to do this sort of thing recursively without OOP.
Thanks c4ooo, those simplifications are already implemented in a similar way to what you described. What I would like to add is the simplification of like-terms, but the way I programmed the cas, it would be difficult to do without rewriting the inner workings. I am likely going to implement all the other simplifications when I rewrite the cas as a library for the CE. I do miss oop haha
Congratulations on tying third place in the Cemetech 2017 Project of the Year rankings! Since your program isn't in the Cemetech archives, I'll leave this here, but you really should fix that at your earliest convenience.
Thanks for the files.
I'm sorry but I don't fully understand how to install it.
I transfer the .8kp ONLY but when I'm trying to run it it's saying "need LibLoad"
Do I need to transfer somehow all the files in the download?
EDIT: Ok, I installed Libload. but now when I'm running the program its writing "Solver by Nathan.... Calculating done."
What I'm doing wrong?
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum