Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*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 1995

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

Search the Archive

Re: "unChopping" oddity

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg742] Re: "unChopping" oddity
  • From: rknapp (Robert Knapp)
  • Date: 12 Apr 1995 13:56:47 GMT
  • Organization: The Santa Fe Institute

In article <3md0p3$830 at news0.cybernetics.net> Preston Nichols <pdn at godel.math.cmu.edu> writes:

> Dear mathgroup:
> 
> I have encountered some strange behavior (session below) in which  
> Graphics3D seems to introduce 15 "new" significant digits in some  
> coordinates.  The session below is from version 2.2 for SPARC, but I  
> also got exactly the same behavior from version 2.0 for NeXT.
> 
> Can anyone else reproduce this?  What do you make of it?
> 
> Preston Nichols
> Department of Mathematics
> Carnegie Mellon University
> 
> ----------------------------------------------
> unix18 1 $ math
> Mathematica 2.2 for SPARC
> Copyright 1988-93 Wolfram Research, Inc.
>  -- Terminal graphics initialized --
> 
> In[1]:= myline = Line[{{0, 0, 0}, {1, 0, 0}}];
> 
> In[2]:= divide[{a_,b_}] := Table[(1-t) a + t b, {t,0,1,0.2}]
> 
> General::spell1:
>    Possible spelling error: new symbol name "divide"
>      is similar to existing symbol "Divide".
> 
> In[3]:= Map[divide,Graphics3D[myline], {2,2}]//InputForm
> 
> Out[3]//InputForm=
>   Graphics3D[Line[{{0, 0, 0}, {0.2, 0, 0}, {0.4, 0, 0},
>      {0.6000000000000001, 0, 0}, {0.8, 0, 0}, {1., 0, 0}}]]
> 
> In[4]:= Map[divide,myline]
> 
> Out[4]= Line[{{0, 0, 0}, {0.2, 0, 0}, {0.4, 0, 0}, {0.6, 0, 0},  
> {0.8, 0, 0}, {1., 0, 0}}]
> 
> In[5]:= %//Graphics3D//InputForm
> 
> Out[5]//InputForm=
>   Graphics3D[Line[{{0, 0, 0}, {0.2, 0, 0}, {0.4, 0, 0},
>      {0.6000000000000001, 0, 0}, {0.8, 0, 0}, {1., 0, 0}}]]
> 

This is not an effect of Graphics3D.  It arises from the interaction
of floating point numbers and InputForm.  Floating point arithmetic is
allowed to produce errors in the last bit.  Thus, if you added two
floating point numbers and expect 6/10, you may well get something
slightly different.  The idea of InputForm is to format the result in
way suitable for input to Mathematica such that this input would
prduce as close an expression as possible.  For floating point
numbers, this means giving all the digits.  

Here is an example (on a SPARC 5)


In[2]:= a = .2 + .4
 
Out[2]= 0.6
 
In[3]:= InputForm[a]
 
Out[3]//InputForm= 0.6000000000000001
 
In[4]:=  InputForm[b = 0.6]
 
Out[4]//InputForm= 0.6
 
In[5]:= a-b
 
                  -16
Out[5]= 1.11022 10
 

The point is that the output form rounds off the digits to make the
numbers easier to read.  However, if InputForm did this, one could get
unpredictable results from reinputting such output.  

Because the floating point processors are different on different
machines, you may not see the same output on your machine.


Rob Knapp
WRI


  • Prev by Date: Re: Word - Mathematica connection
  • Next by Date: Re: Time Series
  • Previous by thread: "unChopping" oddity
  • Next by thread: Re: "unChopping" oddity