Talk:Haversine formula: Difference between revisions

respond to Eliasen
(Different results)
 
(respond to Eliasen)
 
(16 intermediate revisions by 8 users not shown)
Line 33:
2889.68
</pre>
 
:This might be due to the different values given for the rough radius of the Earth, in kilometers, for different examples. --[[User:Paddy3118|Paddy3118]] 19:22, 16 August 2012 (UTC)
 
-----
 
Some reasons probably are:
* using a different (mean) radius of the earth
* using a derived radius from the earth's circumference
* use of difference precisions
* use of different formulas for trigonometric functions
* use of smaller numbers via radian (or degree) reduction/normalization.
-- [[User:Gerard Schildberger|Gerard Schildberger]] 19:25, 16 August 2012 (UTC)
 
Apparently it's the two different values used for the eartH's radius: 6372.8 and 6371.0, respectively-
--[[User:Walterpachl|Walterpachl]] 20:14, 16 August 2012 (UTC)
 
:Right, “6371.0” is the authalic radius based on/extracted from surface area, while “6372.8” is an approximation of the radius of the average circumference (i.e., the average “great-elliptic” or “great-circle radius”), where the boundaries are the meridian (≈ 6367.45 km) and the equator (≈ 6378.14 km).
:See ''[http://math.wikia.com/wiki/Ellipsoidal_quadratic_mean_radius Ellipsoidal quadratic mean radius]''. [[User:Kaimbridge|<span style="border:1px solid green;color:#e55b3c; padding:2px;background:#fde0bc">~<font face="courier new bold" class="title" title="Kaimbridge M. GoldChild">Kaimbridge</font>~</span>]] 17:44, 19 August 2012 (UTC)
 
::Thank you for the excellent explanation. I'd still want that explanation in the task description
::and would advise programmers to use one specific value in order to get comparable results
::Maybe the one yielding a result of about 2887.26 km as this is the majority. --[[User:Walterpachl|Walterpachl]] 18:11, 19 August 2012 (UTC)
 
:::It's probably too late to ask for an update to the tasks. We know what causes the differences and the two results that are obtained from using the two radii, and have noted it here. --[[User:Paddy3118|Paddy3118]] 20:57, 19 August 2012 (UTC)
 
 
::::It's never too late:-) I suggest to MENTION these radii in the task and RECOMMEND one for future implementers
::::Was it you who said that it's difficult to create watertight task descriptions:-)
::::Thanks anyway --[[User:Walterpachl|Walterpachl]] 05:07, 20 August 2012 (UTC)
:::::''Recommend a radius for future implementors''. Mention both and then recommend one sounds good as it would leave the examples already there alone or allow them to be updated. Or would we want to force all the examples to use the one radius? (Is it that much of a problem? --[[User:Paddy3118|Paddy3118]] 07:26, 20 August 2012 (UTC)
:I have a sneaking suspicion that the fortran code c = 2*atan2(sqrt(a),sqrt(1-a)) is wrong. I can't prove it. Does anyone have a Fortran compiler handy?
 
I've change the recommended radius to the mean earth radius. This choice minimizes the RMS relative error and is consistent with the choice which conserves the volume and the area of the earth (in the limit of small flattening). The previous recommendation was the "quadratic mean radius". Unfortunately, its derivation contained a flaw in the way azimuths were sampled, so it does not minimize any reasonable error metric. For an extended discussion see this [https://en.wikipedia.org/wiki/Talk:Great-circle_distance/Archive_1 archived talk page for Great-circle distances] on Wikipedia. [[User:Cffk|cffk]] ([[User talk:Cffk|talk]]) 22:48, 10 February 2014 (UTC)
 
:With 53 examples, it is too late to make most radical changes. Try appending a recommendation instead. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 07:55, 11 February 2014 (UTC)
 
If you want to use a high-accuracy function for the *actual* distance on earth's geoid, you should probably look at the [https://rosettacode.org/wiki/Haversine_formula#Frink Frink entry]. [https://frinklang.org/fsp/colorize.fsp?f=navigation.frink Frink's navigation library] contains high-accuracy calculations of distances on earth's ellipsoid. These calculations are due to:
 
"Direct and Inverse Solutions of Geodesics on the Ellipsoid with Application
of Nested Equations", T.Vincenty, ''Survey Review XXII'', 176, April 1975.
http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
 
There is also a slightly higher-accuracy algorithm (if you want nanometer accuracy instead of sub-millimeter accuracy):
"Algorithms for geodesics", Charles F. F. Karney, ''Journal of Geodesy'', January 2013, Volume 87, Issue 1, pp 43-55
http://link.springer.com/article/10.1007%2Fs00190-012-0578-z
 
In short, a most accurate distance on the Earth's geoid, given the WGS84 geoid, is:
 
2892.776957 km
--[[User:Eliasen|Eliasen]] ([[User talk:Eliasen|talk]]) 07:35, 24 April 2022 (UTC)
 
: But at that point you're no longer using the Haversine formula. The task is not to compute the most accurate distance possible between two points on the surface of the Earth. -- [[User:Markjreed|Markjreed]] ([[User talk:Markjreed|talk]]) 22:38, 24 April 2022 (UTC)
 
: Additionally, these implementations are very close. The [[Haversine_formula#bc|bc implementation]] with WGS84 ellipsoid¹ is guaranteed to have less than ¼% of error (0.21877% from your given number). This is “good enough” for something this easy to port to various programming languages that might not have enough functionality to support the “better” maths. 【¹) Though I switched to the Astronomical Almanac 2021 radius of i=6378136.600, x stays the same, in my “current” version, which is supposedly more precise. It’s very very close to WGS84, still.】 [[User:Mirabilos|mirabilos]] ([[User talk:Mirabilos|talk]]) 01:00, 25 April 2022 (UTC)
Anonymous user