Math Operator

Shipping
math_operator

Element-wise binary operations: add, subtract, multiply, divide, power, modulo, min, max

Signature

Inputs

  • aSignal|Scalarrequired
  • bSignal|Scalarrequired

Outputs

  • resultSignal|Scalar

Parameters

KeyTypeDefaultNotes
operationenumaddone of: add, subtract, multiply, divide, power, modulo, min, max
length_policyenumtruncateone of: truncate, pad

Description

Math Operator applies one element-wise binary operation to its two inputs a and b. The operation parameter selects among add, subtract, multiply, divide, power, modulo, min, and max. It is stateless — the output depends only on the current inputs, never on prior samples.

The node is mixed-type aware. Signal + Signal produces an element-wise result; Signal + Scalar broadcasts the scalar across every sample; Scalar + Scalar yields a single scalar. Integers and UnitValue quantities are accepted as numeric operands. When two signals differ in length, length_policy reconciles them: truncate clips to the shorter length, while pad extends to the longer.

Physical units propagate through dimensional analysis: add/subtract/min/max require dimensionally compatible operands and preserve the unit; multiply and divide combine units (e.g. ); power raises the dimension by the exponent. Uncertainty () propagates through each operation by standard first-order error propagation, so results carry a correctly derived .

For divide and modulo, a zero in b is a genuine edge case (see Known Issues). power with a non-integer exponent on a negative base is likewise undefined in the reals.

Mathematics

Examples

Instantaneous power from voltage and current

Wire a voltage signal () into a and a current signal () into b, set operation = multiply. The output is instantaneous power with unit , and its is derived from the relative uncertainties of both operands.

Scalar broadcast gain

Feed a signal into a and a constant scalar 2.0 into b with operation = multiply. The scalar is broadcast across all samples:

a = [1, 2, 3, 4]   b = 2.0   →   result = [2, 4, 6, 8]

Applications

  • Combining measured channels — instantaneous power (V×I), ratios, differences between sensor streams.
  • Normalization and gain staging by dividing or multiplying a signal against a scalar or reference.
  • Computing errors and residuals via subtraction of a model signal from a measured one.
  • Envelope and clamp logic using element-wise `min`/`max` against a threshold signal or scalar.

Neat

Because units are algebraic, `divide` of two like-dimensioned signals returns a dimensionless result automatically — a built-in way to form normalized ratios.

`min` and `max` are treated as binary operations here, so pairing a signal against a constant scalar acts as a per-sample floor or ceiling without any dedicated clip node.

Known issues

`divide` or `modulo` by zero in `b` yields a non-finite result (Inf/NaN) at those samples; guard the denominator upstream if zeros are possible.

`power` with a fractional exponent on a negative base is undefined in the reals and produces NaN; `add`/`subtract`/`min`/`max` on dimensionally incompatible units are rejected.

See also

arithmeticelement-wisebinaryunitsuncertaintystateless