Finite difference matrix operators for performing numerical differentiation in python. The current version can handle 1D and 2D numpy arrays. 2D arrays need to be reshaped/unraveled into a column vector first. Differentiation can be performed by pre-multiplying the vector with the matrix operator. After the matrix operation, it can be reshaped to its originial dimensions. The matrix operators use secord order central differene formula (except for edge points where second order forward/backward difference formula is used). The code uses sparse matrices and therefore can handle large arrays.
- Differentiate numpy arrays using simple matrix multiplication.
- Differentiation of 1D and 2D data (in meshgrid format) have been implemented so far.
- The matrix operators are in the form of sparse matrices. So, the operators can handle large datasets.
The Differentiation_testing_v1.py
file contains an example differentiation problem in 1D and 2D.
The following plots show the first and second derivative of an one dimensional Gaussian function. The results obtained using the matrix operators are compared with the analytical results.
The following plots show the first derivative of a two dimensional Gaussian function. The results obtained using the matrix operators are compared with the analytical results.