---
url: /dyad/dev/stdlib/BlockComponents/components/Math.Feedback.md
description: >-
  Dyad Math.Feedback docs.  Computes the difference between a reference input
  and a feedback input.
---

# `Math.Feedback` {#Math.Feedback}

Computes the difference between a reference input and a feedback input.

This block calculates the error signal in a feedback control system by subtracting the feedback input (`u2`) from the reference input (`u1`). The component is typically used at the beginning of a control system to determine the difference between a desired setpoint and the measured output being fed back.

## Usage {#Usage}

`BlockComponents.Math.Feedback()`

## Connectors {#Connectors}

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

* `u2` - 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) &= \mathtt{u1}\left( t \right) - \mathtt{u2}\left( t \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Computes the difference between a reference input and a feedback input.

This block calculates the error signal in a feedback control system by subtracting the feedback
input (`u2`) from the reference input (`u1`). The component is typically used at the beginning of a
control system to determine the difference between a desired setpoint and the measured output
being fed back.
"""
component Feedback
  "First real-valued input signal"
  u1 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -110, "y1": 450, "x2": -10, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Second real-valued input signal"
  u2 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {
          "iconName": "default",
          "x1": 450,
          "y1": 1010,
          "x2": 550,
          "y2": 1110,
          "rot": 270
        }
      },
      "tags": []
    }
  }
  "Real-valued output signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
relations
  "Calculates output as the difference between the reference input and feedback input"
  y = u1 - u2
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Feedback.svg"}
  }
}
end
```

```dyad
"""
Computes the difference between a reference input and a feedback input.

This block calculates the error signal in a feedback control system by subtracting the feedback
input (`u2`) from the reference input (`u1`). The component is typically used at the beginning of a
control system to determine the difference between a desired setpoint and the measured output
being fed back.
"""
component Feedback
  "First real-valued input signal"
  u1 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -110, "y1": 450, "x2": -10, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Second real-valued input signal"
  u2 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {
          "iconName": "default",
          "x1": 450,
          "y1": 1010,
          "x2": 550,
          "y2": 1110,
          "rot": 270
        }
      },
      "tags": []
    }
  }
  "Real-valued output signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
relations
  "Calculates output as the difference between the reference input and feedback input"
  y = u1 - u2
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Feedback.svg"}
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

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

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

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

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