Re: Numerical accuracy/precision - this is a bug or a feature?
- To: mathgroup at smc.vnet.net
- Subject: [mg120274] Re: Numerical accuracy/precision - this is a bug or a feature?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 16 Jul 2011 05:41:27 -0400 (EDT)
On 7/14/11 at 5:20 AM, fateman at cs.berkeley.edu (Richard Fateman) wrote: >On 7/13/2011 12:13 AM, Bill Rowe wrote: >>On 7/12/11 at 6:59 AM, slawek at host.pl (slawek) wrote: >>The documentation for Equal (==) specifically states: >>Approximate numbers with machine precision or higher are considered >>equal if they differ in at most their last seven binary digits >>(roughly their last two decimal digits). >You mean "considered Equal[] by Mathematica. No. I meant exactly what I wrote. The excerpt was copy/paste from the documentation for Equal. Now if you want to interpret the documentation fine. But this is what is in the documentation. And if your comment is to the effect something other than Mathematica might treat 1.4 as unequal to 14/10, so what? The existence of other ways to treating this has no impact on what is in the Mathematica documentation or how Mathematica works. >>Ultimately, since the developers are unlikely to change such a >>fundamental aspect of Mathematica, the only sensible thing is to >>understand how Mathematica does things if you want to effectively >>use Mathematica. The alternative would be to find a system that >>operates more to your liking. >It might be fun to test to see if any of your code broke if you did >this: >Unprotect[Equal] Equal[a_Real,b_]:= >Equal[Rationalize[SetAccuracy[a,Infinity]],b] Equal[a_,b_Real]:= >Equal[a,Rationalize[SetAccuracy[b,Infinity]]] Fun?? Modifying built-in Mathematica commands is risky. To much of Mathematica uses other Mathematica functions. I could do then this spend lots of time testing and getting results that lead me to believe there is no impact only to get burned much later and likely have a very difficult time determining why something didn't work as expected. This isn't my idea of fun. I have far better things to do with my time. >For example, 0.1d0 is exactly p= 3602879701896397/36028797018963968 >so my new and improved Equal thinks that 0.1d0 and 1/10 are NOT >equal, (indeed, they differ by 1/180143985094819840) >but >0.1d0 and p ARE equal. >So the question is: would any of YOUR code break if you used this >patch on Equal? Really? I don't know the answer. And since I assume you don't have access to Mathematica's source code, you cannot know the answer either. I have no intention of attempting to determine the answer for the reasons stated above. So, a discussion of whether this patch would or would not break some code is pointless to me.