[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> floating point errors in MSWLogo



I'm trying again to post this message from Tony Gauvin
agauvin@umcs.maine.edu  Please reply to Tony's address or logo-l@gsn.org.
 
-John
--Message below re-posted by <jstclair@omsd.cerf.fred.org>
Date - Sat, 22 Nov 97 13:32 pdt
Reply-to - agauvin@umcs.maine.edu
>From - <jstclair@omsd.cerf.fred.org>
To - logo-l@gsn.org
Subject - floating point errors in MSWLogo
Please reply to agauvin@umcs.maine.edu or logo-l@gsn.org NOT me.  I'm
just re-posting Tony Gauvin's bounced message.
 
-John
From: "Anthony Gauvin" <agauvin@umcs.maine.edu>
To: logo-l@gsn.org

   I recently wrote a Molecular dynamics simulation in MSW LOGO and 
ran into a problem in how LOGO handles floating points numbers. One 
of the calculations in the program was 
 
    make "time sum :delta_t :time   

Adding a delta_t of  0.02 to a time of  0  1640 times gave me a 
value of time that was 32.7799999999995 , that is a small error but 
an error none the less. The problem is that with more iterations of the
program  the error grows exponential and after  a hour or so 
of running the simulations the values walk straight into the 
ether.
 This poses a severe limitations on the type 
and scale of models that can be constructed in LOGO. I realize that 
I'm probably pushing LOGO beyond it intended domain but you except 
the correct answer from a computer 

  As a test of this error, I wrote the following program 

to  atest 
(local "times "number)
make "number 0 
for [j 1 6 1 ]~
  [ make "times power 10 :j
    type [times -> ] 
    print :times  
    for[i 1 :times 1]~
        [make "number sum :number 0.01]
    type [result -> ]
    print :number 
    make "number 0
  ]  
end

  Running the program produces the same wrong results on two different 
machines (one WIN95, the other WINNT). 
********************************************************************

  Tony Gauvin                       (207) 581-1367          
  Graduate Assistant                 agauvin@umcs.maine.edu  
  109 Neville Hall                                         
  Dept of Computer Science                                 
  University of Maine                            
  Orono Me 04469                                           
 
          HTTP://www.umfk.maine.edu/hpage/tony/menu.htm    

******************************************************************************  
                                                     
                                                               


---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home