Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been using this to compute the first order derivative's value of a function $f$ in a given point: $$f'(x) = \frac{f(x+\epsilon) - f(x-\epsilon)}{2\epsilon}$$

For some $\epsilon = 0.0001$ or so. But when I try to use the same formula for higher order derivatives it gives odd results

$$f''(x) = \frac{f'(x+\epsilon) - f'(x-\epsilon)}{2\epsilon}$$ $$f''(x) = \frac{\frac{f(x+\epsilon+\epsilon) - f(x-\epsilon+\epsilon)}{2\epsilon} - \frac{f(x+\epsilon-\epsilon) - f(x-\epsilon-\epsilon)}{2\epsilon}}{2\epsilon}$$

What am I doing wrong here?

share|cite|improve this question
Don't use previous derivatives to find higher-order ones. Use $f$ directly. See… – lhf Mar 2 '12 at 14:47
Try this – Inquest Mar 2 '12 at 14:54
up vote 1 down vote accepted

You use a $1,-2,1$ scheme

$$f''(x) = \frac{\frac{f(x+\epsilon+\epsilon) - f(x-\epsilon+\epsilon)}{2\epsilon} - \frac{f(x+\epsilon-\epsilon) - f(x-\epsilon-\epsilon)}{2\epsilon}}{2\epsilon} = \frac{f(x+h) - 2f(x)+f(x-h)}{h^2},$$

with $h=2\epsilon$, which is the first one here. Here is a list of alternatives.

Do you implement it with the additional two fractions and include "${}+\epsilon-\epsilon$"?

For what application and with program what do you use it?

Odd calculation of what kind or to what accuracy?

share|cite|improve this answer
Thanks! The odd results were because of me, but I fixed it and using the formula you suggested I managed to increase accuracy. I need it for a school project on "Newton polynomial" – Diana Dcn Mar 2 '12 at 15:32

Your Answer


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.