Math Help - Formula not working

Here’s the link to the project:

I am trying to get a formula that works in Excel to work in Thunkable. I have put both formulas, in the comments, in the Blocks section.

The formulas are:
=180/PI() * ACOS(COS(PSA to PAP * PI()/13.5)/SIN(Pin to PAP * PI()/13.5))
and
=180/PI() * ASIN (SIN(Pin Buffer * PI()/13.5)/SIN(Pin to PAP * PI()/13.5))

User inputs are as follows
Pin to PAP 4
PSA to PAP 4
Pin Buffer 2

The result returned should be 42 x 4 x 34.

The result I get is 1 x 4 x 2.

I’m stuck, any help would be greatly appreciated.
Thank You. :sunglasses:

When I viewed your project, the first formula was set to 180 / π * ASIN(SIN(…

But even after switching it to 180 / π * ACOS(COS(… it still doesn’t return the expected values.

It may matter that Thunkable is expecting degree values for trig functions.

Can you provide a link to a website that shows those formulas? I find it a little hard to read in the current format. Edit: nevermind. I found a website but it’s not any better formatted than what you shared. And I also get 42 for the first result as soon as I paste the formula into Excel. So yeah, it’s a matter of parsing what you put together. :wink:

1 Like

Having so many nested blocks, it is amost impossible for my little brain to figure out the issue. Whenever I have a process with more than 2 nested blocks, I will create a temporary variable and perform the calculation one operation at a time. I will also update a label to show the result of each step so I can see how where the calculation is breaking down. Something like this:

Good luck and happy Thunking!

3 Likes

I’d agree with @drted and was going to suggest the same. It’s a little extra work at the beginning but much easier to troubleshoot and modify later.

Also, I think the problem with your formula in Thunkable is that you have a much larger/longer denominator than the original functions suggests. So instead of 180/π * …, you have 180/(π * …)

Here’s where I’m at now. I broke the formula down into parts and gave each part its own variable, thank you for the suggestion. It does make it easier to troubleshoot. What I am finding out is the SIN function does not return the correct value. If I do SIN(.47) to 2 decimal places it should return the value 0.45, but when I use the sin block and put the value in of .47 it returns 0.01. So I’m starting to think that the sin block itself is mis-calculating. Does that make sense?

Try splitting out the SIN for the Rounding to 2 decimal places. A few weeks ago I discovered that the …with…decimal places block returns a string, not a number. Map crashes when adding markers from data source.

Save the rounding to the final display step.

1 Like

I tried this and it still does not return the correct value. For SIN(.47) thunkable returns 0.0082029554875217 without using Rounding.

Sounds like a Radians vs. Degrees problem.

I sent a PM to Thunkable to see what they can find out. I’ll post the reply when I receive it. :sunglasses:

1 Like

You need to convert from radians to degrees.

Screen Shot 2020-10-21 at 7.57.06 AM

3 Likes

Absolutely Brilliant !!! Thank You !!!
The sin and cos blocks now return the correct values.
I tried doing the same with the asin and acos blocks and still received the wrong result.
asin(.56) is .59, but thunkable block returns 34.06
acos(.75) is .72, but thunkable block returns 41.41

Any thoughts on how to correct this? :thinking:

You’re welcome!

No… I can’t make heads or tails of the asin function results I’m seeing.

If you REALLY need it, you might try bypassing thunkable and using a 3rd party web API. It is DEFINITELY a more challenging Thunkable project, but it is an option.

A quick google search found this API that might do what you need