“Dynamic” N-dimensional finite difference in Python along an axis
问题 I have a function to compute the finite difference of a 1d np.array and I want to extrapolate to a n-d array. The function is like this: def fpp_fourth_order_term(U): """Returns the second derivative of fourth order term without the interval multiplier.""" # U-slices fm2 = values[ :-4] fm1 = values[1:-3] fc0 = values[2:-2] fp1 = values[3:-1] fp2 = values[4: ] return -fm2 + 16*(fm1+fp1) - 30*fc0 - fp2 It is missing the 4th order multiplier ( 1/(12*h**2) ), but that is ok, because I will