Signed_Sqrt Signed_Sqrt Icon

Mathematical.Signed_Sqrt

Signed_Sqrt

A component that computes the signed square root of a real-valued input signal.

Description

The Signed_Sqrt block computes the signed square root of input u. Unlike the standard Sqrt block, this version preserves the sign of the input. The output y is defined as: y = sign(u) * √|u|. This makes it continuous around zero and suitable for signals that can take both positive and negative values (e.g., in control or estimation systems).

Variables

  • u(t): Input signal
  • y(t): Output signal (signed square root of u)

Examples

  • u = 9 → y = 3
  • u = 0 → y = 0
  • u = -9 → y = -3
  • u = 2.25 → y = 1.5
  • u = -2.25 → y = -1.5

This component extends from BlockComponents.SISO

Usage

PrimitiveComponents.Mathematical.Signed_Sqrt()

Connectors

  • u - This connector represents a real signal as an input to a component (RealInput)
  • y - This connector represents a real signal as an output from a component (RealOutput)

Behavior

\[ \begin{align} y\left( t \right) &= \left( \left|u\left( t \right)\right| \right)^{0.5} sign\left( u\left( t \right) \right) \end{align} \]

Source

"""
    Signed_Sqrt

A component that computes the signed square root of a real-valued input signal.

# Description
The Signed_Sqrt block computes the signed square root of input `u`.
Unlike the standard Sqrt block, this version preserves the sign of the input.
The output `y` is defined as: y = sign(u) * √|u|.
This makes it continuous around zero and suitable for signals that can take both
positive and negative values (e.g., in control or estimation systems).

# Variables
- `u(t)`: Input signal
- `y(t)`: Output signal (signed square root of u)

# Examples
- u =  9   → y =  3
- u =  0   → y =  0
- u = -9   → y = -3
- u =  2.25 → y =  1.5
- u = -2.25 → y = -1.5
"""
component Signed_Sqrt
  extends BlockComponents.SISO
relations
  y = sign(u) * (abs(u) ^ (0.5))
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 1100,
        "rot": 0,
        "layer": "icon",
        "attrs": {}
      }
    ],
    "icons": {"default": "dyad://PrimitiveComponents/SignedSqrt.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end
Flattened Source
"""
    Signed_Sqrt

A component that computes the signed square root of a real-valued input signal.

# Description
The Signed_Sqrt block computes the signed square root of input `u`.
Unlike the standard Sqrt block, this version preserves the sign of the input.
The output `y` is defined as: y = sign(u) * √|u|.
This makes it continuous around zero and suitable for signals that can take both
positive and negative values (e.g., in control or estimation systems).

# Variables
- `u(t)`: Input signal
- `y(t)`: Output signal (signed square root of u)

# Examples
- u =  9   → y =  3
- u =  0   → y =  0
- u = -9   → y = -3
- u =  2.25 → y =  1.5
- u = -2.25 → y = -1.5
"""
component Signed_Sqrt
  "Input signal port"
  u = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0},
        "diagram": {"iconName": "input", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      }
    }
  }
  "Output signal port"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "output", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
relations
  y = sign(u) * (abs(u) ^ (0.5))
metadata {
  "Dyad": {
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 1100,
        "rot": 0,
        "layer": "icon",
        "attrs": {}
      }
    ],
    "experiments": {},
    "tests": {},
    "icons": {"default": "dyad://PrimitiveComponents/SignedSqrt.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end


Test Cases

No test cases defined.

  • Examples
  • Experiments
  • Analyses