Linear difference equation [closed]

Give the equation $$y[n]-y[n-1] +\frac14y[n-2]= x[n]$$ With initial conditions $$y[0]=0\\ y[1]= 0$$ Find the step response.

I have been able to get the solution $$y[n] =C_1(\frac12)^n +C_2(\frac12)^n + 1,,$$ I am have problem finding $C_1$ and $C_2$. How do I find $C_1$ and $C_2$?

• given difference equation is correct ? – Arpit Jain Jun 8 '17 at 5:52
• Yes is correct..need to find the step response of the equation. – Didi Jun 8 '17 at 5:55
• It doesn't look sensible to me; 1/4[n-2] doesn't look right. Please proof-read. – Marcus Müller Jun 8 '17 at 6:04
• if difference equation is correct, then isn't it Y[n] = X[n] = Y[n-1] + (1/4) *[n-2]. making transfer function equal to 1 ? – Arpit Jain Jun 8 '17 at 6:06
• so, I think this boils down to a very basic math question: you've got an equation with two unknowns, and you have two known pairs of $n\mapsto Y[n]$. What's stopping you from simply inserting those? Also, how did you get to your solution? Doesn't make much sense to me, since you can rewrite it to $Y[n] = \left(\frac12\right)^n\left(C_1+C_2\right) + 1= \frac{\tilde C}{2^n} + 1$, which only has one unknown, so I think your "solution" really isn't all that good. – Marcus Müller Jun 8 '17 at 7:20

As shown in other answers, one way to solve such problems is using the $\mathcal{Z}$-transform. However, your approach of finding a general and a particular solution also works, but you've got a few things wrong. Since this looks like homework, I'll just try to give you a few essential hints to enable you to solve the problem yourself (and to actually learn something).

You seem to have found the characteristic polynomial and its solutions:

$$\lambda^2-\lambda+\frac14\lambda=\left(\lambda-\frac12\right)^2=0\tag{1}$$

The characteristic polynomial has a double root at $\lambda=\frac12$, which must be taken into account when forming the general solution. That's where you've gone wrong. You treated the double root as two distinct single roots, which doesn't work. The solution of the homogeneous difference equation ($x[n]=0$) has the form

$$y_h[n]=C_1\left(\frac12\right)^n+C_2n\left(\frac12\right)^n,\qquad n\ge 0\tag{2}$$

A particular solution (taking into account the excitation $x[n]=u[n]$) can be found by inspection:

$$y_p[n]=C_3\tag{3}$$

First determine $C_3$ by simply plugging the particular solution $(3)$ into the difference equation. The final solution is then given by

$$y[n]=y_h[n]+y_p[n]\tag{4}$$

The constants $C_1$ and $C_2$ must now be chosen such that the given initial conditions are satisfied.

• I have plugged C3 into the difference equation and got 1 . Final solution Y[n]= C1(1/2)^n + C2n(1/2)^n + 1, so can I just choose the value of C1 and C2 randomly to satisfy the initial conditions – Didi Jun 8 '17 at 10:50
• @Didi: How can you get $1$ for $C_3$? Absolutely impossible. And what do you mean by "choosing $C_1$ and $C_2$ randomly"? The initial conditions have to be satisfied, which gives two equations for two unknowns with one unique solution. No randomness about that. – Matt L. Jun 8 '17 at 10:57
• Ok...I am confused now. C3= C1+C2+1. is this right. – Didi Jun 8 '17 at 11:05
• @Didi: Plug $y_p[n]=C_3$ into the difference equation (ignoring $y_h[n]$ for the moment) and solve for $C_3$. This should be very simple, and it should give you an answer different from $1$. – Matt L. Jun 8 '17 at 11:43

$$y[n]-y[n-1]+\frac{1}{4}y[n-2]=x[n],$$

then it describes a system with the following transfer function:

$$H(z)=\frac{1}{1-z^{-1}+\frac{1}{4}z^{-2}}$$

If $x[n]=u[n]$ is the unit step function, i.e.:

$$u[n]=\begin{cases} 1, & \text{for } n \ge 0\\ 0, & \text{for } n < 0 \end{cases}$$ then its $z$-transform $\displaystyle U(z)=\frac{1}{1-z^{-1}}$ and the unit step response, in $z$-domain, is:

$$Y_u(z)=H(z)U(z)=\frac{1}{(1-z^{-1}+\frac{1}{4}z^{-2})(1-z^{-1})}=\frac{1}{(1-\frac{1}{2}z^{-1})^2(1-z^{-1})},$$

