Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Some comments:</p> <ul> <li><p><strong>You need to specify the range and the accuracy requirements of your computation.</strong> Range and accuracy are <em>extremely important</em> in determining what approach you use to calculate cosines. In addition, the pythagorean approximation you posted works well if the relative differences in latitude and longitude are small compared to the angular distance to the pole. Your pseudo-pythagorean algorithm won't work well at high latitudes if the latitudes aren't close together. (e.g. with latitude 43.001 and 43.002 it would work well, but not at 89.961 and 89.962)</p></li> <li><p><strong>Longitudes need to be calculated in view of their circularness</strong> -- Your algorithm will fail around the international date line, but that can be easily remedied by taking the longitudinal difference symmetric-modulo 360, where <code>smod(x,m) = mod(x+m/2,m)-m/2</code>. (e.g. -179.5 - +179.5 = -359 degrees, but if you compute <code>smod(-359,360)</code> you get +1 degrees.)</p></li> <li><p><strong>At design time, make good use of your PC.</strong> You have a very powerful calculator available, and you could evaluate for a large # of test points the high-precision answer and your approximation, and see how they differ, to evaluate accuracy. If you deduce a pattern in this information, you could use it to make a 2nd-order approximation to increase accuracy.</p></li> </ul> <hr> <p><em>update</em>: You state that your range/accuracy requirements are +/-60 degrees (no advantage in reducing range in one hemisphere) and 1% accuracy. A good approximation of cos(x), with x in degrees, within this range is c<sub>2</sub>(x) = 0.9942 - 1.39*10<sup>-4</sup> * x<sup>2</sup> = 0.9942 - (0.01179x)<sup>2</sup>; its error over this range has a maximum value of 0.006. </p> <p>If you want better accuracy use a 4th degree polynomial (c<sub>4</sub>(x) = 0.999945-(0.01233015x)<sup>2</sup>+(0.007778x)<sup>4</sup> has a maximum error over this range of less than 6x10<sup>-5</sup>, but is much more sensitive to parameter errors and arithmetic errors) or split into multiple ranges.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload