Skip to content
LIBRARY
Math.Power.md

Math.Power

Outputs the power of a base raised to the input signal.

Computes the output y as the constant base raised to the power of the input u. When useExp is true (default), the numerically stable form is used:

Otherwise:

The default base is Euler's number e ≈ 2.71828.

This component extends from BlockComponents.Interfaces.SISO

Usage

BlockComponents.Math.Power(base=exp(1.0), useExp=true)

Parameters:

NameDescriptionUnitsDefault value
baseBase of the powerexp(1.0)
useExpUse exp function in implementation for numerical stabilitytrue

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

Source

dyad
"""
Outputs the power of a base raised to the input signal.

Computes the output `y` as the constant `base` raised to the power of the
input `u`. When `useExp` is true (default), the numerically stable form is
used:

```math
y = \\exp(u \\cdot \\ln(\\text{base}))
```

Otherwise:

```math
y = \\text{base}^u
```

The default base is Euler's number e ≈ 2.71828.
"""
component Power
  extends BlockComponents.Interfaces.SISO
  "Base of the power"
  parameter base::Real = exp(1.0)
  "Use exp function in implementation for numerical stability"
  parameter useExp::Boolean = true
relations
  "Computes base raised to the power of the input signal"
  y = ifelse(useExp, exp(u * log(base)), base ^ u)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Power.svg"}
  }
}
end
Flattened Source
dyad
"""
Outputs the power of a base raised to the input signal.

Computes the output `y` as the constant `base` raised to the power of the
input `u`. When `useExp` is true (default), the numerically stable form is
used:

```math
y = \\exp(u \\cdot \\ln(\\text{base}))
```

Otherwise:

```math
y = \\text{base}^u
```

The default base is Euler's number e ≈ 2.71828.
"""
component Power
  "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}
      }
    }
  }
  "Base of the power"
  parameter base::Real = exp(1.0)
  "Use exp function in implementation for numerical stability"
  parameter useExp::Boolean = true
relations
  "Computes base raised to the power of the input signal"
  y = ifelse(useExp, exp(u * log(base)), base ^ u)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Power.svg"}
  }
}
end


Test Cases

No test cases defined.