do -- compute the distance between places using the Haversine formula local function distance( th1Deg : number, ph1Deg : number, th2Deg : number, ph2Deg : number ) : number local ph1 = math.rad( ph1Deg - ph2Deg ) local th1 = math.rad( th1Deg ) local th2 = math.rad( th2Deg ) local dz = math.sin( th1 ) - math.sin( th2 ) local dx = math.cos( ph1 ) * math.cos( th1 ) - math.cos( th2 ) local dy = math.sin( ph1 ) * math.cos( th1 ) return math.asin( math.sqrt( dx * dx + dy * dy + dz * dz ) / 2 ) * 2 * 6371 end do local d = distance( 36.12, -86.67, 33.94, -118.4 ) local km , mi = math.round( d ), math.round( d / 1.609344 ) print( $"distance: {km} km ({mi} mi.)" ) end end