Confused by Clojure floating-point differences (compared to other languages)

2014-02-05 Thread Glen Fraser
(sorry if you received an earlier mail from me that was half-formed, I hit send by accident) Hi there, I'm quite new to Clojure, and was trying to do some very simple benchmarking with other languages. I was surprised by the floating-point results I got, which differed (for the same calculatio

Re: Confused by Clojure floating-point differences (compared to other languages)

2014-02-05 Thread Glen Fraser
t; Jon. > > > > *From:* clo...@googlegroups.com [mailto: > clo...@googlegroups.com ] *On Behalf Of *Glen Fraser > *Sent:* 05 February 2014 13:17 > *To:* clo...@googlegroups.com > *Subject:* Confused by Clojure floating-point differences (compared to > other languages) >

Re: Confused by Clojure floating-point differences (compared to other languages)

2014-02-05 Thread Glen Fraser
4, at 6:22 PM, Konrad Hinsen wrote: > --On 5 Feb 2014 05:17:13 -0800 Glen Fraser wrote: > >> My benchmark iteratively runs a function 100M times: g(x) <-- sin(2.3x) + >> cos(3.7x), starting with x of 0. > > A quick look at the series you are computing suggests th

Re: Confused by Clojure floating-point differences (compared to other languages)

2014-02-05 Thread Glen Fraser
its but I would mention that it would > possibly make a significant performance difference if you added this to your > code: > > (set! *unchecked-math* true) > > > > On Wednesday, February 5, 2014 7:17:13 AM UTC-6, Glen Fraser wrote: > (sorry if you received an e

Re: Confused by Clojure floating-point differences (compared to other languages)

2014-02-05 Thread Glen Fraser
(recur (dec i) (g x)) x))) > > This is nearly 50% faster than the original version on my machine. Note that > x is bound to 0.0 in the loop, which allows the optimized g to be invoked. > > > On Wed, Feb 5, 2014 at 4:41 PM, Glen Fraser wrote: > Thanks to both of you for th

Re: Confused by Clojure floating-point differences (compared to other languages)

2014-02-06 Thread Glen Fraser
ackOverflow question. > > As most probably all your versions use the same native libraries or hardware > instructions, the differences must rely either on float configuration > parameters, like rounding modes, or the order of operations. > > On Wednesday, February 5, 2014 1