Numerical Differentiation

This rudimentary numerical differentiation script, although very basic, is very useful. It is a Jupyter Notebook and consists of one function, defined as “diff”, which uses the NumPy module. It allows the user to input an x-array and y-array (typically graphed data), where it uses mathematical methods to approximate the numerical values of the first derivatives of each y value. The differentiated values can then be plotted with matplotlib.

Numerical Differentiation

As is to be expected, considering the methodology used involves approximation, using more datapoints leads to a higher resolution of estimated derivatives. The script uses the method of finite differences between points in each array, which is aptly described in this Wikipedia article.

The script has many uses in my labs work, among other things; for example, where the electric field of a point charge is given by the directional derivative of a given potential, the script can evaluate the electric field's magnitude for a given potential dataset. This is just one example. It may not have many uses to the general user, but is worth having in various circumstances.


Click the image below to download the Numerical Differentiation script:


Download Numerical Differentiation Script

Last updated: 06/05/2020

Numerical Differentiation