Formula

Shipping
formula

Element-wise expression evaluation with optional operands y, z

Signature

Inputs

  • xSignalrequired
  • ySignal
  • zSignal

Outputs

  • resultSignal

Parameters

KeyTypeDefaultNotes
formulaformulax

Description

The Formula node evaluates a user-supplied mathematical expression element-wise over its inputs, producing a single output signal. The primary operand arrives on port x (also addressable as signal); two optional operands y and z may be wired in and referenced by name. The running simulation time is exposed as the variable t, letting the expression depend explicitly on time as well as on sample values.

Expressions are parsed and evaluated in a sandboxed evalexpr engine supporting arithmetic, comparison, and a library of scalar math functions such as sin, cos, sqrt, exp, and ln. Bare names can be aliased with template syntax {{name}}, and the parameter key expression is accepted as an alias for formula. The default expression x makes the node a pass-through.

Evaluation is fully stateless — each output sample depends only on the current input samples and t, never on past values, so the node has no memory and incurs zero simulation-context overhead. Optional operands (y, z) that are shorter than x are zero-padded element-wise; the output length and its physical unit metadata follow x.

Because the expression is arbitrary, the engine cannot in general derive a dimensionally-consistent output unit or propagate measurement uncertainty () analytically through it. Units and uncertainty track the primary input x rather than being recomputed from the algebra, so mixing operands of incompatible dimensions inside one expression is the user's responsibility.

Mathematics

Examples

Time-modulated envelope

Multiply an incoming carrier on x by an exponential decay in time. With the expression

x * exp(-t / 0.5)

every sample is scaled by , producing a signal that decays to of its amplitude after . Output length and units follow x.

Two-input nonlinear combine

Wire two signals into x and y and compute a normalized product:

sqrt(x*x + y*y)

This yields the element-wise Euclidean magnitude . If y is shorter than x, the missing tail of y is treated as , so the result reduces to there.

Applications

  • Custom sensor linearization or calibration curves (e.g. converting a raw thermistor voltage to temperature with a polynomial or logarithmic fit) inline in the graph.
  • Rapid prototyping of nonlinear signal transforms — squaring, rectification, gating, or arbitrary transfer functions — without authoring a dedicated node.
  • Combining multiple measurement channels into a derived quantity (power $= v \cdot i$, magnitude, ratios) for real-time monitoring or plotting.
  • Injecting explicit time dependence (ramps, chirps, decays via the `t` variable) to modulate or window a live signal during simulation.

Neat

The same primary input is bound to two names, `x` and `signal`, so expressions copied between generic-signal contexts and Formula nodes work unchanged.

Being stateless, the node explicitly ignores the simulation `ctx` handle — it is one of the zero-overhead builtins that never allocate per-step history.

Known issues

The output unit and uncertainty are inherited from `x` rather than derived from the expression, so a formula that changes dimensionality (e.g. `x*y`) yields correct numbers but stale unit metadata.

Zero-padding of shorter optional operands is silent: an under-length `y` or `z` contributes $0$ past its end rather than raising a length-mismatch error, which can mask miswired inputs.

See also

expressionelement-wisestatelessarithmeticnonlinearevalexpr