---
url: /dyad/stable/stdlib/BlockComponents/tests/Math.Tests.Exponentiation.md
description: >-
  Dyad Math.Tests.Exponentiation docs.  Tests the Exponentiation block with
  multiple exponent values.
---

# `Math.Tests.Exponentiation` {#Math.Tests.Exponentiation}

Tests the Exponentiation block with multiple exponent values.

Mirrors the MSL Exponentiation test structure: a ramp from -2 to 2 feeds blocks with even (2), odd (3), unit (1), and zero (0) exponents. The zero-exponent case uses a Max block to ensure positive input for the inverse exponent test.

## Usage {#Usage}

`BlockComponents.Math.Tests.Exponentiation()`

## Behavior {#Behavior}

$$ \begin{align}
0 &= \mathrm{connect}\left( ramp\_{+}y, even\_{exp\_{+}u} \right) \\
0 &= \mathrm{connect}\left( ramp\_{+}y, odd\_{exp\_{+}u} \right) \\
0 &= \mathrm{connect}\left( ramp\_{+}y, one\_{exp\_{+}u} \right) \\
0 &= \mathrm{connect}\left( ramp\_{+}y, max\_{block\_{+}u1} \right) \\
0 &= \mathrm{connect}\left( floor\_{val\_{+}y}, max\_{block\_{+}u2} \right) \\
0 &= \mathrm{connect}\left( max\_{block\_{+}y}, zero\_{exp\_{+}u} \right) \\
0 &= \mathrm{connect}\left( max\_{block\_{+}y}, inverse\_{exp\_{+}u} \right) \\
\mathtt{ramp.y}\left( t \right) &= ifelse\left( \mathtt{ramp.start_time} < t, ifelse\left( t < \mathtt{ramp.duration} + \mathtt{ramp.start_time}, \mathtt{ramp.offset} + \frac{\mathtt{ramp.height} ~ \left(  - \mathtt{ramp.start_time} + t \right)}{\mathtt{ramp.duration}}, \mathtt{ramp.height} + \mathtt{ramp.offset} \right), \mathtt{ramp.offset} \right) \\
\mathtt{even_exp.y}\left( t \right) &= \left( \mathtt{even_exp.u}\left( t \right) \right)^{\mathtt{even_exp.exponent}} \\
\mathtt{odd_exp.y}\left( t \right) &= \left( \mathtt{odd_exp.u}\left( t \right) \right)^{\mathtt{odd_exp.exponent}} \\
\mathtt{one_exp.y}\left( t \right) &= \left( \mathtt{one_exp.u}\left( t \right) \right)^{\mathtt{one_exp.exponent}} \\
\mathtt{zero_exp.y}\left( t \right) &= \left( \mathtt{zero_exp.u}\left( t \right) \right)^{\mathtt{zero_exp.exponent}} \\
\mathtt{max_block.y}\left( t \right) &= max\left( \mathtt{max_block.u1}\left( t \right), \mathtt{max_block.u2}\left( t \right) \right) \\
\mathtt{floor_val.y}\left( t \right) &= \mathtt{floor_val.k} \\
\mathtt{inverse_exp.y}\left( t \right) &= \left( \mathtt{inverse_exp.u}\left( t \right) \right)^{\mathtt{inverse_exp.exponent}}
\end{align}
$$

## Source {#Source}

```dyad
"""
Tests the Exponentiation block with multiple exponent values.

Mirrors the MSL Exponentiation test structure: a ramp from -2 to 2 feeds
blocks with even (2), odd (3), unit (1), and zero (0) exponents.
The zero-exponent case uses a Max block to ensure positive input for the
inverse exponent test.
"""
test component Exponentiation
  "Ramp from -2 to 2 over 1 second"
  ramp = BlockComponents.Sources.Ramp(height = 4, duration = 1, offset = -2, start_time = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 260, "x2": 120, "y2": 360, "rot": 0}
      },
      "tags": []
    }
  }
  "u^2: even exponent"
  even_exp = BlockComponents.Math.Exponentiation(exponent = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "u^3: odd exponent"
  odd_exp = BlockComponents.Math.Exponentiation(exponent = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  "u^1: identity"
  one_exp = BlockComponents.Math.Exponentiation(exponent = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 260, "x2": 260, "y2": 360, "rot": 0}
      },
      "tags": []
    }
  }
  "u^0: always 1 for nonzero input"
  zero_exp = BlockComponents.Math.Exponentiation(exponent = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 300, "y1": 250, "x2": 400, "y2": 350, "rot": 0}
      },
      "tags": []
    }
  }
  "Ensures positive input for inverse exponent"
  max_block = BlockComponents.Math.Max() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 380, "x2": 260, "y2": 480, "rot": 0}
      },
      "tags": []
    }
  }
  "Constant 0.1 floor for inverse"
  floor_val = BlockComponents.Sources.Constant(k = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 410, "x2": 120, "y2": 510, "rot": 0}
      },
      "tags": []
    }
  }
  "u^(-1): inverse"
  inverse_exp = BlockComponents.Math.Exponentiation(exponent = -1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 300, "y1": 380, "x2": 400, "y2": 480, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(ramp.y, even_exp.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 140, "y": 70}], "E": 2}],
      "junctions": [{"x": 140, "y": 310}],
      "renderStyle": "standard"
    }
  }
  connect(ramp.y, odd_exp.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 310}], "E": -1}, {"S": -1, "M": [], "E": 2}],
      "junctions": [{"x": 140, "y": 190}],
      "renderStyle": "standard"
    }
  }
  connect(ramp.y, one_exp.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(ramp.y, max_block.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 310}, {"x": 140, "y": 400}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(floor_val.y, max_block.u2) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(max_block.y, zero_exp.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 280, "y": 300}], "E": 2}],
      "junctions": [{"x": 280, "y": 430}],
      "renderStyle": "standard"
    }
  }
  connect(max_block.y, inverse_exp.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "expect": {
          "signals": [
            "ramp.y",
            "even_exp.y",
            "odd_exp.y",
            "one_exp.y",
            "zero_exp.y",
            "inverse_exp.y"
          ]
        }
      }
    }
  }
}
end
```

