# Math Help - Formula not working

**URL:** https://community.thunkable.com/t/math-help-formula-not-working/917769
**Category:** Questions about Thunkable X
**Created:** [October 20, 2020, 6:51pm UTC](https://community.thunkable.com/t/math-help-formula-not-working/917769 "2020-10-20T18:51:06Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![kareem](https://avatars.discourse-cdn.com/v4/letter/k/9de053/32.png) [@kareem](https://community.thunkable.com/u/kareem)
#### Post date: [December 1, 2021, 10:44pm UTC](https://community.thunkable.com/t/math-help-formula-not-working/917769/15 "2021-12-01T22:44:54Z")

</div>

Hi guys, I know I’m like a year late but I got it to work! @drted’s api solution was great but network here in my country is quite slow and it would be a pain on bad days and even worse for a batch requests if I had to use a for loop. It works in degrees as of testing and you can see the blocks below as well a sample test I did. I double checked with radians in excel and it returned the same answer.

**TEST**

 ![Screen Shot 2021-12-02 at 00.20.01](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/8/685a4281b9691ab0bf3ee8e278af88f615604353.png)

**BLOCKS**

 ![Screen Shot 2021-12-02 at 00.20.34](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/d/9d6b0ed2b0e4b62800200cac49ddd8f353cc1285.png)

The link to the project is [here](https://x.thunkable.com/copy/19aaec38b051798ff2ad14b77e577ed6). I would think everyone on this thread figured it out by now but if you didn’t, or if it’s someone like me who saw this but couldn’t get the **acos** to work as intended, hope this helps! Now we should be able to rip the coordinates from wherever (e.g api response) and plug them right into the function on the client side.

For anyone who want to know more information, this method uses the _haversine_ formula with the respective formulae below:  
**DEGREES**  
d = r \* ( (pi/180) \* acos( (sin(lat1) \* sin(lat2)) + cos(lat1) \* cos(lat2) \* cos(lng2 - lng1) ) )

**RADIANS** ( e.g lat radian = lat/(180/pi) )  
d = r \* acos( (sin(lat1) \* sin(lat2)) + cos(lat1) \* cos(lat2) \* cos(lng2 - lng1) )

“r” is the radius of the earth in the units you want (miles, metres, kilometres…) so you can use whichever you prefer, I just ripped them straight from google in the example.

> **Edits Summary**
>
> **EDIT**
> 
> 1. Added the project link
> 2. Forgot to add that multiplying the acos by pi/180 allows us to convert this to radians for the formula to work if your acos/asin/atan is in degrees
> 
> **EDIT 2**
> 
> 1. Added that it is the haversine formula
> 2. Spelling errors

---

_[View the full topic](https://community.thunkable.com/t/math-help-formula-not-working/917769)._
