Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expression simplification in SymPy

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?

like image 477
Giorgi Bakhtadze Avatar asked Nov 15 '16 22:11

Giorgi Bakhtadze


Video Answer


1 Answers

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)
like image 84
asmeurer Avatar answered Oct 17 '22 07:10

asmeurer