SquareRoot Block
Calculates the n-th root of the input signal
Open SquareRoot in BlockWerk →# SquareRoot Block
Description
The SquareRoot block calculates the n-th root of the input signal. While named SquareRoot for common usage (where n=2), it is a versatile root-calculation block that supports cube roots (n=3) and any other numeric root order.
Mathematical Model
The block implements the following calculation:
y(t) = in(t) ^ (1/n)
Where:
y(t)is the output signalin(t)is the input signalnis the root order (default is 2.0)
Handling of Negative Inputs
Calculating the root of a negative number can be problematic for even root orders (e.g., √-1). The block provides several configurable safety modes:
1. Return Zero (Default): Outputs 0.0 when a negative input is encountered. This is the safest option for simulation stability and includes a one-time visual warning. 2. Use Absolute Value: Calculates the root of the absolute value of the input. Useful when the sign of the signal is irrelevant for the root calculation. 3. Return NaN: Returns "Not a Number". Note that this value will propagate through your diagram and may cause other blocks to output NaN.
Parameters
Root Order (n)
The order of the root to calculate.
2.0for square root (default)3.0for cube root0.5is equivalent to squaring the signal
Negative Input
Specifies the behavior when the input signal falls below zero.
- Return Zero: Stable fallback.
- Use Absolute Value: Mathematical alternative.
- Return NaN: Scientific standard.
Report Warning
When enabled (true), displays a visual popup warning in the UI the first time a negative input is detected.
Examples
Distance Calculation
Calculate the distance from coordinates (x, y):
Sum (x^2 + y^2) → SquareRoot (n=2) → Distance
Flow Measurement
Calculate fluid flow rate from differential pressure (where flow ∝ √ΔP):
PressureDifference → SquareRoot (n=2) → FlowRate
Remarks
- Negative inputs: Even root orders (n = 2, 4, 6) produce NaN for negative inputs; use the "Use Absolute Value" mode or the "Return Zero" safety option
- Zero input: Returns 0 for any positive root order
- Root order < 1: Equivalent to raising the input to a power > 1 (e.g., n = 0.5 squares the signal)
- Performance: Very low computational cost; safe for real-time simulation
- Numerical stability: Root of very small positive numbers can produce large outputs; consider clamping near-zero inputs
See Also
- Product: For general multiplication and squaring (n=0.5)
- Gain: For scaling signals
- MathFunction: For other mathematical operations