I've been trying this now for hours. I think I don't understand a basic concept, that's why I couldn't answer this question to myself so far.
What I'm trying is to implement a simple mathematical function, like this:
f(x) = x**2 + 1
x = sympy.Symbol('x')
f = sympy.Function('f')(x)
f.exp("x**2 + 1")
Here's your solution:
>>> import sympy >>> x = sympy.symbols('x') >>> f = x**2 + 1 >>> sympy.diff(f, x) 2*x