I've done some more testing. It looks like some simplification of the
expression is not happening, but I haven't been able to understand when and
why it is done or not done. Here is a test program created by copying the
expression values from the debugger into the test program. Everything works
Yes, that is exactly what I thought, and that there might be some kind of
unintended side effect that I don't see.
Here is another example I just got:
print(exp) #!!
exp = expand(exp)
print(exp) #!!
exp = factor(exp)
produces:
(-1*(-2)*(m_0**2 + 2*(-2)*m_0 - 2*(-2)*m_0 + (-2)**2 -
> I can't see why something that should work the same every time suddenly
fails with an exception
Since you don't pass variables to the function, it's return value will
depend on the value of those variables in the calling context
```
def f():
return i
>>> for i in range(2): f()
...
0
1