[Date Index]
[Thread Index]
[Author Index]
Re: Would you post this Mathematica question to news group for me, please?
*To*: MathGroup at yoda.physics.unc.edu
*Subject*: Re: Would you post this Mathematica question to news group for me, please?
*From*: jacobson at cello.hpl.hp.com
*Date*: Mon, 06 Jul 92 09:20:16 -0700
andrew at ll.mit.edu (Andrew Hecht) writes:
> I have a problem with mathematica, version 2.0 (on NeXT): When I
> perform the following iteration using numbers with high precision, I
> get erroneous results. For example, with
>
> a =
> 3.750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
>
> and
>
> t = a/2
>
> and using the following iteration technique:
>
> x = t; Do[Print[x]; x = a x - x^2 ,{140}] ; N[x,80]
>
> the results for the 135th through 140th iteration are
>
> 3.0, 2.0, 0.0, 0.0
>
You have encounted the infamous ratcheting precision problem.
It is instructive to note what is happening to the accuracy at each
step.
In[1]:= a=SetAccuracy[3.5,100]
Out[1]= 3.5
In[10]:= x=SetAccuracy[2.5,30];Do[Print[{x,Accuracy[x]}];x=a x - x^2,{50}]
{2.5, 30}
{2.5, 29}
{2.5, 28}
{2.5, 27}
{2.5, 26}
{2.5, 25}
{2.5, 24}
{2.5, 23}
{2.5, 23}
{2.5, 22}
{2.5, 21}
{2.5, 20}
{2.5, 19}
{2.5, 18}
{2.5, 17}
{2.5, 16}
{2.5, 15}
{2.5, 14}
{2.5, 13}
{2.5, 12}
{2.5, 11}
{2.5, 10}
{2.5, 10}
{2.5, 9}
{2.5, 8}
{2.5, 7}
{2.5, 6}
{2.5, 5}
{2.5, 4}
{2.5, 3}
{2.5, 2}
{2.5, 1}
{3., 0}
{0., 0}
{0., -1}
{0., -2}
{0., -5}
{0., -10}
{0., -20}
{0., -39}
{0., -78}
{0., -157}
{0., -313}
{0., -626}
{0., -1252}
{0., -2505}
{0., -5009}
{0., -10019}
{0., -20038}
{0., -40075}
Mathematica's problem is that it has entangled two subtlely different
ideas all under the name of precision. One is an estimate of the
error that might be in a calculation. The other is the number of
digits to represent the data. For the first notion, it assumes that
at every addition/subtraction, the errors in each operand are
independent, and might combine in a worst-case way. It then uses this
to estimate the precision of the result. However, in many
calculations, both terms derive from the same varibles (x, in the
example), and if one is off a little, the other is off a little in the
same direction, so the errors in fact cancel rather than reinforce
each other. In fact, in interative calculations, we don't care about
error based on the original value, as the result is getting more and
more accurate, not less and less accurate with each iteration. But
Mathematica does not know this and lowers the precision (first
definition) with each iteration. This is not a bug, but just a
natural result of such a system. But, and this is a fundamental
mistake, I believe, Mathematica links these two notions of precision,
so when it sees a lower precision (first definition) it then throws
away digits of representation (making the second notion of precision
match the first).
Fortunately, you can keep Mathematica from doing this by setting the
variable $MinPrecision:
In[12]:= x=SetAccuracy[2.5,30];\
Block[{$MinPrecision=50},Do[Print[{x,Accuracy[x]}];x=a x - x^2,{50}]]
{2.5, 50}
{2.5, 50}
{2.5, 50}
...
I am writing an article on this phenomona for the Mathematica
Journal. The galleys just arrived Friday, so it should be off the
presses soon.
-- David Jacobson
Prev by Date:
**ftp instructions for Project CALC notebooks.**
Next by Date:
**Re: Would you post this Mathematica question to news group for me, please?**
Previous by thread:
**Re: Would you post this Mathematica question to news group for me, please?**
Next by thread:
**Re: Would you post this Mathematica question to news group for me, please?**
| |