Pi is Rotten? [message #88044] |
Fri, 14 March 2014 06:17  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Folks,
Perhaps because today is Pi Day:
http://bit.ly/1lDkQi4
Andrew Cools alerts me to an IDL problem of utmost importance. I refer,
of course, to an inexplicable problem with IDL's version of Pi:
IDL> print, !dpi, format='(f0.18)'
3.1415926535897931
As everyone knows, the actual value of Pi is 3.1415926535897932. The
last digit here is a "2", not a "1".
http://bit.ly/1qCvycp
Even ExelisVis itself realizes this, and puts the proper value in the
new !Const system variable. What's up with this? Can we ever trust IDL
again?
Cheers,
David
P.S. Let's just say I'm off to get a piece of apple with my morning Joe.
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
|
Re: Pi is Rotten? [message #88049 is a reply to message #88048] |
Fri, 14 March 2014 09:16   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Norbert Hahn writes:
> David Fanning <news@idlcoyote.com> wrote:
>
>> Folks,
>>
>> Perhaps because today is Pi Day:
>>
>> http://bit.ly/1lDkQi4
>>
>> Andrew Cools alerts me to an IDL problem of utmost importance. I refer,
>> of course, to an inexplicable problem with IDL's version of Pi:
>>
>> IDL> print, !dpi, format='(f0.18)'
>> 3.1415926535897931
>
> Hm, !dpi is a double precision number. It has about 16 useful digits.
> Due to rounding the last digit is always uncertain.
That's what I told him. He is not satisfied. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Pi is Rotten? [message #88050 is a reply to message #88049] |
Fri, 14 March 2014 11:30   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
In case anyone might think the sky is actually falling, at least with IDL 8.2.3
Windows 7 64-bit:
IDL> print,!dpi,format='(F25.23)'
3.14159265358979310000000
IDL> print,!const.pi,format='(F25.23)'
3.14159265358979310000000
And I think this can reassure us that at that digit position, double precision
does not distinguish between those two values:
IDL> print,3.1415926535897932D EQ 3.1415926535897931D
1
Further:
IDL> print,3.1415926535897928D EQ 3.1415926535897931D
0
IDL> print,3.1415926535897929D EQ 3.1415926535897931D
1
IDL> print,3.1415926535897930D EQ 3.1415926535897931D
1
IDL> print,3.1415926535897931D EQ 3.1415926535897931D
1
IDL> print,3.1415926535897932D EQ 3.1415926535897931D
1
IDL> print,3.1415926535897933D EQ 3.1415926535897931D
1
IDL> print,3.1415926535897934D EQ 3.1415926535897931D
0
https://www.idlcoyote.com/math_tips/sky_is_falling.html
Cheers,
-Dick
Dick Jackson Software Consulting Inc.
Victoria, BC, Canada
www.d-jackson.com
On Friday, March 14, 2014 6:17:51 AM UTC-7, David Fanning wrote:
> Folks,
>
> Perhaps because today is Pi Day:
>
> http://bit.ly/1lDkQi4
>
> Andrew Cools alerts me to an IDL problem of utmost importance. I refer,
> of course, to an inexplicable problem with IDL's version of Pi:
>
> IDL> print, !dpi, format='(f0.18)'
> 3.1415926535897931
>
> As everyone knows, the actual value of Pi is 3.1415926535897932. The
> last digit here is a "2", not a "1".
>
> http://bit.ly/1qCvycp
>
> Even ExelisVis itself realizes this, and puts the proper value in the
> new !Const system variable. What's up with this? Can we ever trust IDL
> again?
>
> Cheers,
> David
>
> P.S. Let's just say I'm off to get a piece of apple with my morning Joe.
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Pi is Rotten? [message #88055 is a reply to message #88044] |
Sun, 16 March 2014 13:10  |
Jim Pendleton
Messages: 165 Registered: November 2011
|
Senior Member |
|
|
On Friday, March 14, 2014 7:17:51 AM UTC-6, David Fanning wrote:
> Folks,
>
>
>
> Perhaps because today is Pi Day:
>
>
>
> http://bit.ly/1lDkQi4
>
>
>
> Andrew Cools alerts me to an IDL problem of utmost importance. I refer,
>
> of course, to an inexplicable problem with IDL's version of Pi:
>
>
>
> IDL> print, !dpi, format='(f0.18)'
>
> 3.1415926535897931
>
>
>
> As everyone knows, the actual value of Pi is 3.1415926535897932. The
>
> last digit here is a "2", not a "1".
>
>
>
> http://bit.ly/1qCvycp
>
>
>
> Even ExelisVis itself realizes this, and puts the proper value in the
>
> new !Const system variable. What's up with this? Can we ever trust IDL
>
> again?
>
>
>
> Cheers,
>
>
>
> David
>
>
>
> P.S. Let's just say I'm off to get a piece of apple with my morning Joe.
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
David,
You might consider updating your Sky is Falling article to include a discussion on the new "implied print" behavior of IDL 8.3.
"For floating-point data types, unlike the PRINT procedure, Implied Print will automatically use the maximum number of digits of precision."
Will it prevent angry phone calls from researchers at 3 am? Probably not.
Jim P.
|
|
|