4 ms·
You're absolutely right - in my experience the pythagorean theorem has less than ~50 meters difference from the Haversine formula for distances less than 20 mil
by smanek 17y ago
You're absolutely right - in my experience the pythagorean theorem has less than ~50 meters difference from the Haversine formula for distances less than 20 miles or so. In the actual code I use a simple heuristic to decide when to use which calculation.
Like I mentioned in the post, the distance function presented is a bit of a simplification I invented for pedagogical purposes (my goal was to examine languages, not geometry).
- jacquesm 17y agoCan you release the source data used for the benchmark? I'd like to compare it to C.
- smanek 17y agoThere is no source data. I just iterate through each latitude from -90 to 90 and each longitude from -180 to 180 in increments of 2.5 (for both the start and end). Check out the source code for any of the 5 examples (included in the post). If you'd like, post the code up somewhere and I'll be happy to run it on the same machine and post the results along with the rest.
- catch23 17y agoI also wonder why your java benchmark is slow. Java seems to be around 2-3x slower than C on average, this would make your optimized CL to be around 1.5x faster than C.
- mahmud 17y agoDefine "slower". Languages don't have a fixed "speed" relation between them. Performance varies between machine, language, problem, and implementation technique.
- igouy 17y agoIs any of that so remarkable that we should presume catch23 doesn't know? A charitable response would help catch23 understand what's different about this one problem from what we can sensibly presume as common experience - not Sun Java, JVM trig functions.
- revorad 17y agoFair enough. But then that raises a more important issue: you are showing Lisp is faster than more popular languages in a way that probably doesn't matter much. When I read the title, I was hoping this isn't some benchmarking or academic exercise, which does not have relevance for real applications. So I was delighted to read that this is something you use in your webapp, only to be disappointed again now. I don't mean to discourage you or be cynical. I love the fact that you are writing interesting articles on the practicalities of using Lisp with actual data behind it. So, keep up the good work. I look forward to more posts.
- Confusion 17y agoThe distance the swallow flies doesn't seem very interesting for many cases, where the terrain forces you to take a much longer route due to bridges, train track crossings, etc. Wouldn't you be better of using the Google maps API to return the length of an actual route to the target?