MathGroup Archive 2001

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

Search the Archive

RE: FractionalPart

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31243] RE: [mg31232] FractionalPart
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 23 Oct 2001 04:53:21 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Juan,

It is just the effects of machine precision arithmetic. For example, with a
= 3.

Exp[0.5*Log[3^2]]
FullForm[%]
3.
3.0000000000000004`

so there is a fractional part. On the other hand, if you use exact
calculation:

Exp[(1/2)*Log[Range[9]^2]]
FractionalPart[%]
{1, 2, 3, 4, 5, 6, 7, 8, 9}
{0, 0, 0, 0, 0, 0, 0, 0, 0}

Whenever you use a machine precision number (0.5 instead of 1/2) in an
expression, it forces the entire expression to be calculated with machine
precision numbers. Check out Section 3.1 in The Mathematica Book for
Mathematica's various representations of numbers. (Also, machine precision
numbers only display to 6 places unless you change the setting in Option
Inspector, or use NumberForm.)

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



> From: Juan [mailto:erfa11 at hotmail.com]
To: mathgroup at smc.vnet.net
>
> Hello.
> I am new in Mathematica(also in english), and I have this question:
> I would like to know the behavior of the function FractionalPart.
> See here:
>
> In[1]:= a=Range[9]^2
> Out[1]= {1,4,9,16,25,36,49,64,81}
>
> In[2]:= x=Exp[.5 Log[a]]
> Out[2]= {1,2.,3.,4.,5.,6.,7.,8.,9.}
>
> In[3]:= FractionalPart[x]
> Out[3]= {0,0.,4.444089x10^-16,0.,0.,1.,0.,0.,1.,1.77639x10^-15}
>
> But it shoud be 0., all of them,no?
>
> Thanks. Juan
>




  • Prev by Date: Re: FractionalPart
  • Next by Date: Re: FractionalPart
  • Previous by thread: Re: FractionalPart
  • Next by thread: How to simplify this routine which is able to export data into TXT file?