Divide Block
Divides the numerator signal by the denominator signal
Open Divide in BlockWerk →# Divide Block
Description
The Divide block performs algebraic division of two input signals: the numerator and the denominator. This block includes built-in protection against division by zero, allowing simulations to remain stable even when mathematical singularities are encountered.
The block features two distinct input ports: the upper port for the numerator (num) and the lower port for the denominator (den).
Mathematical Model
The Divide block implements:
y(t) = num(t) / den(t)
Where:
y(t)is the output signal at time tnum(t)is the numerator signalden(t)is the denominator signal
Division by Zero Protection
If the absolute value of the denominator is less than 2.22e-16 (machine epsilon), the block applies protection logic: 1. Returns the user-configurable divByZeroValue. 2. Displays a one-time visual popup warning in the UI to notify you of the event. 3. Logs a detailed message to the browser console.
The visual warning is only shown once per singular event (it resets if the denominator becomes non-zero and then zero again).
Parameters
divByZeroValue
The specific numerical value to output when a division by zero is detected.
- Recommended:
0.0for safety, or a very high value (e.g.,1e308) for saturation.
reportWarning
When enabled (true), the block will send a warning message to the browser's developer console every time a division by zero occurs.
Examples
Signal Normalization
Normalize a signal within the range of 0 to 1:
Measurement → Divide (num)
MaxValue → Divide (den)
Resistance Calculation (Ohm's Law)
Calculate resistance from voltage and current:
Voltage → Divide (num)
Current → Divide (den)
*Tip: Set divByZeroValue to a very high number to represent the infinite resistance of an open circuit when current is 0.*
Remarks
- Machine Epsilon: The zero-check uses a small tolerance (
f64::EPSILON) to handle floating-point precision issues. - WASM Performance: The protection logic is implemented natively in Rust for maximum performance with zero overhead during normal operation.
See Also
- Product: For signal multiplication
- Gain: For fixed-factor signal scaling
- NumericDisplay: To monitor results and console warnings