(Solved): The Formula F'(x) = F(x + H) – F(x – H) - 2h Can Be Used To Find An Approximate Derivative Of A ...

The formula f'(x) = f(x + h) – f(x – h) - 2h can be used to find an approximate derivative of a mathematical function f(x) if h is small. (This is a finite- difference formula, which you will see later as well. There is more than one way to set these approximations up.) Write a function diff( f,x, h=1e-5 ) that returns the approximation of the derivative of a mathematical function represented by a Python function f( x). For instance, the result of diff( math.sin, 0.25*math.pi ) should be 0.7071 (with some numerical error). The result of diff( math.sin, 0.375*math.pi, h=1e-3 ) should be 0.3827 (with some numerical error). (This assignment is based on Langtangen, Exercise 3.24a.)