Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Bug in calculating -3^49999.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66021] Re: [mg65989] Bug in calculating -3^49999.0
  • From: "Carl K. Woll" <carlw at wolfram.com>
  • Date: Thu, 27 Apr 2006 02:26:13 -0400 (EDT)
  • References: <200604260837.EAA02684@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

kowald at molgen.mpg.de wrote:
> Hello everybody,
> 
> I'm using Mathematica 5.1 under Win2k and I found a bug when I try to compute
> -3^49999. I get:
> 
> -3^49999 //N  =>  -3.85 * 10^23855          okay
> -3^49999.      =>  -3.85 * 10^23855          okay
> (-3)^49999.    =>  -3.85 * 10^23855 + 4.56*10^23844 i       wrong
> (-3)^49999     =>  -3.85 * 10^23855          okay
> 
> Is this a known problem?
> Is there a work around ?
> Obviously this is part of a more complicated calculation and so I
> cannot simply leave out the brackets.
> 
>  Many thanks,
> 
>                 Axel

Recall that a negative number to a noninteger power is not real. For 
your example, we have

(-3)^(49999.0)

and the exponent is not an integer, it is a machine real approximation 
to an integer. This real number has only 16 digits of precision, so it 
not only the real approximation to 49999, but it is the real 
approximation to infinitely many other numbers, including for example, 
49999+10^-12. Of course,

(-3)^(49999+10^-12) == (-3)^49999 * (-3)^(10^-12)

and (-3)^(10^-12) is not real.

One possible idea is to use extended precision real approximations:

In[2]:= ((-3))^49999`20

Out[2]= -3.85136543496863Ã?10^23855 + 0.Ã?10^23840 \[ImaginaryI]

You will still get an imaginary part, whose magnitude is related to the 
precision of your input, but it is easy to see that the imaginary part 
is probably 0. You can test whether the imaginary part is zero by:

In[3]:= Im[%2] == 0

Out[3]= True

Given that the imaginary part is zero, perhaps you can just take the 
real part.

Carl Woll
Wolfram Research


  • Prev by Date: Re: Object-Oriented Paradigm in Mathematica?
  • Next by Date: Re: Compile&Which
  • Previous by thread: Re: Bug in calculating -3^49999.0
  • Next by thread: Re: Bug in calculating -3^49999.0