by ZitchDog · 17y ago · 0 comments
user=> (type (/ 1 3))
clojure.lang.Ratio
user=> (* (/ 1 3) 3)
1
I'd really like to see an arithmetic macro for clojure to allow infix notation, constants, and lazy evaluation. Something like (arith 2m/s^2) would be crazy awesome.I don't see why would you want to stay away from floats, using rationals isn't going to magically fix the numerical errors from approximating derivatives and such.
I believe they develop an automatic differentiation routine in SICM that will actually allow you to make a pretty good planetary motion simulator, i.e one that won't just go horribly wrong if you run it for a few thousand years.
Of course if you're really interested/mathematically inclined one of the best ways to simulate Hamiltonian systems is via iterated maps, not unlike what was in the article. A good (but quite hard) ref to this is "simulating hamiltonian dynamics" by Leimkuhler and Reich.