I am working on an ahkab circuit simulator application and a short short history I need to substitute the variable laplace s in some equations with 1j * w. Itβs much more convenient for me to perform this substitution, while others use symbol names rather than the symbols themselves. I came across some strange behavior.
If you do
>>> x = Symbol('x')
>>> y = Symbol('y')
>>> expr = x + y
x + y
>>> expr.subs('x', 'w')
w + y
It seems that I am working as I expect. The problem is that the character is declared using complex = True, here
>>> s = Symbol('s', complex = True)
>>> y = Symbol('y')
>>> expr = s + y
s + y
>>> expr.subs(s, 'w')
w + y
>>> expr.subs('s', 'w')
s + y
I could not find the substitution information in this way in the docs. This seems like a mistake to me, but I donβt know what the behavior should look like.
source
share