Re: Table through zero...strange

• To: mathgroup at smc.vnet.net
• Subject: [mg67033] Re: Table through zero...strange
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Wed, 7 Jun 2006 05:10:19 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <e63mqt\$kqd\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```leptonic wrote:
> Hello,
>
> When i type in Mathematica (version 4) Table[x, {x, -0.1, 0, 0.02}]
>
> it gives me {-0.1, -0.08, -0.06, -0.04, -0.02, -3.46945 x 10-18]}
> but for example Table[x, {x, -0.1, 0, 0.05}] will give a reasonable
> {-0.1, -0.05, 0.}.

This is due to the arithmetic used for the computation:
machine-precision in this case. The last entry is so close to zero that
it can be deemed as equivalent to zero; use the built-in function Chop
[1] to get the desired result {see In[1] and In[2]) or you may also use
exact arithmetic by typing exact numbers as in inputs In[3] and In[4].

In[1]:=
Table[Chop@x, {x, -0.1, 0, 0.02}]

Out[1]=
{-0.1, -0.08, -0.06, -0.04, -0.02, 0}

In[2]:=
Chop@Table[x, {x, -0.1, 0, 0.02}]

Out[2]=
{-0.1, -0.08, -0.06, -0.04, -0.02, 0}

In[3]:=
Table[x, {x, -1/10, 0, 2/100}]

Out[3]=
1      2      3      1      1
{-(--), -(--), -(--), -(--), -(--), 0}
10     25     50     25     50

In[4]:=
N@Table[x, {x, -1/10, 0, 2/100}]

Out[4]=
{-0.1, -0.08, -0.06, -0.04, -0.02, 0.}

HTH,
Jean-Marc

[1]: http://documents.wolfram.com/mathematica/functions/Chop

```

• Prev by Date: Filemaker JDBC Mathematica5.2
• Next by Date: Re: Re: How to generate sections, subsections, etc. automatically?
• Previous by thread: Re: Table through zero...strange