# Given the input and the output, how to determine the impulse response?

I would like to find the impulse response, $h[n]$, of an LTI system given the input

$$x[n] = [1,-3,2]$$

and the output

$$y[n] = [1,-1,-4,4]$$

I know that $y[t]=x[t]*h[t]$, but I am having hard time to figure out the right way to calculate the impulse response. I know very little about signal processing, so if you don't mind giving an easy explanation, then I appreciate it. Or, if it's possible to do an example, that's better.

## migrated from math.stackexchange.comSep 11 '17 at 13:44

This question came from our site for people studying math at any level and professionals in related fields.

From the lengths of the input and the output, we conclude that the impulse response has length $2$. Thus, the output is given by

$$y_k = h_0 x_k + h_1 x_{k-1}$$

We then have an overdetermined system of $4$ linear equations in $h_0$ and $h_1$

$$\begin{bmatrix} x_0 & 0\\ x_1 & x_0\\ x_2 & x_1\\ 0 & x_2\end{bmatrix} \begin{bmatrix} h_0\\ h_1\end{bmatrix} = \begin{bmatrix} y_0\\ y_1\\ y_2\\ y_3\end{bmatrix}$$

Using Python + SymPy:

>>> from sympy import *
>>> X = Matrix([[ 1, 0],
[-3, 1],
[ 2,-3],
[ 0, 2]])
>>> y = Matrix([1,-1,-4,4])
>>> h = (X.T * X)**-1 * X.T * y
>>> h
Matrix([
,
])


This is the least-squares solution. It is easy to verify that it is also a solution of the original linear system (otherwise the problem would be ill-posed). Hence,

$$\boxed{y_k = x_k + 2 x_{k-1}}$$

• Could you elaborate on how you've concluded the impulse length? – Dan M. Jan 6 at 20:39
• @DanM. When convolving finite discrete-time signals, the length of the output is the sum of the lengths of the signals being convolved minus $1$. – Rodrigo de Azevedo Jan 6 at 20:58
• What if they can be padded with zeroes? I.e. you only know the non-zero length of input. – Dan M. Jan 6 at 21:01
• @DanM. Such length is enough. – Rodrigo de Azevedo Jan 7 at 0:24

$\mathcal Z$-transforming the input and the output and then dividing them, we obtain the transfer function

$$\begin{array}{rl} H (z) &= \dfrac{1 - z^{-1} - 4 z^{-2} + 4 z^{-3}}{1 - 3 z^{-1} + 2 z^{-2}}\\\\ &= \dfrac{z^3 - z^2 - 4 z + 4}{z (z^2 - 3 z + 2)}\\\\ &= \dfrac{(z-1) (z-2) (z+2)}{z (z-1) (z-2)}\\\\ &= \dfrac{z+2}{z} = \color{blue}{1 + 2 z^{-1}}\end{array}$$

Computing the inverse $\mathcal Z$-transform of $H (z)$, we finally obtain the impulse response.