How to use trigonometry like in Excel? (cosine, sine, etc.)

How do I do trig calculations in Bubble?

Can I accomplish this with a plugin? Do I need to learn Javascript?

I’m converting an existing Google Sheet into a web app. The app will import data from an uploaded file, complete various calculations, and display the data in a chart. I could share the entire sheet here if that would help, but here’s an example of one of the functions I would need to replicate in Bubble:
IF((ABS(B10-D10)<20),20*LOG10(SQRT((((10^(B10/20))*COS(RADIANS(C10))+(10^(D10/20))*COS(RADIANS(E10)))^2)+(((10^(B10/20)*SIN(RADIANS(C10)))+(10^(D10/20)*SIN(RADIANS(E10))))^2))),""))

Yeah, fundamental JS would be useful for you in this case, HOWEVER that’s not really necessary, it’s very likely that such can be achieved through the math.js (local) plugin.

1 Like

Oh, really? My understanding was that MATH.js had no trigonometry, but now I’m looking at the documentation more closely and I see that I include example like
math.eval('cos(45 deg)') // 0.7071067811865476

I wonder why there is no complete list of mathematical functions it support. I guess I’ll need to look into it further. Thank you @vini_brito !

1 Like

Hi, I have the same problem. Could yo use cosine in bubble? thanks !

Try the formalize plugin, it has allot of excel functions built in. It also supports variables.

For example you can assign a value of 2021 to a variable called current year, then call on that variable in a later step or in a formula

1 Like

Update on this post. My calculation is, in fact, solved with math.js. That being said, I just decided to handle it in MATLAB and send the result to Bubble through the API.

1 Like

hey I have to do similar things with cos and radians, how did your function look in bubble with math.js? How was it implemented? Really appreciate your help

1 Like

Hey @jana.49 , it’s pretty easy. If you head over to mathjs.org, there is a little test dialog box on the right side of the page. You can debug your expression there. If it works there, it should work through the API.

For example, you might type “10 ft to in” which would return 120 in. Use that exact expression in Bubble, just change the 10 to your variable.

1 Like

hey @AliFarahat do you have any documentation as to how to use the Formalize plugin? I can likely put it to use in my app but am having some difficulty understanding how it should work, just by looking at the demo site. thanks!