Ti-89 Haversine Formula

The distance from
New York: 40.71278, -74.00595
to Los Angeles: 34.05223, -118.2436

in kilometers:


This formula is to calculate, in kilometers, the distance between two GPS coordinate points by bird. I use the Haversine formula to write this ti89 function. Since my girlfriend and I are going on a hiking trip, we want to be able to easily calculate out distance with the aid of a GPS, and a known destination in decimal format. Since average hike speed is about 4.8 kilometers per hour (or 3 miles per hour). We should be able to calculate how much time it takes to arrive at our campground relative to the arc of the Earth.

This assumes your calculator is in decimal (not radians):
:dist(xt, yt, xz, yz)
:Local r,d,l,a,b,c,e,f
:Return e*(π/180)

Here is a good site to find the Haversine Formula in different languages

This next function uses the above Haversine distance function and the built-in clock on the ti-89 to calculate arrival time to your destination:
:Local d,h,m,s,a,o,c,f
:If s+a[3]≥60 Then
: mod(s+a[3],60)→s
: m+1→m
: Else
:  s+a[3]→s
:If m+a[2]≥60 Then
: mod(s+a[2],60)→m
: h+1→h
: Else
:  m+a[2]→m
:If h+a[1]≥24 Then
: mod(h+a[1],24)→h
: d+1→d
: Else
:  h+a[1]→h
:"G0 R:"→c
:"G0 R "→f
:If s<10 Then
: "0"&format(s,f)→s
: Else
:  format(s,f)→s
:If m<10 Then
: "0"&format(m,c)→m
: Else
:  format(m,c)
:" "&format(d,f)&"days @"&format(h,c)&m&s→o
:Return o

The eta formula outputs:

" 36 days @10:53:11 "

If we walked a straight line from New York to Los Angeles at 4.8 kilometers per hour (3 miles per hour) non stop, and we left at 5:48pm, we would arrive 36 days later, at 10:53:11 in the morning.