How can I generate a stencil for a d/d(n*x) operator?
I am writing a program that needs a method to calculate line derivatives in an image. If we want to calculate the simplest forward derivative approximation with regards to d/dx, we can run the following operation:
diff[x] = -1.0 * image[x] + image[x+1]
If I want a more precise calculation of the derivative, I can increase the size of the stencil, and possibly recalculate as:
diff[x] = -3./2 * image[x] + 2*image[x+1] - 1./2 * image[x+2]
I have been using the finite difference method in obtaining these coefficients (specifically http://en.wikipedia.org/wiki/Finite_difference_coefficients )
Now suppose I want to take the derivative in regards to d/d(3*x), I could simply stretch the original stencil like this:
diff[x] = -1.0 * image[x] + image[x+3]
However, here I am not using the information from image[x+1] and image[x+2] and so the derivative approximation can be greatly improved. How can I generate a stencil that WILL use this information and hence be more accurate?