I know how to use sympy.utilities.lambdify
to parse user-defined functions into lambdas like this:
f = lambdify(('x',), 'x**2 - 4*x')
and I know that I can make it accept a function of t
instead using
f = lambdify(('t',), 't**2 - 4*t')
But how do I make it so that lambdify
will treat 't'
as 'x'
in the string, so that 't**2 - 4*t'
is treated as identical to 'x**2 - 4*x'
? Note that I am not looking for a function of two variables x
and t
, rather a function of one variable that can parse either letter (but not both!), based on which one shows up in the parsed string. Also note that mixing letters should still be invalid, 't**2 - 4*x'
should prefer the t
s and ignore the x
s.