Comparing Sympy factor results false

91 views Asked by At

I've found an issue about Sympy that I can't understand.

Why does this return false...

factor(81*q + 90) == 9*(9*q + 10)

... whilst this returns true?

factor(q**2-64) == (q+8)*(q-8)

When I type

factor(81*q + 90)

the output is exactly this expression

9*(9*q + 10)

So, why doesn't Sympy consider my first comparison is true?

2

There are 2 answers

4
asmeurer On

SymPy automatically distributes number*addition, like 9*(9*q + 10) into 81*q + 90. factor uses a trick to prevent this automatic simplification (basically, Mul(9, 9*q + 10, evaluate=False)).

There is an open issue to remove this automatic simplification, but it hasn't been implemented yet.

0
Prokhozhii On

From docs

You may do as below:

factor(81*q + 90).equals(9*(9*q + 10))