# How to get difference equation from this block diagram

I was posed a very similiar block diagram in my exam from this book (Alan V Oppenheim Ronald W Schafer - Discrete-Time Signal Processing-Pearson Education) but couldn't solve it:

I want to solve for $$y[n]+a_{a}y[n-1]+...=b_{a}x[n]+b_{b}x[n-1]+...$$ I tried using w[n] but always failed, since both, w[n] and y[n] depend on w[n-1] always leaving one unknown. Here's how far I got: \\ \begin{aligned} w[n] &=x[n-1]+y[n-1]+2w[n-1]\\ y[n] &= 2y[n-1]+2w[n-1] -2x[n] +2w[n] \end{aligned}

I also know, that the solution to the problem is: $$y[n]-8y[n-1]=-2x[n]+6x[n-1]+2x[n-2]$$

Any help is greatly appreciated :) Thanks in advance for any help :)

• Are you familiar with the technique of Mason's gain formula ?
– AJN
May 19 at 13:25
• Can you mark the nodes $y[n-1]$ and $w[n-1]$ just like you marked $w[n]$ ? It looks like the node marked as $w[n-1]$ and $y[n-1]$ are the same node ? OR, the bottom most node should have been marked $w[n]$ instead. To, me it looks like there are three unknowns and three equations.
– AJN
May 19 at 13:35
• @AJN No I didn't, thanks for that tip! But that seems overkill for this system, and wasn't part of our lecture, so I guess it should be solvable without that. Also, the very bottom not and w[n] are the same since their connecting branch has a gain of 1. The node to the right of w[n] =! y[n-1] I think, since it's sum of y[n-1] and w[n-1] May 20 at 7:25
• If you don't get an answer here, consider migrating this question to Signal processing SE.
– AJN
May 21 at 4:19

You can label each node and form a matrix equation: You get equations: \begin{align}x_0&=x[n]\\ x_1&=-x_0+x_3+x_4\\ x_2&=2x_1\\ x_3&=z^{-1}x_0+2x_4\\ x_4&=z^{-1}x_2+z^{-1}x_5\\ x_5&=x_3\end{align} or matrix equation $$\begin{bmatrix} 1&0&0&0&0&0\\1&1&0&-1&-1&0\\0&2&-1&0&0&0\\-z^{-1}&0&0&1&-2&0\\0&0&-z^{-1}&0&1&-z^{-1}\\0&0&0&-1&0&1 \end{bmatrix}\begin{bmatrix}x_0\\x_1\\x_2\\x_3\\x_4\\x_5\end{bmatrix} =\begin{bmatrix}x[n]\\0\\0\\0\\0\\0\end{bmatrix}$$ Your output $$y[n]$$ is equal to $$x_2$$ which takes the solution $$y[n]=-2x[n]\left(\frac{z^{-2}+3z^{-1}-1}{8z^{-1}-1}\right)\hspace{1.5cm}(**)$$ i.e. you get the transfer function $$T(z)=\frac{2z^2-6z-2}{8z-z^2}=\frac{2+6z-2z^2}{z^2-8z}$$ To get the difference equation form we use $$(**)$$ $$y[n]\left(8z^{-1}-1\right)=x[n]\left(2-6z^{-1}-2z^{-2}\right)$$ $$8y[n-1]-y[n]=2x[n]-6x[n-1]-2x[n-2]$$