Welcome to the NavList Message Boards.


A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Wayfinding

Compose Your Message

Add Images & Files
    Re: Cosine vs haversine formulas
    From: Frank Reed
    Date: 2017 Nov 19, 13:32 -0800

    Bob, You wrote:
    "the link gave me half of the root answer I was looking for but did explicitly spell out which was why was the haversine formula developed in the first place and does it still have an advantage"

    The author of that web page is a guy named Chris Veness. He is neither a mathematician nor a historian of science or navigation. What you have picked up from that website is useful information, but it's only a rough outline of the history and the math.

    I'll expand a bit on my comments on the modern history in my earlier post. The haversine technique was still useful in 1984 when Roger Sinnott first wrote about it in that brief note for Sky & Telescope (Greetings, Roger, by the way! I notice you signed up for NavList emails last night). At that point in time, common desktop PCs had very limited chip-level math computation capabilities. If you bought a typical inexpensive PC, like the infamous "Trash 80", or more correctly, the TRS-80 (known at that time as a "PC clone", as many of you may recall), you could do scientific calculations including trigonometric calculations like the great circle calculation, but users were sometimes shocked to discover that a common scientific calculator could produce more accurate results. This is why such antiquated arithmetic as the haversine had a short window of opportunity. It allowed those early desktop computers to perform as well as common calculators. Most of the math on early PCs was done in software libraries, and it was limited to what was known as "single precision" in most cases. In those days, you had to pay up if you wanted better math and buy a special plug-in piece of hardware called a "math coprocessor". This enabled so-called "double precision" math and also much faster single precision math, and if that coprocessor was available, it wiped out the benefit that came from using the haversine algorithm. It was obvious that this math capability deserved to be on every computer, and as quickly as the economics of the market permitted, math or "floating point" coprocessors disappeared. As soon as Intel's 486 chips became widespread, which was by 1993 roughly, the game was done. The special instructions that were formerly found in the expensive coprocessor chip were moved onto the main CPU. And for the vast majority of computer users, that was the end of it --except for specialty applications on devices which did not have chip-level floating point math, like some early cell phones. Enter Chris Veness...

    Chris Veness, the creator of the website movable-type.co.uk, developed a popular repository of javascript code in the early days of the Internet. He wrote and published code for great circle distance and related calculations extolling the virtues of the haversine algorithm and referencing Roger Sinnott's article from 1984. You can read early examples of this code, dating back to 2002, at archive.org here. Veness was wrong to do this --the technique was already obsolete-- and in the summer of 2005, he admitted as much. There has been no real need for this variant on the great circle computation since about 1993 --nearly a quarter of a century ago. Veness also stated plainly back in those early days that he is "not a mathematician". Fair enough. If javascript had remained a minor scripting language, as it seemed to be at the beginning of the 21st century, Veness's code and his commentary on the subject would be unknown, but javascript exploded in popularity and it is now counted as a mature, flexible, world-class programming language. The archive at movable-type.co.uk grew in popularity with the language, and it remains highly rated. This popularity, unfortunately, has spread the incorrect belief that has some programmers "blathering" even in the year 2017. The Internet is like that. People believe what they read, and bad info fades slowly...

    You believe me, right? ;)

    Note: confusion can arise when folks talk about the mathematical/trig computation capabilities of a language. There is no specification on this in most languages. Rather it's the hardware and the associated interfaces that yield accurate numbers. In other words, these algorithms are not tied to javascript to any significant extent. And it's certainly possible to un-do the advantages of 21st century hardware. I am quite certain that someone out there has created a simple javascript-enabled web browser able to run on an old PC with an early 8086 processor (or equivalent). This would, of course, make all that old code relevant again. I tried just now to find something like that, but my search only yielded a sort of mirror universe: 8086 emulators running as virtual machines using javascript in modern web browsers.

    The history of "the" haversine in celestial navigation in the 19th and early 20th centuries is also burdened by confusion, and I'll try to get into that in a later post. 

    Frank Reed

    Browse Files

    Drop Files


    What is NavList?

    Join NavList

    (please, no nicknames or handles)
    Do you want to receive all group messages by email?
    Yes No

    You can also join by posting. Your first on-topic post automatically makes you a member.

    Posting Code

    Enter the email address associated with your NavList messages. Your posting code will be emailed to you immediately.

    Email Settings

    Posting Code:

    Custom Index

    Start date: (yyyymm dd)
    End date: (yyyymm dd)

    Visit this site
    Visit this site
    Visit this site
    Visit this site
    Visit this site
    Visit this site