Square Root
systemic:core-sqrtMathfunction1 crInputs
| Name | Type | Description |
|---|---|---|
| Data | floatarray | The numeric series to take the square root of. |
Outputs
| Name | Type | Description |
|---|---|---|
| Sqrt | floatarray | The principal square root of each input value. |
Computes the principal square root of each value. A compression tool that reduces the scale of extreme values while preserving order.
| Input | Output |
|---|---|
| 0 | 0 |
| 4 | 2 |
| 100 | 10 |
| 10,000 | 100 |
Input Constraint
⚠️ Important: Input values must be non-negative (≥ 0). Negative numbers have no real square root, so a negative input produces a null output at that position — the math is never faked with a substitute value.
The Compression Effect
Square root compresses large values more than small ones:
| Original | √ Result | Compression |
|---|---|---|
| 1 | 1 | 1:1 |
| 100 | 10 | 10:1 |
| 10,000 | 100 | 100:1 |
| 1,000,000 | 1,000 | 1000:1 |
This makes data with extreme outliers (like volume or market cap) more manageable for comparison and analysis.
Practical Example: Volume Normalization
Trading volume varies by orders of magnitude across assets. Square root makes comparison meaningful:
| Stock Type | Raw Volume | √ Volume |
|---|---|---|
| Small-cap | 100,000 | 316 |
| Mid-cap | 1,000,000 | 1,000 |
| Large-cap | 100,000,000 | 10,000 |
Now “2× average volume” has comparable significance across all asset sizes.
SQRT vs. POW(0.5)
Mathematically equivalent, but SQRT:
- Enforces non-negative input constraint
- Is semantically clearer for square root operations
Use POW with exponent 0.5 if you need more flexibility (e.g., variable exponents).
Related Modules
- POW — General exponentiation (use exponent 2 to reverse SQRT)
- ABS — Ensure non-negative input before SQRT
- DIV — Alternative normalization (ratio-based)
| Transform | Compression | Best For |
|---|---|---|
| √x | Moderate | Volume, counts, moderate outliers |
| log(x) | Strong | Price ratios, returns, extreme outliers |
Use square root when you want to reduce scale without completely flattening the data.
Missing Data
When an input position is missing (null) — for example, a stock series has no bar on a weekend or holiday — the output at that same position is null. Values are never invented to fill a gap: every non-null output is the true square root of a real datapoint.
In live mode, the module returns exactly one datapoint — the most recent position — and it may be null when no bar exists at that moment (e.g., a weekend tick on a market-hours series). That gap is correct, not an error.
Handling Negative Inputs
A negative value is a real datapoint whose square root simply does not exist — distinct from missing data, where no datapoint exists at all. Both surface as null in the output, but they mean different things:
- Missing input → null: there was no bar to compute from
- Negative input → null: there was a bar, but the math is undefined for it
If your data may contain negative values, pre-process with the ABS module to make inputs non-negative.
Quick Reference
| Input | Output |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 4 | 2 |
| 9 | 3 |
| 2.25 | 1.5 |
| 1,000,000 | 1,000 |