I've often wondered about trying Maple (any good?).
Anyway, here is a reply from Wolfram tech support, turns out I wasn't
using Mathematica correctly (a common occurrence with me, not a simple
app to use). Os other were correct, 0.036 is not base-2
representable, and this explains the integer round-down "error" first
reported in this thread.
======
I believe Mathematica is working correctly.
As specified in help of RealDigits, RealDigits[x]normally returns a list of
digits whose length is equal to Precision[x].
Please use the correct precision.
RealDigits[0.036`100, 2, 100]
returns:
{{1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0,
0,
1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1,
1,
1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0,
1,
1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1,
1,
0, 0, 1}, -4}
On 7/28/06, Charles Yeomans <[EMAIL PROTECTED]> wrote:
Shouldn't you be using Maple?
Charles Yeomans
On Jul 28, 2006, at 3:12 PM, Peter K. Stys wrote:
> Good point Michael. It is disconcerting that Mathematica reports 0's
> when in fact the values are unknown. I guess you can't even trust the
> king of math programs.
>
> Cheers,
> Peter.
>
>
> Tho looking at the result of RealDigits[0.036,2,100], I infer that
> 0.036 is
>
> On 7/28/06, Michael Sharpe <[EMAIL PROTECTED]> wrote:
>> Peter,
>>
>> Mathematica is misleading you here. At least in recent versions (I'm
>> using 5.2), the last 48 positions are not 0, but are Indeterminate,
>> indicating that the precision you requested goes beyond the numerical
>> precision in the floating point number .036. The only numbers capable
>> of an exact finite binary representation are those whose fractional
>> representation as m/n (ie, all common factors removed) have n as a
>> power of 2. As 36/1000 reduces to 9/250, and 250 is not a power of 2.
>> In your first example, where you compute N[72/1000*750,100], what you
>> are observing is the ability of Mathematica to do exact arithmetic
>> calculations, not using any internal representation as a floating
>> point number, at least when the number you enter is not manifestly
>> approximate.
>>
>> Michael
>>
>> > Subject: Re: Re: Math Error?
>> > From: "Peter K. Stys" <[EMAIL PROTECTED]>
>> > Date: Fri, 28 Jul 2006 12:35:56 -0400
>> >
>> > On 7/28/06, Norman Palardy <[EMAIL PROTECTED]>
>> wrote:
>> >>
>> >> On Jul 28, 2006, at 8:53 AM, Peter K. Stys wrote:
>> >>
>> >>>
>> >>> In[26]:= N[72/2000*750,100]
>> >>>
>> >>> Out[26]=
>> >>>
>> 27.00000000000000000000000000000000000000000000000000000000000000000
>> >>> 00
>> >>> 0000000000000000000000000000000
>> >>>
>> >>> In[27]:= N[72/2000*750]
>> >>>
>> >>> Out[27]= 27.
>> >>>
>> >>> Still suggests all these numbers and intermediate results are
>> >>> representable exactly at machine precision.
>> >>
>> >> I'm quite certain that 72/2000 is not.
>> >> Write it as the simple sum of powers of 2 and you find the
>> problem.
>> >> 72/2000 = 2^-2 + 2^-4 + 2^-5 + 2^-6 + 2^-11 + 2^-15 ..... and
>> so on
>> >> and you never get exactly the result you get from 72/2000.
>> >> In the machine all you have is powers of 2
>> >>
>> >>
>> >
>> > Actually we're both right and wrong:
>> >
>> > In[55]:=RealDigits[0.036,2,100]
>> >
>> > Out[55]=
>> >
>> {{1,0,0,1,0,0,1,1,0,1,1,1,0,1,0,0,1,0,1,1,1,1,0,0,0,1,1,0,1,0,1,0,0,1
>> ,
>> > 1,1,1,
>> >
>> >
>> 1,1,0,1,1,1,1,1,0,0,1,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>> ,
>> > 0,
>> > 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},-4}
>> >
>> > Shows that 0.036 can be represented exactly in binary, but
>> requires 51
>> > significant digits (if I counted correctly to the last 1). So
>> with a
>> > 64 bit double, it probably just missed the # of digits in the
>> mantissa
>> > to represent 0.036 exactly.
>> > Nuf time wasted on this, just a curiosity.
>> >
>> > P.
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives of this list here:
>> <http://support.realsoftware.com/listarchives/lists.html>
>>
>
>
> --
> ----------------------------------------------------------------------
> ---------
> Peter K. Stys, MD
> Professor of Medicine(Neurology), Senior Scientist
> Ottawa Health Research Institute, Div. of Neuroscience
> Ottawa Hospital / University of Ottawa
> Ontario, CANADA
> tel: (613)761-5444
> fax: (613)761-5330
> http://www.ohri.ca/profiles/stys.asp
> ----------------------------------------------------------------------
> ---------
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
--
-------------------------------------------------------------------------------
Peter K. Stys, MD
Professor of Medicine(Neurology), Senior Scientist
Ottawa Health Research Institute, Div. of Neuroscience
Ottawa Hospital / University of Ottawa
Ontario, CANADA
tel: (613)761-5444
fax: (613)761-5330
http://www.ohri.ca/profiles/stys.asp
-------------------------------------------------------------------------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>