Re: Numerical accuracy/precision - this is a bug or
- To: mathgroup at smc.vnet.net
- Subject: [mg120278] Re: Numerical accuracy/precision - this is a bug or
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 16 Jul 2011 05:42:10 -0400 (EDT)
On 7/15/11 at 5:15 AM, christoph.lhotka at univie.ac.at (Christoph Lhotka) wrote: >If we want to see the actual form of a and b I would rather use >FullForm: >a = 1.100000000000000000000000000; b = 1.1; Note, a more compact way to get 27 digit precision would be a = 1.1`27; and this has the additional advantage of being more apparent when read that the precision is 27 digits. >FullForm/@{a,b} >{1.1000000000000000000000000000000000000000000000000000000001`27. >041392685158225,1.1`} >As we can see the first number is accurate up to the 27th digit >while the second is accurate up to machine precision. Well but they >are still different! >First I was surprised that SameQ yields True but I guess that it has >something to do with Mathematica's principle to return results >correct to the lowest precision found in the expression. The documentation for SameQ states: SameQ requires exact correspondence between expressions, except that it still considers Real numbers equal if they differ in their last binary digit. So, SameQ cannot be used to insure two real values are identical in all aspects. >So to my opinion Mathematica does the following: 1) first convert >all numbers to numbers of the lowest precision found in the >expression, 2) follow the usual evaluation chain. Am I correct? I don't know if this is entirely true. In my experience, Mathematica converts numbers in any expression containing both machine precision numbers and higher precision numbers to machine precision before completing the evaluation. But I have not ever investigated the behavior when using lower precision than machine precision. I would guess this characteristic is intended to improve performance since machine precision computations are done by hardware and arbitrary precision is done by Mathematica. That is, reducing the precision of higher precision numbers to machine precision would allow the evaluation to take place using the FPU resulting in less time to complete the evaluation. And if this is the goal, I would guess Mathematica does not reduce machine precision values to lower precision since this would make them an arbitrary precision value and increase execution time.