[Date Index]
[Thread Index]
[Author Index]
Re: Numerical accuracy/precision - this is a bug or a feature?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg119998] Re: Numerical accuracy/precision - this is a bug or a feature?
*From*: "Kevin J. McCann" <kjm at KevinMcCann.com>
*Date*: Mon, 4 Jul 2011 07:14:03 -0400 (EDT)
*References*: <ius5op$2g7$1@smc.vnet.net>
The answer to this puzzle is that the N[2.0,20] is 2.0, not
2.00000000... Try N[2,20] and all is well. I think that when you put 2.0
in you have already limited yourself to machine precision, and N[2.0,20]
is then just machine accuracy.
Kevin
On 7/4/2011 6:47 AM, slawek wrote:
> Let Mathematica (6.x, 7.x) compute quite a simple product
>
> In[1]:= N[N[2.0, 20] * N[Sqrt[2] , 20], 20]
>
> Out[1]= 2.82843
>
> This is a bug.
>
> Why?
>
> Now we analyze it in details:
>
> 1. N[2.0,20] should give 2 with accuracy/precision/whatsever about 20
> decimal digits, i.e. 2.00000000000000000000
>
> 2. Sqrt[2] should give... Sqrt[2]
>
> 3. N[Sqrt[2]] should give 1.4142135623730950488 (this is copy-paste from
> Mathematica output to N[Sqrt[2]] )
>
> 4. The product 2.00000000000000000000 * 1.4142135623730950488 is
> 2.8284271247461900976 (again copy-paste)
>
> 5. BUT THE RESULT OF N[2.0, 20] * N[Sqrt[2] , 20] "truncated to 20 digits"
> is Out[1]= 2.82843
>
> Where are missing digits?!
>
> slawek
>
>
>
>
Prev by Date:
**Re: Insoluble marbles-in-urn problem?**
Next by Date:
**Re: Numerical accuracy/precision - this is a bug or a feature?**
Previous by thread:
**Numerical accuracy/precision - this is a bug or a feature?**
Next by thread:
**Re: Numerical accuracy/precision - this is a bug or a feature?**
| |