---
title: Steps, impulses and convolution
heading: Switched inputs, sudden kicks, and the response to anything
eyebrow: A8 · Lesson 33 · Steps, impulses and convolution
xp: 40
---

::: hook
Circuits are switched: a source turns on at one moment and off at another, a digital line goes high for 1 ms, a lightning strike delivers its charge in a microsecond. The Laplace transform handles these with two tools. A **delayed step** turns an input on at any time, and its transform just picks up a factor $e^{-as}$. An **impulse** is a kick so short that only its area matters, and the response to it, the **impulse response**, determines the response to every other input through **convolution**.
:::

::: play
- A first-order system with time constant $\tau$ is driven by a 1 V pulse lasting $T$.
- While the pulse is on, the output rises as $1 - e^{-t/\tau}$; when it ends, the output decays from wherever it reached.
- Make the pulse much shorter than $\tau$. The output barely rises, and its peak becomes proportional to the pulse's area: the system only sees how much was delivered.
:::

```sim plot
view: graph
x: t = 0..10 ms
y: v = 0..1.1 V
slider: T = 0.1..5 step 0.1 = 1 ms
slider: tau = 0.5..3 step 0.1 = 1 ms
plot: step(T - t) | dashed | color: ch2 | label: pulse | samples: 600
plot: (1 - exp(-t/tau)) - step(t - T)*(1 - exp(-(t - T)/tau)) | label: output | samples: 600
readout: peak output = 1 - exp(-T/tau) | digits: 4
```

::: predict
## A pulse of 10 V lasting 1 µs drives an RC circuit with $\tau$ = 1 ms. About how high does the output get?

- [ ] 10 V
- [ ] 6.3 V
- [x] About 10 mV
- [ ] Nothing at all

::: reveal
About 10 mV: $10(1 - e^{-0.001}) = 0.009995$ V. A pulse a thousand times shorter than $\tau$ acts like an impulse of area $10 \times 10^{-6} = 10^{-5}$ V·s, and the response jumps to the area divided by $\tau$, then decays.
:::
:::

::: nameit
## Delayed steps

The unit step $u(t - a)$ is 0 before $t = a$ and 1 after. A pulse from 0 to $T$ is $u(t) - u(t - T)$. The **shift theorem**:

$$\mathcal{L}\{f(t - a)u(t - a)\} = e^{-as}F(s)$$

So a pulse's transform is $\frac{1 - e^{-Ts}}{s}$, and a linear system's response to it is the step response minus the same step response delayed by $T$.

## The impulse

The impulse $\delta(t)$ is the limit of a pulse of area 1 whose width goes to zero. Its transform is 1. Applied to a system, it changes a state instantly: a current impulse of area $Q$ into a capacitor adds charge $Q$ and jumps the voltage by $Q/C$. The **impulse response** $h(t)$ has transform $H(s)$, the **transfer function**: for $a\ddot y + b\dot y + cy = x$, $H(s) = \frac{1}{as^2 + bs + c}$.

## Convolution

For any input $x(t)$ starting at 0, from rest:

$$y(t) = \int_0^th(\tau)\,x(t - \tau)\,d\tau, \qquad Y(s) = H(s)X(s)$$

The output is a weighted sum of past inputs, each weighted by how much of a kick from that long ago still remains. Multiplication of transforms corresponds to convolution in time.
:::

::: example
## A 5 V pulse lasting 1 ms drives an RC circuit with $\tau$ = 1 ms. Find the peak output and the output at 2 ms.

::: solution
1. **During the pulse.** The output charges as $v = 5(1 - e^{-t/\tau})$, reaching
   $$\begin{aligned} v(1\ \text{ms}) &= 5(1 - e^{-1}) \\ &= 3.16\ \text{V} \end{aligned}$$
2. **After the pulse.** Then the input is zero and the output decays from there:
   $$v = 3.16e^{-(t - 1\,\text{ms})/\tau}$$
