Sympy: How to minimize the number of multiplications in multivariate expressions?
问题 I have a lot of expressions which sympy default writes as sums of products of variables. These expressions can get quite long. I would like to simplify these expressions to have as few as possible multiplications. A reduced example: from sympy import symbols, cse, factor, simplify, count_ops, collect a,b,c=symbols("a b c", integer=True, positive=True) e = a*a*b + a*a + a*b*b + a*b*c + 4*a*b + a*c + 3*a + b*b*c + 4*b*c + 3*c + 1 What I would like to get is something like: (a + b + 3) * (a + c)