Expression simplification in SymPy

余生颓废 提交于 2019-12-23 19:10:05

问题


I want to achieve this kind of simplification: e+ac+ad+bc+bd = e+(a+b)(c+d) . None of SymPy simplification functions worked this way. Is there any other method in SymPy or somewhere else in python to get this kind of simplification?


回答1:


You can use collect(expr, e, func=factor).

In [5]: expr = e + a*c + a*d + b*c + b*d

In [6]: collect(expr, e, func=factor)
Out[6]: e + (a + b)⋅(c + d)


来源:https://stackoverflow.com/questions/40620585/expression-simplification-in-sympy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!