3. **At 2 ms.**
   $$\begin{aligned} v(2\ \text{ms}) &= 3.16e^{-1} \\ &= 1.16\ \text{V} \end{aligned}$$
4. **Another route.** The same result comes from the shift theorem: the step response minus the step response delayed by 1 ms.

**Answer:** the output peaks at 3.16 V at 1 ms and is down to 1.16 V at 2 ms.
:::
:::

::: example
## A charge of 1 µC is dumped into a 1 µF capacitor in parallel with 1 kΩ, starting from 0 V. Describe the voltage.

::: solution
1. **The jump.** The current is an impulse of area $Q = 1$ µC, so the voltage jumps to $Q/C = 1$ V at $t = 0^+$.
2. **The decay.** It then decays through the resistor:
   $$v = e^{-t/1\,\text{ms}}\ \text{V}$$
3. **Impulse response.** The impulse response of this circuit (volts per coulomb) is
   $$h = \frac1Ce^{-t/RC}$$
4. **How fast the charge arrives.** Whether the charge arrives in 1 ns or 1 µs makes no visible difference, as long as it's far shorter than the 1 ms time constant.

**Answer:** the voltage jumps to 1 V and then decays as $e^{-t/1\,\text{ms}}$ V.
:::
:::

::: example
## Find the response of $\dot y + y = x$ to a unit pulse from 0 to 1 by convolution, at $t = 2$.

::: solution
1. **Impulse response.** The impulse response is $h = e^{-t}$.
2. **Convolve over the pulse.** For $t > 1$, the pulse contributes only for $\tau$ between $t - 1$ and $t$:
   $$\begin{aligned} y(t) &= \int_{t-1}^{t}e^{-\tau}\,d\tau \\ &= e^{-(t-1)} - e^{-t} \\ &= (e - 1)e^{-t} \end{aligned}$$
3. **At $t = 2$.**
   $$\begin{aligned} y(2) &= (e - 1)e^{-2} \\ &= 0.233 \end{aligned}$$
4. **Check by step difference.** The step-difference method gives the same:
   $$\begin{aligned} &(1 - e^{-2}) - (1 - e^{-1}) \\ &= e^{-1} - e^{-2} \end{aligned}$$

**Answer:** $y(2) = (e - 1)e^{-2} = 0.233$.
:::
:::

::: check
given: T = 0.5 | 1 | 2; tau = 1 | 2; V = 5 | 10
answer: V*(1 - exp(-T/tau))
unit: V
tolerance: 0.5%

## A {V} V pulse lasting {T} ms drives a first-order system with $\tau$ = {tau} ms. What is the peak output?

::: right
Right. It rises until the pulse ends: $V(1 - e^{-T/\tau})$ = {answer}.
:::

::: misses
- [V] It doesn't have time to reach the full value.
- [V*exp(-T/tau)] That's how far it is from the full value.
- [any] Not yet. The peak is reached as the pulse ends.
:::
:::

::: check
given: Q = 1 | 4.7; C = 0.1 | 2.2
answer: Q/C
unit: V
tolerance: 0.5%

## A current impulse delivers {Q} µC to a {C} µF capacitor. By how much does its voltage jump?

::: right
Right. $\Delta v = Q/C$ = {answer}.
:::

::: misses
- [Q*C] Voltage is charge divided by capacitance.
- [any] Not yet. $Q = C\Delta v$.
:::
:::

::: check
given: a = 1 | 2 | 0.5; s = 2 | 4
answer: exp(-a*s)/s
tolerance: 0.5%

## What is the transform of $u(t - \given{a})$, a step delayed by {a}, at $s$ = {s}?

::: right
Right. $\frac{e^{-as}}{s}$ = {answer}.
:::

::: misses
- [1/s] The delay multiplies by $e^{-as}$.
- [exp(-a*s)] Include the step's own $\frac1s$.
- [any] Not yet. Use the shift theorem.
:::
:::

::: check
given: t = 1.5 | 2 | 3
answer: (exp(1) - 1)*exp(-t)
tolerance: 0.5%

