Non-sequential substitution in SymPy

后端 未结 5 972
醉梦人生
醉梦人生 2021-02-13 14:11

I\'m trying to use [SymPy][1] to substitute multiple terms in an expression at the same time. I tried the [subs function][2] with a dictionary as parameter, but found out that i

5条回答
  •  没有蜡笔的小新
    2021-02-13 14:46

    The Keyword simultaneous will do non-clashing subs regardless of the input (dict or sequence):

    >>> x.subs([(x,y),(y,z)],simultaneous=1)
    y
    >>> x.subs([(y,z),(x,y)],simultaneous=1)
    y
    

提交回复
热议问题