Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10213 > unrolled thread

Loss of precision

Started bysam.takoy@yahoo.com
First post2012-05-25 08:57 +0000
Last post2012-05-31 06:48 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Loss of precision sam.takoy@yahoo.com - 2012-05-25 08:57 +0000
    Re: Loss of precision danl@wolfram.com - 2012-05-26 09:14 +0000
      Re: Loss of precision Richard Fateman <fateman@cs.berkeley.edu> - 2012-05-29 09:50 +0000
        Re: Loss of precision danl@wolfram.com - 2012-05-31 06:48 +0000

#10213 — Loss of precision

Fromsam.takoy@yahoo.com
Date2012-05-25 08:57 +0000
SubjectLoss of precision
Message-ID<jpnhi8$qa4$1@smc.vnet.net>
Hi,

I understand intuitively why Sin[Large Number] cannot be computed too accurately. For example

Precision[Sin[SetPrecision[10^10, 100]]] = 89.75

We can I find an explanation of precisely why and how 100 becomes 89.75.

Many thanks in advance,

Sam

[toc] | [next] | [standalone]


#10215

Fromdanl@wolfram.com
Date2012-05-26 09:14 +0000
Message-ID<jpq6t7$6vs$1@smc.vnet.net>
In reply to#10213
On Friday, May 25, 2012 3:57:44 AM UTC-5, sam....@yahoo.com wrote:
> Hi,
>
> I understand intuitively why Sin[Large Number] cannot be computed too accurately. For example
>
> Precision[Sin[SetPrecision[10^10, 100]]] = 89.75
>
> We can I find an explanation of precisely why and how 100 becomes 89.75.
>
> Many thanks in advance,
>
> Sam

The most likely method used would involve first subtracting an appropriate multiple of Pi so as to bring the argument into a small range. I will illustrate with the range (-pi/4,pi/4).

In[20]:= rem = Mod[SetPrecision[10^10,100],Pi/2,-Pi/4];

In[21]:= {N[rem],Precision[rem],Precision[Sin[rem]]}

Out[21]= {-0.509231, 89.7069, 89.7469}

So we get the result you are seeing. Why is precision of the remainder around 89.7? That's a consequence of subtracting some integral multiple of pi/2 from a a number with magnitude 10^10 (that is, roughly digit number ten times the magnitude of our divisor). Consider multiplying both divisor and dividend by 10^90, so that the dividend, which was known to 100 places (90 to the right of the decimal) is now an integer. Once we subtract, we have at most 90 known digits. Slightly less, actually, because the result must be 10^90 times the result we get by not multiplying, and we know that has to be strictly less than pi/4, hence less than 1.

Daniel Lichtblau
Wolfram Research

[toc] | [prev] | [next] | [standalone]


#10255

FromRichard Fateman <fateman@cs.berkeley.edu>
Date2012-05-29 09:50 +0000
Message-ID<jq265m$6jt$1@smc.vnet.net>
In reply to#10215
On 5/26/2012 2:14 AM, danl@wolfram.com wrote:
> On Friday, May 25, 2012 3:57:44 AM UTC-5, sam....@yahoo.com wrote:
>> Hi,
>>
>> I understand intuitively why Sin[Large Number] cannot be computed too accurately. For example
>>
>> Precision[Sin[SetPrecision[10^10, 100]]] = 89.75
>>
>> We can I find an explanation of precisely why and how 100 becomes 89.75.

Sin[Large Number]  can be computed accurately to any desired number of 
digits.  Just as one can compute pi to any specified number of digits,
one can compute 10^10  or 10^100 modulo pi/2  to any specified number of
digits.

Daniel does describe what Mathematica does, which is hardly
mathematically or computationally inevitable.
RJF

[toc] | [prev] | [next] | [standalone]


#10290

Fromdanl@wolfram.com
Date2012-05-31 06:48 +0000
Message-ID<jq747l$qg0$1@smc.vnet.net>
In reply to#10255
On Tuesday, May 29, 2012 4:50:46 AM UTC-5, Richard Fateman wrote:
> On 5/26/2012 2:14 AM, danl@... wrote:
> > On Friday, May 25, 2012 3:57:44 AM UTC-5, sam....@yahoo.com wrote:
> >> Hi,
> >>
> >> I understand intuitively why Sin[Large Number] cannot be computed too accurately. For example
> >>
> >> Precision[Sin[SetPrecision[10^10, 100]]] = 89.75
> >>
> >> We can I find an explanation of precisely why and how 100 becomes 89.75.
>
> Sin[Large Number]  can be computed accurately to any desired number of
> digits.  Just as one can compute pi to any specified number of digits,
> one can compute 10^10  or 10^100 modulo pi/2  to any specified number of
> digits.
>
> Daniel does describe what Mathematica does, which is hardly
> mathematically or computationally inevitable.
> RJF

The operand in question was not 10^10, but rather a finite precision approximation thereto. Once you pin the precision of the operand to a finite value, you are subject to precision loss. If your convention is that, for example, .001 "really" means .001000000... then of course it is a different matter, because you have not pinned the precision to something finite. As you observe, tacitly, that's not what Mathematica does.

Daniel Lichtblau
Wolfram Research

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web