> 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). This is no problem of LOGO but a problem of computer mathematics. 0.02 cannot be translated into binary code without rounding. So if you add this number several times the error gets really important. Kind regards Anthony Haase (This list has helped me so much during the few days that I can read it. I'm glad that I could help too a little bit.) --------------------------------------------------------------- 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