Sunday, 10 February 2019

sympy: how to simplify across multiple expressions

I have a set of sympy expressions like this (a few hundred of them):

>>> foo = parse_expr('X | Y')
>>> bar = parse_expr('(Z & X) | (Z & Y)')
>>> baz = parse_expt('AAA & BBB') # not needed for this example; just filler

I can simplify one in isolation:

>>> simplify(bar)
Z & (X | Y)

Is there a way to simplify, including the whole set of variables available?

>>> mysimplify(bar, include=(foo,bar,baz))
Z & foo



from sympy: how to simplify across multiple expressions

No comments:

Post a Comment