which you can write as:

$$Y_u(z)=\frac{C_1}{(1-\frac{1}{2}z^{-1})^2}+\frac{C_2}{(1-z^{-1})}$$

where $C_1$ and $C_2$ are constants to be determined. Knowing that ($z$-transform tables):

$$\frac{z^{-1}}{(1-az^{-1})^2}\rightleftharpoons nu[n]a^{n-1}$$

and using the time-shift property you can deduce that:

$$\frac{1}{(1-az^{-1})^2}\rightleftharpoons (n+1)u[n+1]a^{n}.$$

Hence,

$$y_u[n]=C_1(n+1)(\frac{1}{2})^{n}u[n+1]+C_2u[n].$$

All you need to do now is to use the initial conditions to get $C_1$ and $C_2$ ($y_u[0]=0$ and $y_u[1]=0$). You will find two equations and both give you $C_1+C_2=0$ which is not sufficient to find the coefficients. You need then to compute $y_u[2]$ which you will find equal to $1$. Using this, you get in the end:

$$y_u[n]=4(u[n]-(n+1)(\frac{1}{2})^{n}u[n+1])$$

• Your PFE is wrong. See the details in my answer. – msm Jun 8 '17 at 10:21
• The final solution in this answer is correct! – Matt L. Jun 8 '17 at 10:55
• (Even though we actually don't want to give full solutions for homework questions.) – Matt L. Jun 8 '17 at 10:55
• @msm Sorry, what does PFE stand for? – Learn_and_Share Jun 8 '17 at 12:25
• @MattL. You're right, I should've just hinted to the derivations. – Learn_and_Share Jun 8 '17 at 12:27

Taking the $z$-transform and applying the initial conditions, $$Y(z)-z^{-1}Y(z)+\frac14z^{-2}Y(z)=X(z)$$ $$Y(z)\left(1-z^{-1}+\frac{1}{4}z^{-2}\right)=X(z)$$ $$\frac{Y(z)}{X(z)}=H(z)=\frac{1}{1-z^{-1}+\frac{1}{4}z^{-2}}=\frac{1}{(1-\frac12z^{-1})^2}=\frac{z^2}{(z-\frac12)^2}$$ Hence, the step response is given by the inverse $z$-transform of $\frac{z^2}{(z-\frac12)^2}\cdot\frac{z}{z-1}$. Can you do it?

Update - Due to a mistake in another answer, I will give a complete answer.

Using partial fraction expansion:

\begin{align} F(z)=\frac{S(z)}{z}=\frac{z^2}{(z-\frac12)^2(z-1)}=\frac{A}{(z-\frac12)^2}+\frac{B}{z-\frac12}+\frac{C}{z-1} \end{align} gives $$C=(z-1)F(z)\biggr\vert_{z=1}=\frac{z^2}{(z-\frac12)^2}\biggr\vert_{z=1}=4$$ $$A=(z-\frac12)^2F(z)\biggr\vert_{z=\frac12}=\frac{z^2}{z-1}\biggr\vert_{z=\frac12}=-\frac12$$ $$B=\frac{d}{dz}\left((z-\frac12)^2F(z)\right)\biggr\vert_{z=\frac12}=\frac{2z(z-1)-z^2}{(z-1)^2}\biggr\vert_{z=\frac12}=\frac{z(z-2)}{(z-1)^2}\biggr\vert_{z=\frac12}=-3$$ Now use a table of $z$-transforms and its properties to find the final result:

$$s[n]=\mathcal{Z}^{-1}\left(\frac{Az}{(z-\frac12)^2}+\frac{Bz}{z-\frac12}+\frac{Cz}{z-1}\right)$$

• I have plugged C3 into the difference equation and got 1 . Final solution Y[n]= C1(1/2)^n + C2n(1/2)^n + 1, so can I just choose the value of C1 and C2 randomly to satisfy the initial conditions? – Didi Jun 8 '17 at 10:48
• @msm: There's a mistake in your final solution: for $n=1$ you get $s[1]=2$, but it should be $0$ (initial conditions), whereas the solution in MedNait's answer appears to be correct. – Matt L. Jun 8 '17 at 10:54
• @MattL. The point was the PFE in the mentioned answer which is wrong. – msm Jun 8 '17 at 11:09
• @msm: Yes, I only referred to the final solution as a reference; I haven't checked the derivation. – Matt L. Jun 8 '17 at 11:45