Hypot Hypot Icon

Mathematical.Hypot

Hypot

A component that computes the Euclidean norm (hypotenuse) of two input signals.

Description

The Hypot block computes the Euclidean norm of inputs u1 and u2 using the built-in hypot() function. The output y represents the length of the vector formed by u1 and u2, computed as: y = hypot(u1, u2) = sqrt(u1^2 + u2^2).

Variables

  • u1(t): First input signal
  • u2(t): Second input signal
  • y(t): Output signal (Euclidean norm of u1 and u2)

Examples

  • u1 = 3, u2 = 4 → y = 5.0 (classic 3-4-5 triangle)
  • u1 = 6, u2 = 8 → y = 10.0
  • u1 = 0, u2 = 5 → y = 5.0
  • u1 = -3, u2 = 4 → y = 5.0 (signs don't affect magnitude)

This component extends from BlockComponents.SI2SO

Usage

PrimitiveComponents.Mathematical.Hypot()

Connectors

  • u1 - This connector represents a real signal as an input to a component (RealInput)
  • u2 - 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) &= hypot\left( \mathtt{u1}\left( t \right), \mathtt{u2}\left( t \right) \right) \end{align} \]

Source

"""
    Hypot

A component that computes the Euclidean norm (hypotenuse) of two input signals.

# Description
The Hypot block computes the Euclidean norm of inputs `u1` and `u2` using the built-in `hypot()` function.
The output `y` represents the length of the vector formed by `u1` and `u2`, computed as:
y = hypot(u1, u2) = sqrt(u1^2 + u2^2).

# Variables
- `u1(t)`: First input signal
- `u2(t)`: Second input signal
- `y(t)`: Output signal (Euclidean norm of u1 and u2)

# Examples
- u1 = 3,  u2 = 4   → y = 5.0       (classic 3-4-5 triangle)
- u1 = 6,  u2 = 8   → y = 10.0
- u1 = 0,  u2 = 5   → y = 5.0
- u1 = -3, u2 = 4   → y = 5.0       (signs don't affect magnitude)
"""
component Hypot
  extends BlockComponents.SI2SO()
relations
  y = hypot(u1, u2)
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 1100,
        "rot": 0,
        "layer": "icon",
        "attrs": {}
      }
    ],
    "icons": {"default": "dyad://PrimitiveComponents/Hypot.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end
Flattened Source
"""
    Hypot

A component that computes the Euclidean norm (hypotenuse) of two input signals.

# Description
The Hypot block computes the Euclidean norm of inputs `u1` and `u2` using the built-in `hypot()` function.
The output `y` represents the length of the vector formed by `u1` and `u2`, computed as:
y = hypot(u1, u2) = sqrt(u1^2 + u2^2).

# Variables
- `u1(t)`: First input signal
- `u2(t)`: Second input signal
- `y(t)`: Output signal (Euclidean norm of u1 and u2)

# Examples
- u1 = 3,  u2 = 4   → y = 5.0       (classic 3-4-5 triangle)
- u1 = 6,  u2 = 8   → y = 10.0
- u1 = 0,  u2 = 5   → y = 5.0
- u1 = -3, u2 = 4   → y = 5.0       (signs don't affect magnitude)
"""
component Hypot
  "First real-valued input signal"
  u1 = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -50, "y1": 150, "x2": 50, "y2": 250, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 150, "x2": 0, "y2": 250, "rot": 0}
      }
    }
  }
  "Second real-valued input signal"
  u2 = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -100, "y1": 750, "x2": 0, "y2": 850, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 750, "x2": 0, "y2": 850, "rot": 0}
      }
    }
  }
  "Real-valued output signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
relations
  y = hypot(u1, u2)
metadata {
  "Dyad": {
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 1100,
        "rot": 0,
        "layer": "icon",
        "attrs": {}
      }
    ],
    "experiments": {},
    "tests": {},
    "icons": {"default": "dyad://PrimitiveComponents/Hypot.svg"},
    "path": {},
    "doc": {"behavior": true}
  }
}
end


Test Cases

No test cases defined.

  • Examples
  • Experiments
  • Analyses