I have gone into detail in this issue thread https://github.com/sympy/sympy/issues/23709
but the gist is that I am trying to get the coefficients of an equation in the form:
parsed_input = 7*x + 4*(10*x + 6) >= 8*x + 15
I am using the pattern:
x = Wild("x", properties=[lambda x: isinstance(x, Symbol)])
a = Wild("a", properties=[lambda x: isinstance(x, Integer)])
p = Wild("p", properties=[lambda x: isinstance(x, Integer)])
q = Wild("q", properties=[lambda x: isinstance(x, Integer)])
b = Wild("b", properties=[lambda x: isinstance(x, Integer)])
c = Wild("c", properties=[lambda x: isinstance(x, Integer)])
r = Wild("r", properties=[lambda x: isinstance(x, Integer)])
s = Wild("s", properties=[lambda x: isinstance(x, Integer)])
expected_output = Ge(Mul(a, (p*x + q)) +b*x + c, r*x + s)
But when I do:
matching = parsed_input.match(expected_output)
I am mostly getting a=1 , p=40, q=24 and some other times I get a=4,p=10, q=6
How can I get a=4,p=10, q=6 everytime?