---
title: Variation of parameters and the impulse response
heading: A formula for any input
eyebrow: A8 · Lesson 27 · Variation of parameters
xp: 40
---

::: hook
Guessing the forced response works for steps, exponentials and sines. Real inputs are messier: a speech waveform, a sensor's noise, a pulse train with odd timing. **Variation of parameters** handles any input with an integral instead of a guess. Pushed one step further, it says something remarkable: if you know how a linear circuit responds to a single sharp kick, its **impulse response**, you know how it responds to everything. Every input is a stream of tiny kicks, and the output adds up their responses. That idea, convolution, is the foundation of signals and systems.
:::

::: play
- The solid curve is the impulse response $h(t)$ of $\ddot y + 2\zeta\dot y + y = 0$: what happens after one sharp kick.
- The dashed curve is its running integral, which is the step response: a step is a steady stream of kicks.
- Change $\zeta$. The step response settles where the impulse response's total area says it should.
:::
:::

```sim plot
view: graph
x: t = 0..15
y: y = -0.6..1.6
slider: zeta = 0.05..0.95 step 0.05 = 0.2
plot: exp(-zeta*t)*sin(sqrt(1 - zeta^2)*t)/sqrt(1 - zeta^2) | label: impulse response h(t) | samples: 800
plot: 1 - exp(-zeta*t)*(cos(sqrt(1 - zeta^2)*t) + zeta/sqrt(1 - zeta^2)*sin(sqrt(1 - zeta^2)*t)) | label: step response | dashed | color: ch2 | samples: 800
readout: step response settles to = 1
readout: peak of step response = 1 + exp(-pi*zeta/sqrt(1 - zeta^2)) | digits: 4
```

::: predict
## You know a circuit's response to one sharp kick at $t = 0$. Can you predict its response to a long, arbitrary input?

- [x] Yes: treat the input as many small kicks and add their responses
- [ ] No: each input needs its own solution
- [ ] Only for sinusoidal inputs
- [ ] Only if the circuit is first order

::: reveal
Yes. Because the circuit is linear and doesn't change over time, the response to a kick of size $g(s)\,ds$ at time $s$ is $g(s)\,ds\,h(t - s)$, and the responses to all the kicks simply add:

$$y(t) = \int_0^t h(t - s)\,g(s)\,ds$$

That's the **convolution** of $h$ and $g$. C9 is largely about this integral.
:::
:::

::: nameit
## Variation of parameters

For $\ddot y + p\dot y + qy = g(t)$ with homogeneous solutions $y_1$, $y_2$ and Wronskian $W = y_1\dot y_2 - \dot y_1y_2$, a particular solution is

$$y_p = -y_1\int\frac{y_2\,g}{W}\,dt + y_2\int\frac{y_1\,g}{W}\,dt$$

It comes from letting the constants in $c_1y_1 + c_2y_2$ vary with time, $u_1(t)y_1 + u_2(t)y_2$, and imposing $\dot u_1y_1 + \dot u_2y_2 = 0$ to keep the algebra simple. It needs no guess and works for any continuous $g$, even with variable $p$ and $q$.

## The impulse response

The **impulse response** $h(t)$ is the solution starting at rest that's kicked at $t = 0$: $h(0) = 0$, $\dot h(0) = 1$. For constant coefficients, variation of parameters rearranges into the **convolution** formula: starting from rest,

$$y(t) = \int_0^t h(t - s)\,g(s)\,ds$$

| Equation | $h(t)$ |
|---|---|
| $\dot y + ay = g$ | $e^{-at}$ |
| $\ddot y + \omega^2y = g$ | $\frac{\sin\omega t}{\omega}$ |
| roots $r_1 \ne r_2$ | $\frac{e^{r_1t} - e^{r_2t}}{r_1 - r_2}$ |
| roots $-\sigma \pm j\omega_d$ | $\frac{e^{-\sigma t}\sin\omega_dt}{\omega_d}$ |

The step response is $\int_0^th(s)\,ds$: the impulse response's running area.
:::

::: example
## Use convolution to find the step response of $\ddot y + 3\dot y + 2y = 1$ from rest.

