MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

HairyPooter IV.75 cont.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24563] HairyPooter IV.75 cont.
  • From: William Boyd <william at kamaz.demon.co.uk>
  • Date: Mon, 24 Jul 2000 03:04:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

The story so far:

HairyPooter IV¾, in a desperate bid to save the world from Jake induced
hysteria, is locked in battle with loathsome The-Function-That-Will-Not-
Reveal-Its-Precision.

A preliminary skirmish, distinguished if nothing else for its
considerable intellectual honesty, has left our hero bruised and
confused, and forced him into consulting the Wolf Ram Oracle. 

They have replied with:

In[147]:=
firstSuggestion[n_Real, s_Integer, r_Real] :=With[ 
            {e = Log[1 - r*s/(n*(1 - r))]/Log[1 - r]},
            {"precision" -> Precision[e], Floor[e] + 1}
                 ]

firstSuggestion[1.0000000000000000000,635,0.0015723270440250000000]
firstSuggestion[1.0000000000000000000,635,0.0015723270440251000000]
firstSuggestion[1.0000000000000000000,635,0.0015723270440251500000]
firstSuggestion[1.0000000000000000000,635,0.0015723270440251570000]
firstSuggestion[1.0000000000000000000,635,0.0015723270440251572000]
firstSuggestion[1.0000000000000000000,635,0.0015723270440251572200]

Out[148]=
{precision -> 7, 19022}
Out[149]=
{precision -> 7, 19665}
Out[150]=
{precision -> 6, 20979}
Out[151]=
{precision -> 5, 23163}
Out[152]=
{precision -> 4, 24410}
Out[153]=
{precision -> 4, 25011}

and

secondSuggestion[n_Real, s_Integer, r_Real] := With[
        {n20=SetPrecision[n, 20], r20=SetPrecision[r,20]},
        Floor[Log[1-r20*s/(n20*(1-r20))]/Log[1-r20]] + 1
        ]
secondSuggestion[1.,635,0.001572327044025]
secondSuggestion[1.,635,0.0015723270440251]
secondSuggestion[1.,635,0.00157232704402515]
secondSuggestion[1.,635,0.001572327044025157]
secondSuggestion[1.,635,0.0015723270440251572]
secondSuggestion[1.,635,0.00157232704402515722]

19023
19665
20974
23522
24410
25011

The trouble is they don't agree! 

Now read on.

According to my respondent, the discrepancy appears to be an artefact
introduced by the fact of SetPrecision padding with machine bit zeros,
which is not the same as padding with denary zeros. 

This rather puts me off secondSuggestion. It also puts me off
firstSuggestion because it occurs to me that it must then be the case
that Precision is held in machine bits, which is then returned to
denary, and that itself will introduce a loss of precision. It can only
be sensible to round the result, in which case one can only trust
firstSuggestion when the reported precision is greater than the
precision for the result (by at least one)? 

Struggling more with all this, it dawns upon me that Mathematica is
healthily paranoid about Reals:

In[187]:=
aResult[r_]:= With[
                {e = Log[1 - 2 * r]/Log[1 - r]},
                {e, "precision" -> Precision[e]}
           ]

NumberForm[aResult[0.49999999999999999999]]


Out[188]//NumberForm=

NumberForm::sigz: 
    Requested number format may result in trailing zeros which are not 
significant digits.

{70. , precision -> 2}


reflecting a very proper distrust of quotients and differences, and I'm
just never going to get a more precise result so long as I use Reals.

Is that right? And incidentally where can I get some information about
how Mathematica calculates Precision under the ordinary arithmetical
operations: Uglification and Derision I can follow, but the other two
(wouldn't mind being reminded what they are as well) completely defeats
me. Not in The Book - (2nd edition, anyway): ought to be page 1 surely.


So, lightbulb, use Rationals instead. The whole point about the sequence
of ordinates is that it's supposed to be a limiting sequence of
rationals anyway .. oh dear, sorry.

In[161]:=
concludingResult[n_Real, s_Integer, r_Real] :=With[  
                      {nRat =  Floor[n * 10^20 ]/ 10^20, rRat =  Floor[r
* 10^20 ]/ 10^20},
            {e =Floor[N[Log[1 - rRat*s/(nRat*(1 - rRat))]/Log[1 -
rRat],50]], 
      "precision" -> Precision[e]}
                 ]

concludingResult[1.,635,0.001572327044025]
concludingResult[1.,635,0.0015723270440251]
concludingResult[1.,635,0.00157232704402515]
concludingResult[1.,635,0.001572327044025157]
concludingResult[1.,635,0.0015723270440251572]
concludingResult[1.,635,0.00157232704402515722]


Out[162]=
{19021, precision -> Infinity}
Out[163]=
{19665, precision -> Infinity}
Out[164]=
{20985, precision -> Infinity}
Out[165]=
{23623, precision -> Infinity}
Out[166]=
{24240, precision -> Infinity}
Out[167]=
{24641, precision -> Infinity}

which I take to be definitive. Is that right?

And if so, why is there so much disagreement with firstSuggestion?





-- 
William Boyd




  • Prev by Date: Re: A strange bug in Solve
  • Next by Date: Re: Mathematica 3.0: reliability close to LogZero?
  • Previous by thread: Problem using NIntegrate within FixedPoint
  • Next by thread: insect population dynamics