Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

share|improve this question
    
Do not use bugs tag. It is only for confirmed by community bugs. –  ybeltukov Oct 13 '13 at 11:43
    
@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. –  ybeltukov Oct 13 '13 at 19:03
    
@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. –  Artes Oct 13 '13 at 19:11
add comment

1 Answer

up vote 9 down vote accepted

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
share|improve this answer
    
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! –  storluffarn Oct 13 '13 at 18:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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