I guess in Python, there are no functions to calculate first derivative with the help of the gradient function using 5th order stencils (up to fifth order accuracy). The NumPy gradient function calculates the gradient using 2nd order accurate central difference at interior points and either 1st or 2nd order at the boundaries.
Suppose I have the following code that calculates the gradient of the perturbed parabola y=x^2+x/2:
X = np.linspace(0,100,200)
Y = np.array([])
for i in range(0,len(X)):
Y = np.append(Y,X[i]**2+X[i]/2)
D = np.gradient(Y,X)
D is the first derivative. I need to calculate D using 5th order stencils. Is there a way to do it directly without writing an external function?
The reason for my asking this question relates to another problem. Consider a domain bounded by a Jordan boundary, like a deformed disc, that grows with time. While calculating the curvature of the boundary, as the domain grows with time, gradient function I have used to calculate the first and the second derivatives to find the curvature, is introducing noise to the graph of the curvature as time increases. I was wondering whether using the gradient with a higher order stencil will reduce the noise.