Calculate Lat Long distance

Ok, so I was never good at Trig. I am attempting to calculate the Great Circle Distance using the Haversine formula. The distance between 1° on each leg should be ~97 miles but alas, my formula is not. Any help by someone smarter than I would be appreciated.

Local La, Lc, Ld, LLat1, LLong1, LLat2, LLong2

LLat1 = 58
LLong1 = -134
LLat2 = 59
LLong2 = -135

La = sin((LLat1-LLat2)/2) * sin((LLat1-LLat2)/2)  +
cos(LLat1) * cos(LLat2) *
 sin((LLong1-LLong2)/2) * sin((LLong1-LLong2)/2)
     
Lc = 2 * ArcTan(Sqr(La) ÷ Sqr(1-La))

Ld = 3963 * Lc

Message Pattern(Ld,"###,.##")

I think the problem is with your expectations, not your code. 97 miles would be about right for 1° legs near the equator, but at the latitudes you are using in your example, it would be closer to 78. The lines of latitude will be about 69 miles apart, for a 1° difference, wherever they occur, but longitude lines get closer together the farther you get from the equator. At 58.5° latitude, they are about 36 miles apart.

OK. I do see a problem. By default the sin( and cos( functions use radians, not degrees. You need to include a degree statement to get it to switch, or you can leave it that way, and convert degrees to radians.

radians = degrees*(π/180)

The arctan( function will use radians no matter what, but that’s fine, because that’s what you want here.

Yep, it was that darn radian thing. Working at 0°, 0° also helps. This does work with an answer of 97.81 miles. Thanks Dave.

Local La, Lc, Ld, LLat1, LLong1, LLat2, LLong2

LLat1 = 0
LLong1 = -0
LLat2 = 1
LLong2 = 1

Degree

La = sin((LLat1-LLat2)/2) * sin((LLat1-LLat2)/2)  +
cos(LLat1) * cos(LLat2) *
 sin((LLong1-LLong2)/2) * sin((LLong1-LLong2)/2)
 
Lc = 2 * ArcTan(Sqr(La) ÷ Sqr(1-La))

Ld = 3963 * Lc

Message Pattern(Ld,"##,.##")

Robert, I have a suite of navigation procedures in the Database Exchange - called CustomNavigations. These should do anything you want without bothering with the hassles of spherical trigonometry.