Ask Your Question

Revision history [back]

If g is some callable version of an expression, then you should differentiate g(x) rather than g itself:

sage: from sympy import symbols, lambdify, diff
sage: x = symbols('x')
sage: f = int(1)/(x + int(7)) # avoid Sage integers, ensure the result is a SymPy object
sage: g = lambdify(x, f)
sage: g(1)
0.125
sage: diff(g(x), x)
-1.0/(x + 7)**2.0

The resulting SymPy expression object can be lambdified again if desired.