Ti-89 Haversine Formula

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

in kilometers:

img

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)
:Func
:Local r,d,l,a,b,c,e,f
:cos-1(-1)/180→r
:2*6372.8→d
:r*(yt-yz)→l
:r*xt→f
:r*xz→g
:sin(f)-sin(g)→a
:cos(l)*cos(f)-cos(g)→b
:sin(l)*cos(f)→c
:sin-1((a^2+b^2+c^2)^(1/2)/2)*d→e
:Return e*(π/180)
:EndFunc

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:
:eta(x,y,z,t)
:Func
:Local d,h,m,s,a,o,c,f
:dist(x,y,z,t)/(4.8)/24→d
:(d-floor(d))*24→h
:(h-floor(h))*60→m
:(m-floor(m))*60→s
:floor(d)→d
:floor(h)→h
:floor(m)→m
:floor(s)→s
:getTime()→a
:If s+a[3]≥60 Then
: mod(s+a[3],60)→s
: m+1→m
: Else
:  s+a[3]→s
:EndIf
:If m+a[2]≥60 Then
: mod(s+a[2],60)→m
: h+1→h
: Else
:  m+a[2]→m
:EndIf
:If h+a[1]≥24 Then
: mod(h+a[1],24)→h
: d+1→d
: Else
:  h+a[1]→h
:EndIf
:"G0 R:"→c
:"G0 R "→f
:If s<10 Then
: "0"&format(s,f)→s
: Else
:  format(s,f)→s
:EndIf
:If m<10 Then
: "0"&format(m,c)→m
: Else
:  format(m,c)
:EndIf
:" "&format(d,f)&"days @"&format(h,c)&m&s→o
:Return o
:EndFunc

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.