I am getting an exception where I don't see why it happens.

The exception is:
invalid input: Mod(1*(2*0) + 1*(1*1), (1*1)*(1*2))

The statement where it is being thrown is:
    print(P3().subs(i, 0))
    exp = factor(expand(P3().subs(i, 0)))

P3() should always return the same thing:
def P3():
    exp = 2*i**2 + 4*i*j + 8*i*m - j**2 +2*m*j + 9*m**2
    return exp

The print statement is just for debugging purposes. It shows me multiple 
times
-j**2 + 2*j*m + 9*m**2
then
9*m**2 + j*(2*m) - j**2 + (8*0)*m + (4*0)*j + 2*0**2
invalid input: Mod(1*(2*0) + 1*(1*1), (1*1)*(1*2))

So, I can't see why something that should work the same every time suddenly 
fails with an exception. The statement P3().subs(i, 0) should always return 
the same thing.

A note on my coding style: P3 could easily be a global constant, but the 
function paradigm fits very well with the mathematics that I am 
reproducing. The most complex case I have runs recursively, which is very 
valuable. Also, I am using "exp" as a local variable that means 
"expression".

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/c427ce48-8d94-48df-a89c-fea3686b26a3n%40googlegroups.com.

Reply via email to