Subject: More consistent handling of 4.0*x - 3.0*x
From: Dieter Kaiser
Date: Sun, 28 Jun 2009 19:39:09 +0200
We have done some changes to get more consistent simplifications for floating
point numbers:
This is new:
(%i13) 2.0*x-2.0*x;
(%o13) 0.0
This is an old behavior
(%i14) 4.0*x-2.0*x;
(%o14) 2.0*x
But we still have:
(%i15) 4.0*x-3.0*x;
(%o15) x
(%i16) 4.0*(x+y)-3.0*(x+y);
(%o16) y+x
The reason is that we simplify a floating point number 1.0 or 1.0b0 away.
I would like to suggest to remove this from PLUSIN too. We would get:
(%i15) 4.0*x-3.0*x;
(%o15) 1.0*x
(%i16) 4.0*(x+y)-3.0*(x+y);
(%o16) 1.0*(y+x)
(%i17) expand(%);
(%o17) 1.0*y+1.0*x
Perhaps the last result might look strange, but I think it is more consistent.
This will work for bigfloat numbers and mixed types too:
(%i20) 2.0b0*x-2*x;
(%o20) 0.0b0
(%i21) 3.0b0*x-2*x;
(%o21) 1.0b0*x
(%i22) 3.0b0*(x+y)-2*(x+y);
(%o22) 1.0b0*(y+x)
(%i23) expand(%);
(%o23) 1.0b0*y+1.0b0*x
The testsuite and share_testsuite have no problems.
Any comments?
Dieter Kaiser