Expression
Evaluates a math expression f(x) and outputs the result as a Float. The full JavaScript Math.* library is exposed, plus the common constants pi, e, tau.
Node
Interactive preview is available in the interactive reader.
Sockets
x (in)- Float. The input variable the expression binds to (default 0).
value (out)- Float. The evaluated result.
Parameters
Parameter details are listed in the interactive docs.
Recognised Identifiers
The expression parser exposes these names — everything else raises an invalid-param problem and the output falls back to 0:
x- The input variable — bound to the x socket value.
pi- Math.PI.
e- Math.E.
tau- 2 × Math.PI.
sin, cos, tan, asin, acos, atan, atan2- Math.* trigonometry. Angles are in radians.
sqrt, abs, floor, ceil, round, sign- Math.* scalar functions.
min, max, pow, log, exp- Math.* multi-arg functions.
+, -, *, /, %, **- Standard arithmetic.
**is exponentiation.
Examples
sin(x)— identity sine wave.sin(x * tau / 10) * 5— sine with 10-unit period, amplitude 5.abs(sin(x)) * 0.8 + 0.2— oscillate between 0.2 and 1.pow(x, 2) / 100— quadratic ramp.max(0, x - 5)— soft ReLU / threshold.