Non-sequential substitution in SymPy

后端 未结 5 887
醉梦人生
醉梦人生 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:41

    The current version of sympy provides the keyword simultaneous. The complicated operations in the previous answers are no more necessary:

    In [1]: (x*sin(y)).subs([(x,y),(y,x)],simultaneous=True)
    Out[1]: y⋅sin(x)
    

提交回复
热议问题