ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 21 Jul 2013 02:49:50 -0500Trigonometric simplification for distance on a spherehttp://ask.sagemath.org/question/10369/trigonometric-simplification-for-distance-on-a-sphere/These are two equivalent equations for distance on a sphere:
hav(x)=sin(x/2)^2
dist1(lat1, lat2, dLon)=2*asin(hav(lat1-lat2)+cos(lat1)*cos(lat2)*hav(dLon))
dist2(lat1, lat2, dLon)=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(dLon))
(According to http://www.movable-type.co.uk/scripts/latlong.html )
Indeed numerically they evaluate equal.
But why their difference does not simplify to 0?
diff(x,y,z)=dist1(x,y,z)-dist2(x,y,z)
diff.simplify_full()
Am I doing something wrong? Is there a way to have Sage prove the two forms are equivalent, or to transform one to another?
Thanks!
Sat, 20 Jul 2013 23:53:30 -0500http://ask.sagemath.org/question/10369/trigonometric-simplification-for-distance-on-a-sphere/Answer by Volker Braun for <p>These are two equivalent equations for distance on a sphere:</p>
<pre><code>hav(x)=sin(x/2)^2
dist1(lat1, lat2, dLon)=2*asin(hav(lat1-lat2)+cos(lat1)*cos(lat2)*hav(dLon))
dist2(lat1, lat2, dLon)=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(dLon))
</code></pre>
<p>(According to <a href="http://www.movable-type.co.uk/scripts/latlong.html">http://www.movable-type.co.uk/scripts...</a> )
Indeed numerically they evaluate equal.</p>
<p>But why their difference does not simplify to 0?</p>
<pre><code>diff(x,y,z)=dist1(x,y,z)-dist2(x,y,z)
diff.simplify_full()
</code></pre>
<p>Am I doing something wrong? Is there a way to have Sage prove the two forms are equivalent, or to transform one to another?</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/10369/trigonometric-simplification-for-distance-on-a-sphere/?answer=15260#post-id-15260Doesn't look like they are equal, typo?
sage: diff(0.1, 0.2, 0.3)
-0.264329471853371
Sun, 21 Jul 2013 02:49:50 -0500http://ask.sagemath.org/question/10369/trigonometric-simplification-for-distance-on-a-sphere/?answer=15260#post-id-15260