0

Suppose I can generate infinitely many values of x and f(x). The functional form of f(x) is now known. Now I need the value of f'(x) at each point. What is the best way to find it with satisfactory accuracy using matlab. In short it is described below

x:    1     1.1    1.2..............................
f(x): 2      4      5...............................
f'(x):?      ?      ?...............................
  • 2
    "Suppose I can generate infinitely many values of x and f(x)" But... you can't... – 5xum Mar 26 '15 at 08:48
  • You may consider the following approximation :

    $$ f'(x) = \frac{-f(x+2h)+8f(x+h)-8f(x-h)+f(x-2h)}{12h} + O(h^4) $$

    – pitchounet Mar 26 '15 at 08:50

1 Answers1

1

Using finite many points, you can use the finite difference formula $$\frac{f(x+h) - f(x-k)}{h+k}$$ to approximate the derivative $f'(x)$ at $x$. For example, to evaluate $f'(1.1)$, you can take $h = 0.1 = k$. Then $$f'(1.1) = \frac{f(1.2) - f(1.0)}{0.2} = 5\times(5-2) = 15$$ The accuracy is improved if the partition is finer, i.e. $h$ an $k$ are chosen smaller. But that requires more points.

There are more finite difference formulas. You can goggle for more.

Empiricist
  • 7,933