This isn’t possible yet in the expression editor but I just wrote a feature request for this. In the meantime, I did create a custom widget that does exactly this:
It takes inputs:
X
The operation you want to do: sin,cos,tan,asin,acos,atan
Whenever the value of X changes, the widget will recalculate the value of the result variable.
In the example video above I show the widget itself visible on the app step, but it can be outside of the viewable area of the app and it will still execute.
I would consider, to also start calculating, when the opration changes (and x has a valid value).
That ensures, that you will never have a situation, where you can see a result, that does not fit to your inputs (changing operation after first result was delivered would lead to an unvalid combination on screen).
You could also clear the x value and the result after changing the operation but, I think thts less unser friendly.
Do you already have an update for us for further mathematical functions within the expression editor?
We now have another customer who is also missing the sinus hyperbolic.
Already available:
sin()
cos()
tan()
What we are missing:
asin()
acos()
atan()
sinh()
cosh()
tanh()
We have added the functions to the custom widget for time being, but it would be useful for apps that support workers with these complicated calculations if they were also available in the expression editor.
FWIW this can be solved using any postgres database connection. Tulip hosts and provides a random one out of the box which is a little bit suspect but gets the job done. We continue to see a need for more natural ways to use javascript or postgres for custom, global expressions.
In general, these are basic mathematical functions for the industry.
For this special use case:
They align spindle towers during assembly.
These are mounted on a 3-point support and underlaid with washers.
We now want to calculate, what washer height needs to be placed underneath to align the tower parallel to a guide.
The required washer height is then displayed to the worker.