---
url: /dyad/stable/stdlib/BlockComponents/components/Math.Power.md
description: Dyad Math.Power docs.  Outputs the power of a base raised to the input signal.
---

# `Math.Power` {#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:

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

Otherwise:

$$y = \text{base}^u$$

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

This component extends from [`BlockComponents.Interfaces.SISO`](../types/Interfaces.SISO.md)

## Usage {#Usage}

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

## Parameters: {#Parameters:}

|     Name |                                                Description | Units | Default value |
| --------:| ----------------------------------------------------------:| -----:| -------------:|
|   `base` |                                          Base of the power |     – |      exp(1.0) |
| `useExp` | Use exp function in implementation for numerical stability |     – |          true |

## Connectors {#Connectors}

* `u` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

$$ \begin{align}
y\left( t \right) &= ifelse\left( \mathtt{useExp}, e^{\log\left( \mathtt{base} \right) ~ u\left( t \right)}, \mathtt{base}^{u\left( t \right)} \right)
\end{align}
$$

## Source {#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
````

````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 {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Constant`](Math.Power.md)

  * [`Power`](Math.Power.md)

  * [`Power`](Math.Power.md)

  * [`Sine`](Math.Power.md)