::: solution
1. **Impulse response.** The roots are $-1$ and $-2$, so
   $$h(t) = e^{-t} - e^{-2t}$$
2. **Convolve with the step.**
   $$\begin{aligned} y &= \int_0^t\left(e^{-(t - s)} - e^{-2(t - s)}\right)ds \\ &= (1 - e^{-t}) - \tfrac{1}{2}(1 - e^{-2t}) \\ &= \tfrac{1}{2} - e^{-t} + \tfrac{1}{2}e^{-2t} \end{aligned}$$
3. **Compare.** It's the same answer undetermined coefficients gives.

**Answer:** $y = \tfrac{1}{2} - e^{-t} + \tfrac{1}{2}e^{-2t}$.
:::
:::

::: example
## Find a particular solution of $\ddot y + y = \sec t$, for which no guess works.

::: solution
1. **Homogeneous solutions.** $y_1 = \cos t$ and $y_2 = \sin t$, with Wronskian $W = 1$.
2. **Variation of parameters.**
   $$\begin{aligned} y_p &= -\cos t\int\sin t\sec t\,dt \\ &\quad + \sin t\int\cos t\sec t\,dt \\ &= \cos t\ln|\cos t| + t\sin t \end{aligned}$$

**Answer:** $y_p = \cos t\ln|\cos t| + t\sin t$.
:::
:::

::: example
## Find the impulse response of $\ddot y + 3\dot y + 2y = \delta(t)$ and its peak.

::: solution
1. **What an impulse does.** An impulse leaves the system at rest in position but with $\dot y(0^+) = 1$.
2. **Fit the homogeneous solution.** With roots $-1$ and $-2$, $h = c_1e^{-t} + c_2e^{-2t}$ with $h(0) = 0$ and $\dot h(0) = 1$, so
   $$h = e^{-t} - e^{-2t}$$
3. **Time of the peak.** It peaks where
   $$-e^{-t} + 2e^{-2t} = 0$$
   so $e^{-t} = \frac12$, at $t = \ln 2 = 0.693$.
4. **Peak value.**
   $$\begin{aligned} h &= \frac12 - \frac14 \\ &= 0.25 \end{aligned}$$
5. **Why it matters.** Every other response of this system is a convolution with this one curve.

**Answer:** $h = e^{-t} - e^{-2t}$, which peaks at 0.25 when $t = 0.693$.
:::
:::

::: check
given: w = 2 | 5 | 10
answer: w

## What is the Wronskian of $\cos\given{w}t$ and $\sin\given{w}t$?

::: right
Right. $\cos(\omega t)\,\omega\cos(\omega t) + \omega\sin(\omega t)\sin(\omega t) = \omega$ = {answer}.
:::

::: misses
- [1] Each derivative brings out a factor $\omega$.
- [any] Not yet. $y_1\dot y_2 - \dot y_1y_2$.
:::
:::

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

## A system has characteristic roots $-\given{a}$ and $-\given{b}$. What is its impulse response at $t$ = {t}?

::: right
Right. $\frac{e^{-at} - e^{-bt}}{b - a}$ = {answer}.
:::

::: misses
- [exp(-a*t) - exp(-b*t)] Divide by $r_1 - r_2 = b - a$ so that $\dot h(0) = 1$.
- [any] Not yet. $\frac{e^{r_1t} - e^{r_2t}}{r_1 - r_2}$.
:::
:::

::: check
given: w = 2 | 4; t = 0.3 | 0.5
answer: sin(w*t)/w
tolerance: 0.5%

## What is the impulse response of $\ddot y + \given{w}^2y = g$ at $t$ = {t}?

::: right
Right. $\frac{\sin\omega t}{\omega}$ = {answer}.
:::

::: misses
- [sin(w*t)] Divide by $\omega$ so the starting velocity is 1.
- [cos(w*t)] A kick sets the velocity, not the position: it starts at 0.
- [any] Not yet. $h(0) = 0$, $\dot h(0) = 1$.
:::
:::

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

