---
url: /dyad/stable/stdlib/BlockComponents/components/Math.Gain.md
description: Dyad Math.Gain docs.  Multiplies input signal by a constant gain factor.
---

# `Math.Gain` {#Math.Gain}

Multiplies input signal by a constant gain factor.

Multiplies the input signal by a constant parameter `k`. The relationship between the input u and output y is simply y = k\*u, where `k` is the gain factor. This block is useful for scaling signals or converting between different units.

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

## Usage {#Usage}

`BlockComponents.Math.Gain(k)`

## Parameters: {#Parameters:}

| Name |                                           Description | Units | Default value |
| ----:| -----------------------------------------------------:| -----:| -------------:|
|  `k` | Constant gain factor that multiplies the input signal |     – |               |

## 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) &= k ~ u\left( t \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Multiplies input signal by a constant gain factor.

Multiplies the input signal by a constant parameter `k`. The relationship
between the input u and output y is simply y = k*u, where `k` is the gain factor. This block is useful
for scaling signals or converting between different units.
"""
component Gain
  extends BlockComponents.Interfaces.SISO
  "Constant gain factor that multiplies the input signal"
  parameter k::Real
relations
  y = k * u
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 1100, "rot": 0},
      {"label": "k=$(k)", "x": 500, "y": -100, "rot": 0}
    ],
    "icons": {"default": "dyad://BlockComponents/Gain.svg"}
  }
}
end
```

```dyad
"""
Multiplies input signal by a constant gain factor.

Multiplies the input signal by a constant parameter `k`. The relationship
between the input u and output y is simply y = k*u, where `k` is the gain factor. This block is useful
for scaling signals or converting between different units.
"""
component Gain
  "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}
      }
    }
  }
  "Constant gain factor that multiplies the input signal"
  parameter k::Real
relations
  y = k * u
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 1100, "rot": 0},
      {"label": "k=$(k)", "x": 500, "y": -100, "rot": 0}
    ],
    "icons": {"default": "dyad://BlockComponents/Gain.svg"}
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`ZeroThresholds`](Math.Gain.md)
