---
url: /dyad/stable/stdlib/DiscreteComponents/components/DiscreteDerivative.md
description: >-
  Dyad DiscreteDerivative docs.  Discrete-time derivative filter, corresponding
  to the transfer function
---

# `DiscreteDerivative` {#DiscreteDerivative}

Discrete-time derivative filter, corresponding to the transfer function

$$Y(z) = k \dfrac{z - 1}{T_s z} U(z)$$

where $T_s$ is the sample time.

## Usage {#Usage}

`DiscreteComponents.DiscreteDerivative(k=1)`

## Parameters: {#Parameters:}

|             Name | Description | Units |             Default value |
| ----------------:| -----------:| -----:| -------------------------:|
|             `Ts` |             |     – |              SampleTime() |
| `initialization` |             |     – | DiscreteCom...t(; y0=0.0) |
|              `k` |        Gain |     – |                         1 |

## 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) &= \frac{\left(  - Shift(t, -1)\left( u\left( t \right) \right) + u\left( t \right) \right) ~ k}{SampleTime(ShiftIndex(InferredClock.Inferred(UUID("af6a88b6-0466-4fa8-8126-016f6ad0a4c5")), 0), nothing)}
\end{align}
$$

## Source {#Source}

````dyad
"""
Discrete-time derivative filter, corresponding to the transfer function
```math
Y(z) = k \dfrac{z - 1}{T_s z} U(z)
```

where ``T_s`` is the sample time.
"""
component DiscreteDerivative@[input clk extends Discrete]
  "Input signal"
  u = RealInput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Output signal"
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter Ts::Real = SampleTime()
  "Gain"
  parameter k::Real = 1
  structural parameter initialization::InitialCondition = DiscreteComponents.InitialCondition.InitialOutput(y0 = 0.0)
relations
  y@clk = k * (u@clk - u@(clk-1)) / Ts
  switch initialization
    case InitialOutput
      initial u@(clk-1) = -(Ts / k * initialization.y0 - u@clk)
    case SteadyState
      initial u@(clk-1) = u@clk
    case InitialState
      initial u@(clk-1) = initialization.x0
  end
metadata {
  "Dyad": {"icons": {"default": "dyad://DiscreteComponents/DiscreteDerivative.svg"}}
}
end
````

````dyad
"""
Discrete-time derivative filter, corresponding to the transfer function
```math
Y(z) = k \dfrac{z - 1}{T_s z} U(z)
```

where ``T_s`` is the sample time.
"""
component DiscreteDerivative
  "Input signal"
  u = RealInput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Output signal"
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter Ts::Real = SampleTime()
  "Gain"
  parameter k::Real = 1
  structural parameter initialization::InitialCondition = DiscreteComponents.InitialCondition.InitialOutput(y0 = 0.0)
relations
  y@clk = k * (u@clk - u@(clk-1)) / Ts
  switch initialization
    case InitialOutput
      initial u@(clk-1) = -(Ts / k * initialization.y0 - u@clk)
    case SteadyState
      initial u@(clk-1) = u@clk
    case InitialState
      initial u@(clk-1) = initialization.x0
  end
metadata {
  "Dyad": {"icons": {"default": "dyad://DiscreteComponents/DiscreteDerivative.svg"}}
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
