Derivative Calculator

v1

Derivative Calculator
Derivative Calculator
Derivative Calculator

This Derivative Calculator is mainly a build up of functions that come together to find the derivative of an input mathematical expression. The main principle of this project was to build everything from scratch, as a challenge, not only to develop my proficiency in python but also to attempt to build something useful to me in my studies. As a result, there are many parts of this script that already belong to other Python modules, for example the scipy.misc.derivative function, which can find the derivative of an expression at any given point.


The script works on the basis of slicing and replacing strings; all inputs from the user are strings. This means that the most basic functions in the code include replacing specific instances of a substring within a string, or iterating through the string to return all numeric digits. The whole calculator essentially works on this basis; it has steps in logic based on what can be expected in a mathematical expression, for example:

The current build stage of the code is working on quotient differentiation (fractions), while also cleaning and finalising product differentiation (multiple functions or variables in an expression, e.g. x2e5x). The introduction of quotients has led to some interesting new functions being incorporated, such as "variable_cancel", which evaluates the expression for identical variables on the top and bottom of a fraction and cancelling them to simplify, e.g. x5x → x4.

Derivative Calculator
Derivative Calculator
Derivative Calculator
Derivative Calculator
Derivative Calculator Derivative Calculator

The calculator started life as an attempt at building a Maclaurin expander, to approximate complicated functions for physics. After realising that derivatives of functions would be necessary, that was decided as a good place to start.
Only two modules are used in this .py script - time and math, the latter of which is only used in the (work-in-progress) Maclaurin expansion function at the bottom. Future iterations of the project will aim to include (possibly optimistically) complex differentiation.



A download for the Derivative Calculator v1 is coming soon!