Question: simplify of Matrix returns wrong remembered value?

Not able to make an example, since it depends of code flow and not able to reproduce it in small code. I spend hrs trying to make one. It depends on how memory is arranged and this problem shows only when running my large program.

But I can show screen shots from a debugging session showing clearly the problem, and the solution I found.

Maple was giving this result, when calling simplify to simplify a matrix:

Notice what happend. There was a matrix [3/2,-1,-3/2,0],[0,0,0,0],[-2,2,2,0]] before that was simplfied.

Next iteration called simplify on modified version of the matrix, which is  [3/2,-1,-3/2,0],[0,0,0,0],[0,2/3,0,0]].  (called e in the above).

But simplify returned as result the old copy. Which is completely wrong.

It simplified  [3/2,-1,-3/2,0],[0,0,0,0],[0,2/3,0,0]]  to  [3/2,-1,-3/2,0],[0,0,0,0],[-2,2,2,0]]  !

Now see what happes when calling forget(simplify)

You see, now it simplfies it correctly. (there is actually nothing to simplify, so it returned back same matrix as expected, and no copy it had in memory).

So now I went over all my code, and everywhere it calls simplify, added 

     forget(simplify)

right after each call.

Problem fixed.

May be someone can shed a light on why this happens. Any information needed will try to provide. I can reproduce this each time but using the debugger.

Please Wait...