## $\dot y + y = x$ starts at rest, and $x$ is a unit pulse from 0 to 1. What is $y$ at $t$ = {t}?

::: right
Right. $(e - 1)e^{-t}$ = {answer}.
:::

::: misses
- [exp(-t)] That's the impulse response; the pulse has width 1, not 0.
- [any] Not yet. Convolve with $h = e^{-t}$ over the pulse.
:::
:::

::: check
kind: parts
given: a = 1 | 2; b = 3 | 5

## A system obeys $\ddot y + (\given{a} + \given{b})\dot y + \given{a}\cdot\given{b}\,y = x$.

::: part
answer: 1/(a*b)
tolerance: 0.5%

### What is $H(0)$, its gain for a constant input?

::: misses
- [any] $H(s) = \frac{1}{s^2 + (a + b)s + ab}$.
:::
:::

::: part
answer: (exp(-a) - exp(-b))/(b - a)
tolerance: 0.5%

### What is its impulse response at $t = 1$?

::: misses
- [any] $h = \frac{e^{-at} - e^{-bt}}{b - a}$, from partial fractions of $H(s)$.
:::
:::
:::

::: check
kind: derivation
vars: tau = 0.5..3, T = 0.1..2, t = 2..6

## A first-order system with time constant $\tau$ gets a unit pulse of width $T$. Find the output after the pulse.

::: step
answer: 1 - exp(-T/tau)

### What is the output when the pulse ends?
:::

::: step
answer: (1 - exp(-T/tau))*exp(-(t - T)/tau)

### What is it at a later time $t$?
:::

::: right
Right. It decays from its value at the end of the pulse, with the same time constant.
:::
:::

::: check
kind: python

## On a grid with $\Delta t$ = 0.001 ms out to 4 ms, convolve the RC impulse response $h = \frac1\tau e^{-t/\tau}$ ($\tau$ = 1 ms) with a 5 V pulse lasting 1 ms. Set `v2` to the output at 2 ms.

```python starter
import numpy as np

v2 = 0.0
print(v2)
```

```python solution
import numpy as np

dt = 0.001
t = np.arange(0, 4, dt)
h = np.exp(-t)
x = 5.0 * (t < 1)
v = np.convolve(h, x)[:len(t)] * dt
v2 = v[2000]
print(v2)
```

```python tests
import math
exact = 5 * (1 - math.exp(-1)) * math.exp(-1)
assert abs(v2 - exact) < 0.005, f"The convolution should match 5(1 - e^-1)e^-1 = {exact:.4f} V; got {v2:.4f}."
```

::: right
Right. The discrete sum reproduces the pulse response, and it would work just as well for a recorded input with no formula.
:::
:::

::: explain
## Why does the impulse response alone determine a linear system's response to every input?

::: model
Any input can be thought of as a rapid sequence of tiny impulses: over a short interval $d\tau$ at time $\tau$, the input $x(\tau)$ delivers an impulse of area $x(\tau)\,d\tau$. Because the system is linear, each of those produces its own copy of the impulse response, scaled by its area, and because the system doesn't change with time, the copy starting at $\tau$ is just $h$ shifted to start there. Adding all the copies gives $\int h(t - \tau)x(\tau)\,d\tau$, the convolution. So knowing how the system rings after one kick is enough to predict what it does with any input at all.
:::
:::

::: practice

::: check
given: T = 0.01..5; tau = 0.1..5
answer: 1 - exp(-T/tau)
tolerance: 0.5%

## Peak of a unit pulse response, width {T}, $\tau$ = {tau}?

::: misses
- [any] $1 - e^{-T/\tau}$.
:::
:::

::: check
given: Q = 0.1..100; C = 0.01..100
answer: Q/C
unit: V
tolerance: 0.5%

## Voltage jump in volts for {Q} µC into {C} µF?

::: misses
- [any] $Q/C$.
:::
:::
:::
