Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
    
It really helps to format your questions in LaTex / mathjax. Helps readability and helps illicit more responses. There is guidance on the FAQ. Regards –  Amzoti Mar 11 '13 at 12:51
    
Thanks, when I have time, I will improve it. –  Boyko Perfanov Mar 11 '13 at 13:07

1 Answer 1

Let's give the name $f$ to the function we're trying to differentiate. If I understand correctly, you are trying to estimate $\tfrac{df}{d(3x)}$ using finite differences.

It's not really clear what $\tfrac{df}{d(3x)}$ means. Let's assumee that it means $\tfrac{df}{du}$, where $u = 3x$.

But, if that's the case, then

$$ \frac{df}{d(3x)} = \frac{df}{du} = \frac{df}{dx}\frac{dx}{du} = \frac13\frac{df}{dx}$$

So, you can use the finite-difference formulae you read about for computing $\tfrac{df}{dx}$

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.