# Calculate distance travelled

**URL:** <https://community.thunkable.com/t/calculate-distance-travelled/565278>\
**Category:** Questions about Thunkable X\
**Created:** [May 11, 2020, 8:23am UTC](https://community.thunkable.com/t/calculate-distance-travelled/565278 "2020-05-11T08:23:20Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [September 8, 2020, 2:01am UTC](https://community.thunkable.com/t/calculate-distance-travelled/565278/14 "2020-09-08T02:01:23Z")

</div>

HAVERSINE ALTERNATIVE USING SPHERICAL LAW OF COSINES

it has come to my attention that i had mistakenly posted a thunkable solution for calculating distance between 2 points on the globe as the haversine formula (i even mispelled it as havesine!). i went back to my sources and discovered that what i had posted was a simpler way of computing the same distance using the spherical laws of cosines. the results may be off by a mile or so when compared to the haversine formula, but they’re mostly pretty close.

in fact, it can be expressed as a oneliner (without using a square function, or square root, or atan that are present in haversine):

D=ACOS(SIN(LAT1)\*SIN(LAT2)+COS(LAT1)\*COS(LAT2)\*COS(LON2-LON1))\*3961

where 3961 is the radius of the earth in miles (use the equivalent 6373 in kilometers). Also note that the difference between the LAT values is not part of the formula.

when i was playing with this in may i also noticed that the trigonometric functions in thunkable rely on angles being expressed in degrees. hence where you expect radians, thunkable actually needs degrees. it’s an important thing to remember.

here’s the link to the new version (remember it’s a haversine replacement!):  
[https://x.thunkable.com/copy/0a769291e941b464b63f836aa39930e1](https://x.thunkable.com/copy/0a769291e941b464b63f836aa39930e1)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f2e27adfb8b330caea7f4b35a0d36831f351023.png)

if anyone is interested, i’ve included link to an exerciser spreadsheet. just enter the lat/ long points at top and get the result in cell marked DISTANCE

> **[distcalc\_sphere](https://docs.google.com/spreadsheets/d/1uHVBqWjbnjroO-Z4FoCefKIfTmerCSZYCfuaLEh-_Gw/edit?usp=sharing)**
>
> Sheet1
> 
> LAT,LONG,https://www.geeksforgeeks.org/haversine-formula-to-find-distance-between-two-points-on-a-sphere/
> POINT1,38.898819,-77.03669,https://notunreasonable.com/2011/09/19/latlon-distance-formula-in-excel-haversine-and-spherical-law-of-cosine...

---

_[View the full topic](https://community.thunkable.com/t/calculate-distance-travelled/565278)._