## Using $h(t) = e^{-t} - e^{-2t}$, what is the step response of $\ddot y + 3\dot y + 2y = 1$ at $t$ = {t}?

::: right
Right. $\int_0^th = \frac{1}{2} - e^{-t} + \frac{1}{2}e^{-2t}$ = {answer}.
:::

::: misses
- [exp(-t) - exp(-2*t)] That's $h$ itself. The step response is its running integral.
- [any] Not yet. Integrate $h$ from 0 to $t$.
:::
:::

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

## A first-order system $\dot y + \given{a}y = g$ at rest gets a pulse: $g = 1$ from 0 to $T$ = {T}, then 0. Using convolution with $h = e^{-at}$, what is $y$ at $t$ = {t}?

::: right
Right. $\int_0^Te^{-a(t - s)}ds = \frac{e^{-a(t - T)} - e^{-at}}{a}$ = {answer}.
:::

::: misses
- [exp(-a*(t - T)) - exp(-a*t)] Divide by $a$ from the integral.
- [any] Not yet. Integrate $h(t - s)$ over the pulse, $0 < s < T$.
:::
:::

::: check
kind: choice

## Why can variation of parameters handle inputs that undetermined coefficients can't?

- [x] It builds the particular solution from integrals of the input, so no guess of its form is needed
- [ ] It only works for polynomial inputs
- [ ] It ignores the homogeneous solutions
- [ ] It avoids integration

::: right
Right. Undetermined coefficients needs an input whose derivatives keep the same form. Variation of parameters needs only the homogeneous solutions and the ability to integrate.
:::

::: misses
- [3] It is built from the homogeneous solutions.
- [4] It replaces the guess with integrals.
- [any] What does each method need to know in advance?
:::
:::

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

## Find the impulse response of $\ddot y + (\given{a} + \given{b})\dot y + \given{a}\cdot\given{b}\,y = \delta(t)$.

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

### When does it peak?

::: misses
- [any] $h = \frac{e^{-at} - e^{-bt}}{b - a}$; set $\dot h = 0$.
:::
:::

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

### What is the step response's final value?

::: misses
- [any] The area under $h$, or set the derivatives to zero.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.5..3, t = 0..5

## The impulse response of $\dot y + ay = \delta(t)$ is $h = e^{-at}$. Find the step response by convolution.

::: step
answer: (1 - exp(-a*t))/a

### What is $\int_0^te^{-a\tau}\,d\tau$?
:::

::: right
Right. The step response is the running integral of the impulse response.
:::
:::

::: explain
## Explain why a linear, time-invariant circuit's response to any input is the convolution of the input with its impulse response.

::: model
Think of the input as a sequence of very short pulses: the slice at time $s$ is a kick of size $g(s)\,ds$. Because the circuit doesn't change over time, a kick at time $s$ produces the same shaped response as one at 0, just delayed: $g(s)\,ds\,h(t - s)$. Because the circuit is linear, the responses to all the separate kicks add up. Adding them over every $s$ from 0 to $t$ gives the integral $\int_0^th(t - s)g(s)\,ds$.
:::
:::

::: practice

::: check
given: a = 2 | 5; t = 0.2 | 1
answer: exp(-a*t)
tolerance: 0.5%

## What is the impulse response of $\dot y + \given{a}y = g$ at $t$ = {t}?

::: misses
- [any] $e^{-at}$.
:::
:::

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

## For $\dot y + \given{a}y = 1$ from rest, convolution with $h = e^{-at}$ gives what at $t$ = {t}?

::: misses
- [1 - exp(-a*t)] Divide by $a$.
- [any] $\int_0^te^{-a(t - s)}ds$.
:::
:::

::: check
given: s = 0.5 | 1; w = 2 | 3; t = 0.5 | 1
answer: exp(-s*t)*sin(w*t)/w
tolerance: 0.5%

## A system has roots $-\given{s} \pm j\given{w}$. What is its impulse response at $t$ = {t}?

::: misses
- [exp(-s*t)*sin(w*t)] Divide by $\omega_d$.
- [any] $\frac{e^{-\sigma t}\sin\omega_dt}{\omega_d}$.
:::
:::
:::