```dyad
"""
Tests the Exponentiation block with multiple exponent values.

Mirrors the MSL Exponentiation test structure: a ramp from -2 to 2 feeds
blocks with even (2), odd (3), unit (1), and zero (0) exponents.
The zero-exponent case uses a Max block to ensure positive input for the
inverse exponent test.
"""
test component Exponentiation
  "Ramp from -2 to 2 over 1 second"
  ramp = BlockComponents.Sources.Ramp(height = 4, duration = 1, offset = -2, start_time = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 260, "x2": 120, "y2": 360, "rot": 0}
      },
      "tags": []
    }
  }
  "u^2: even exponent"
  even_exp = BlockComponents.Math.Exponentiation(exponent = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "u^3: odd exponent"
  odd_exp = BlockComponents.Math.Exponentiation(exponent = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  "u^1: identity"
  one_exp = BlockComponents.Math.Exponentiation(exponent = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 260, "x2": 260, "y2": 360, "rot": 0}
      },
      "tags": []
    }
  }
  "u^0: always 1 for nonzero input"
  zero_exp = BlockComponents.Math.Exponentiation(exponent = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 300, "y1": 250, "x2": 400, "y2": 350, "rot": 0}
      },
      "tags": []
    }
  }
  "Ensures positive input for inverse exponent"
  max_block = BlockComponents.Math.Max() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 380, "x2": 260, "y2": 480, "rot": 0}
      },
      "tags": []
    }
  }
  "Constant 0.1 floor for inverse"
  floor_val = BlockComponents.Sources.Constant(k = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 410, "x2": 120, "y2": 510, "rot": 0}
      },
      "tags": []
    }
  }
  "u^(-1): inverse"
  inverse_exp = BlockComponents.Math.Exponentiation(exponent = -1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 300, "y1": 380, "x2": 400, "y2": 480, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(ramp.y, even_exp.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 140, "y": 70}], "E": 2}],
      "junctions": [{"x": 140, "y": 310}],
      "renderStyle": "standard"
    }
  }
  connect(ramp.y, odd_exp.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 310}], "E": -1}, {"S": -1, "M": [], "E": 2}],
      "junctions": [{"x": 140, "y": 190}],
      "renderStyle": "standard"
    }
  }
  connect(ramp.y, one_exp.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(ramp.y, max_block.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 140, "y": 310}, {"x": 140, "y": 400}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(floor_val.y, max_block.u2) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(max_block.y, zero_exp.u) {
    "Dyad": {
      "edges": [{"S": 1, "M": [], "E": -1}, {"S": -1, "M": [{"x": 280, "y": 300}], "E": 2}],
      "junctions": [{"x": 280, "y": 430}],
      "renderStyle": "standard"
    }
  }
  connect(max_block.y, inverse_exp.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "expect": {
          "signals": [
            "ramp.y",
            "even_exp.y",
            "odd_exp.y",
            "one_exp.y",
            "zero_exp.y",
            "inverse_exp.y"
          ]
        }
      }
    }
  }
}
end
```

## Test Cases {#Test-Cases}

### Test Case `case1` {#Test-Case-case1}

```julia
plt
```

![](icmzgqw.svg)

```julia
plt
```

![](cofcfmv.svg)

```julia
plt
```

![](gqyyblq.svg)

```julia
plt
```

![](xilehwh.svg)

```julia
plt
```

![](unpzdrm.svg)

```julia
plt
```

![](vbixpqe.svg)

## Related {#Related}

* Examples

* Experiments

* Analyses

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

  * [`Exponentiation`](Math.Tests.Exponentiation.md)

  * [`Exponentiation`](Math.Tests.Exponentiation.md)

  * [`Max`](Math.Tests.Exponentiation.md)

  * [`Ramp`](Math.Tests.Exponentiation.md)
