I want to convert a function defined in Python to a symbolic expression in SymPy (lambdify
does the opposite):
import numpy as np
import sympy as sp
def fun1(t):
return t + 3
def fun2(t):
return np.sin(t)
And then convert this fun1
and fun2
to a symbolic expression so I can do, for example:
x = sp.symbols('x')
fun1s = fun1(x)
fun2s = fun2(x)
Then I can differentiate them like:
dfun1s = sp.diff(fun1s, x)
dfun2s = sp.diff(fun2s, x)
I found something here but it's quite complicated, is there an easier way to do it?