BlockWerk Documentation
√

SquareRoot

Math

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.

Simulate in BlockWerk

Interactive sandbox directly in your browser — zero installation, WASM-powered.

Simulate in BlockWerk →

Mathematical Model

The block implements the following calculation:

y(t)=u(t)ny(t) = \sqrt[n]{u(t)}

Where:

  • y(t) is the output signal
  • in(t) is the input signal
  • n is 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.

Inputs & Outputs

Direction ID Label Type Status
→ In in In number Required
← Out out Out number Output

Parameters

Parameters Label Type Default Description
rootOrder Root Order (n) number 2
negativeHandling Negative Input select zero
reportWarning Report Warning boolean true

Usage 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 & Best Practices

  • 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

Related Components

  • Product: For general multiplication and squaring (n=0.5)
  • Gain: For scaling signals
  • MathFunction: For other mathematical operations