4
$\begingroup$

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?

  • 0
    Try [this](http://www.math.unl.edu/~s-bbockel1/833-notes/node23.html#4.1.1)2012-03-02

1 Answers 1

1

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?

  • 0
    Thanks! The odd results were because of me, but I fi$x$ed it and using the formula $y$ou suggested I managed to increase accurac$y$. I need it for a school project on "Newton polynomial"2012-03-02