MathGroup Archive 2006

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

Search the Archive

Re: Mathematica bugs?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67321] Re: Mathematica bugs?
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sun, 18 Jun 2006 05:13:13 -0400 (EDT)
  • References: <e70f29$rf4$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Yaroslav Bulatov schrieb:
> When I run the following line
> x = Pi/4; For[i = 0, i < 56, i += 1, x = 2*Abs[x - 1/2]]; N[x]
> I get
> 3.
> 
> But x should always stay between 0 and 1, why do I get 3?
> 
> Also
> x = Pi/4; For[i = 0, i < 50, i += 1, x = 2*Abs[x - 1/2]]; N[Log[x]]
> gives me
> Indeterminate
> 
> How can I get an indeterminate here?
> 
Hi Yaroslav,

each multiplication which 2 is a binary left shift of the multiplicand.

For iter56 = Nest[2*Abs[#1 - 1/2] & , Pi/4, 56];
Simplify[iter56]
   56593902016227523 - 18014398509481984*Pi

you'll need about 56 bit to represent each of the summands:

Ceiling[Log[2, Abs /@ List @@ %]]
   {56, 56}

compare this to
Log[2, 10]*$MachinePrecision
   53.

Therefore you get an unreliable result using machine arithmetic:

N[iter56]
   3.

Using multiple prec. arithmetic, you'll get

N[iter56, 10]
   0.7938724527

Using insufficient precision leads also to:

logiter50 = Log[Nest[2*Abs[#1 - 1/2] & , Pi/4, 50]];
Simplify[logiter50]
   Log[-884279719003555 + 281474976710656*Pi]

N[logiter50[[1]]]
   0.

and therefore

N[logiter50]
   Indeterminate

but:
N[logiter50, 16]
   -3.367644345831603

hth,
  Peter


  • Prev by Date: Re: Problem with derivate of product
  • Next by Date: Re: Mathematica bugs?
  • Previous by thread: Re: Mathematica bugs?
  • Next by thread: Re: Mathematica bugs?