pysindy.differentiation.SpectralDerivative
- class pysindy.differentiation.SpectralDerivative(d=1, axis=0)[source]
Spectral derivatives. Assumes uniform grid, and utilizes FFT to approximate a derivative. Works well for derivatives in periodic dimensions. Equivalent to a maximal-order finite difference, but runs in O(NlogN).
- Parameters:
d (int) – The order of derivative to take
axis (int, optional (default 0)) – The axis to differentiate along
Examples
>>> import numpy as np >>> from pysindy.differentiation import SpectralDerivative >>> t = np.arange(0,1,0.1) >>> X = np.vstack((np.sin(t), np.cos(t))).T >>> sd = SpectralDerivative() >>> sd._differentiate(X, t) array([[ 6.28318531e+00, 2.69942771e-16], [ 5.08320369e+00, -3.69316366e+00], [ 1.94161104e+00, -5.97566433e+00], [-1.94161104e+00, -5.97566433e+00], [-5.08320369e+00, -3.69316366e+00], [-6.28318531e+00, 7.10542736e-16], [-5.08320369e+00, 3.69316366e+00], [-1.94161104e+00, 5.97566433e+00], [ 1.94161104e+00, 5.97566433e+00], [ 5.08320369e+00, 3.69316366e+00]])
Methods