3
$\begingroup$

I have been experiencing some problems running a certain mathematica file in version 9. I've tracked the problem to a particular sum that I perform. Running the same code in version 8 and 9 I get two different results for this sum. If I then ask mathematica whether the two sums are identical mathematica 8 says that they are whereas mathematica 9 says that they are not.

So: I run the same code in version 8 and 9 and get a different result, if I compare the results version 8 says that they are the same, version 9 says that they are not.

Why would this happen? A bug? Comparison attached below.

Chop@FullSimplify[
  1.9999999999999996` x0^4 + 3.9999999999999987` x0^2 x1^2 + 
  2.` x1^4 + 0.3333333333333333` x1^2 x2^2 + (0.857142857142857` x0^2 - 
  0.699854212223765` x0 x1 + 0.14285714285714285` x1^2) x2^2 + 
  (0.5238095238095237` x0^2 + 0.11664236870396075` x0 x1 + 0.5873015873015872` x1^2) x2^2 + 
  (0.5238095238095236` x0^2 + 0.11664236870396079` x0 x1 + 0.5873015873015872` x1^2) x2^2 + 
  (0.5238095238095237` x0^2 + 0.11664236870396089` x0 x1 + 0.5873015873015872` x1^2) x2^2 + 
  (0.523809523809524` x0^2 +  0.11664236870396096` x0 x1 + 0.5873015873015872` x1^2) x2^2 + 
  (0.5238095238095236` x0^2 + 0.11664236870396066` x0 x1 + 0.5873015873015873` x1^2) x2^2 + 
  (0.5238095238095237` x0^2 + 0.11664236870396083` x0 x1 + 0.5873015873015874` x1^2) x2^2 + 
  1.9999999999999996` x2^4 == 
  1.9999999999999996` x0^4 + 2.` x1^4 + 4.` x1^2 x2^2 + 1.9999999999999996` x2^4 + 
  6 x0^2 (0.5238095238095236` x1^2 + 0.5238095238095236` x2^2) + 
  x0^2 (0.857142857142857` x1^2 + 0.857142857142857` x2^2) +  
  x0 (1.166423687039609` x1^3 - 0.6998542122237649` x1 x2^2) + 
  2 x0 (-0.19440394783993475` x1^3 + 0.11664236870396069` x1 x2^2) + 
  x0 (-0.1944039478399347` x1^3 + 0.11664236870396072` x1 x2^2) + 
  x0 (-0.1944039478399347` x1^3 + 0.11664236870396077` x1 x2^2) + 
  2 x0 (-0.1944039478399347` x1^3 + 0.11664236870396083` x1 x2^2)]

Cheers, David

$\endgroup$
3
  • $\begingroup$ Do not use bugs tag. It is only for confirmed by community bugs. $\endgroup$
    – ybeltukov
    Oct 13, 2013 at 11:43
  • $\begingroup$ @Artes I also thought that it is a bug, but FullSimplify just divide by very small number (it's not forbidden) that produces coefficients like 0.375. See also example in my answer. $\endgroup$
    – ybeltukov
    Oct 13, 2013 at 19:03
  • $\begingroup$ @ybeltukov That sounds reasonably, I guess that division is because of FullSimplify[... == ...] which is allowed. Anyway you should include all those remarks to your answer. $\endgroup$
    – Artes
    Oct 13, 2013 at 19:11

1 Answer 1

10
$\begingroup$

You need to be very careful of simplifying equations with numeric quantities. Compare:

Simplify[1.0 x == 0.9999999999999 x]
Simplify[1.0 x == 0.99999999999999 x]
x == 0
True

In the first case Simplify divide by very small number that produce x == 0. This division is allowed with Simplify[... == ...].

The same way FullSimplify[... == ...] (without Chop) in the OP's question produce

v8:

x0 (4.44089*10^-16 x0 x1^2 - 6.66134*10^-16 x1^3 + (8.88178*10^-16 x0 + 
   1.66533*10^-16 x1) x2^2) == 0

v9:

x0 (1. x0 x1^2 - 1.5 x1^3 + 2. x0 x2^2 + 0.375 x1 x2^2) == 0

This equations are the same except the factor 4.44089*10^-16.

Solution: you just need to change Chop@FullSimplify[... == ...] to Chop@FullSimplify[... - ...] == 0

v8:

True

v9:

True
$\endgroup$
1
  • $\begingroup$ Ah, of course. Well, I guess that solves the mystery... I guess some kind of implementation of Round should solve the problem. I'll try not to misuse the bug tag in the future! $\endgroup$ Oct 13, 2013 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.