Is there a way to discretize the derivative of an unknown function in sympy? I am trying to achieve the following:
from sympy import *
>>> f = Function('f')
>>> x = Symbol('x')
>>> dfdx = Derivative(f(x),x).somemethod()
>>> print dfdx
(f(x+1) - f(x-1)) / 2
>>> eq = lambdify((f,x),dfdx)
>>> w = np.array([1,5,7,9])
>>> print eq(w,1)
-3
After reading this question I have implemented this functionality in Sympy and it is currently available in:
my branch: https://github.com/bjodah/sympy/tree/finite_differencesympy master (https://github.com/sympy/sympy), and will be availble in 0.7.6
Here is an example: