Linear Constant Coefficient Discrete Difference Equations

From PrattWiki
Revision as of 21:29, 23 September 2024 by DukeEgr93 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

This is a step-by-step guide for finding the impulse response for Linear Constant Coefficient Discrete Difference Equations (LCCDDE). Once you find the impulse response, you can find the response to any other input signal.

Basic First Difference

Let's start with a very simple case:

\( a_0\,y[n]+a_1\,y[n-1]=x[n] \)

To find the impulse response $$h[n]$$ we want to solve:

\( a_0\,h[n]+a_1\,h[n-1]=\delta[n] \)

where $$\delta[n]$$ is the discrete impulse, which is 1 when $$n=0$$ and 0 everywhere else. Assuming $$y[n]=0$$ for all $$n<0$$, we could make a table to see how the impulse response progresses:

\( \begin{array}{cccc} n & h[n-1] & \delta[n] & h[n]=\frac{\delta[n]-a_1\,h[n-1]}{a_0}\\ -1 & 0 & 0 & 0 \\ 0 & 0 & 1 & \frac{1}{a_0} \\ 1 & \frac{1}{a_0} & 0 & \frac{0-a_1\frac{1}{a_0}}{a_0} = \frac{1}{a_0}\left(-\frac{a_1}{a_0}\right) \\ 2 & \frac{1}{a_0}\left(-\frac{a_1}{a_0}\right) & 0 & \frac{0-a_1\frac{1}{a_0}\left(-\frac{a_1}{a_0}\right)}{a_0} = \frac{1}{a_0}\left(-\frac{a_1}{a_0}\right)^2 \\ \end{array} \)

As the pattern continues, it looks like we have:

\( h[n]=\begin{cases} n\lt 0, & 0 \\n\geq 0 & \frac{1}{a_0}\left(-\frac{a_1}{a_0}\right)^n\end{cases} \)

or in other words:

\( h[n]=\frac{1}{a_0}\left(-\frac{a_1}{a_0}\right)^n\,u[n] \)

General Homogeneous Solution

For LCCDDE problems, we can use a general homogeneous solution of $$y_h[n]=C\,\gamma^n$$, where $$\gamma$$ is some constant based on the coefficients. The impulse response for the basic first difference will generally be the same as the homogeneous response except for the $$h[0]=1$$ time. We can treat that more like an initial condition than a forcing function as follows:

\( a_0\,y[n]+a_1\,y[n-1]=x[n] \)

To find the impulse response $$h[n]$$ we want to solve:

\( \begin{align*} a_0\,h[n]+a_1\,h[n-1] &= 0, n\gt 0\\ h[n] &= 0, n\lt 0\\ h[n] &= \frac{1}{a_1}, n=0 \end{align*} \)

Substituting in $$h[n]=y_h[n]=C\,\gamma^n$$ for the $$n>0$$ equation gives:

\( \begin{align*} a_0\,C\,\gamma^n+a_1\,C\,\gamma^{n-1} &= 0\\ C\,\gamma^{n}\,\left(a_0+a_1\gamma^{-1}\right) &=0 \end{align*} \)

For that second equation to work, we either need $$C=0$$ (trivial case), $$\gamma^n=0$$ impossible for all $$n$$ unless $$\gamma=0$$, or $$\gamma=-\frac{a_1}{a_0}$$.

To figure out $$C$$, we can look at the $$n=0$$ case: $$y_h[0] = C = \frac{1}{a_1}$$. Since $$h[n]=0$$ for $$n<0$$ we can put the homogeneous solution together with a step function to get:

\( h_n=\frac{1}{a_1}\left(-\frac{a_1}{a_0}\right)^n\,u[n] \)

From this point forward, we can use a technique that is very similar to using $$y_h(t)=C\,e^{st}$$ for differential equations; instead of getting a characteristic polynomial by replacing $$\frac{d^ky(t)}{dt^k}$$ with $$s^k$$, we will replace $$y[n-k]$$ with $$\gamma^{-k}$$. Instead of solving for $$s$$ as an exponent, we will solve for $$\gamma$$ as a geometric constant.

Example 1: Fits Basic Case

Imagine you want to solve for the impulse response of

\( 3\,y[n]-2\,y[n-1]=x[n] \)
  • Find $$\gamma$$ but replace all $$x[n]$$ with 0 and all $$y[n-k]$$ with $$\gamma^{-k}$$:
    \(\begin{align*}3-2\gamma^{-1}&=0\\ \gamma&=\frac{2}{3}\end{align*}\)
  • Find $$C$$ by putting $$C\,\gamma^n\,u[n]$$ in for $$n=0$$ case:
    \(\begin{align*}3\,C\,\left(\frac{2}{3}\right)^0\,u[0]-2\,C\,\left(\frac{2}{3}\right)^{-1}\,u[-1]&=1\\ 3\,C+0&=1\\ C&=\frac{1}{3}\end{align*}\)
  • $$h[n] =\frac{1}{3}\left(\frac{2}{3}\right)^n\,u[n]$$

Example 2: Fits Basic Case After Scaling and Shifting

Imagine you want to solve for the impulse response of

\( 6\,y[n+1]=2\,x[n+1]+4\,y[n] \)
  • Adjust the equation so that all the $$y$$ are on the left, all the $$x$$ are on the right, all the shifts are $$n-k$$ where $$k\geq 0$$ (the system is LTI so we can shift everything by the same amount), and $$x[n]$$ has a coefficient of 1:
\(\begin{align*} 6\,y[n+1]&=2\,x[n+1]+4\,y[n]\\ 6\,y[n+1]-4\,y[n]&=2\,x[n+1]\\ 3\,y[n]-2\,y[n-1]&=x[n] \end{align*}\)
  • At this point, this perfectly fits the basic case again where $$x[n]$$ is alone on the right and unshifted relative to the unshifted $$y[n]$$ on the right.
  • As above, $$h[n] =\frac{1}{3}\left(\frac{2}{3}\right)^n\,u[n]$$

More Complicated Forcing Function

All the cases above could be re-written to have a single $$x[n]$$ on the right, and at that point, all the $$y[n-k]$$ had $$k\geq 0$$ meaning, among other things, the system was causal. If the right-hand-side ends up more complicated than $$x[n]$$, it turns out that you can still solve the problem by re-writing things such that the left side still contains $$y[n-k]$$ with all $$k\geq 0$$, solving as if the right side at that point were merely $$z[n]$$, and then relating $$z[n]$$ to the more complicated right side using scaling and shifting.

Reminder: Scaled Convolutions with Impulses

Recall that $$z[n]\ast a\,\delta[n-k]=a\,z[n-k]$$. That means that something like $$3\,x[n]-4\,x[n-2]$$ could also be written as $$x[n]\ast\left(3\,\delta[n]-4\,\delta[n-2]\right)$$

Back to Basics

Let's start with a relatively simple case:

\( 3\,y[n]-2\,y[n-1]=3\,x[n]-4\,x[n-2] \)

All the $$y$$ shifts are 0 or more to the right so that part is all good. The issue now is the complicated right side - even if we divide by 3 to get the $$x[n]$$ alone there will be more than just $$x[n]$$ over there. So let's start by just replacing all that with $$z[n]$$:

\( 3\,y[n]-2\,y[n-1]=z[n] \)

and then solve for the impulse response of this new system, which we can call $$h'[n]$$. We can solve for that using the methods above and get $$h'[n]=\frac{1}{2}\left(\frac{2}{3}\right)^{n}\,u[n]$$

Hooray for Math!

Since we know the relationship between $$x[n]$$ and $$z[n]$$:

\( x[n]=z[n]\ast\left(3\,\delta[n]-4\,\delta[n-2]\right) \)

we also know the relationship between $$h[n]$$ and $$h'[n]$$:

\( h[n]=h'[n]\ast\left(3\,\delta[n]-4\,\delta[n-2]\right) \)