I declare a variable, define an expression using the variable
from sympy import *
x = symbols ('x')
f = 2 * x
and then assign a value to the variable
x = 42
How can I substitute the variable in the expression by its current value? For obvious reasons
f.subs (x, x)
does not work. I know that I can use a different variable
xx = 42
f.subs (x, xx)
but ...
Nobody likes to get compared to their new girlfriend's ex, but in Matlab you could simply write subs (f)
which would be the equivalent to SymPy's f.subs ()
without any parameters, to substitute all intermediately assigned variables.