# Z-transform to solve difference equation

• Jun 9th 2010, 11:31 AM
Rainey77
Z-transform to solve difference equation
Hello all hopefully you can be of help
I have to solve the following difference equation using z transforms

Xq+2 - 5Xq+1 +6Xq = 2

conditions Xo=0 and X1=1

Not to sure how to do it

so far i have took the z transforms and got

(z^2-z) -5zx + 6x = 2z/z-1

I'm not sure if this is correct but even if it is i have no idea of what to do next
Any help would be greatly appreciated
• Jun 9th 2010, 11:40 AM
Ackbeet
Just to clarify:

You're trying to solve

$x_{q+2}-5x_{q+1}+6x_{q}=2$,

subject to $x_{0}=0$, and $x_{1}=1$.

Is this correct?
• Jun 9th 2010, 11:46 AM
Rainey77
Yes thats correct using z-transforms
• Jun 9th 2010, 11:49 AM
Ackbeet
There are different definitions of the z-transform: bilateral, unilateral, and geophysical. Which one are you using? I'm guessing unilateral?
• Jun 9th 2010, 11:54 AM
Rainey77
yeah i believe its unilateral

• Jun 9th 2010, 12:04 PM
Ackbeet
So, when I take the z-transform of the difference equation, $x_{q+2}-5x_{q+1}+6x_{q}=2$, I get the following:

$z^{2}X(z)-5zX(z)+6X(z)=2z/(z-1)$.

As with most transform techniques, the next step is to solve the problem in the new domain (i.e., solve for $X(z)$), and then perform the inverse z-transform. You might need partial fraction decomposition.
• Jun 9th 2010, 12:19 PM
Rainey77
Okay im still not 100% sure

But so far i've got it to this form

2z/(z-1)(z-3)(z-2)

Then using partial fractions got it to,

-4/z-2 +1/z-1 +3/z-3

You mention inverse z-transform, have i missed a stage? or am i heading in the right direction?

(sorry being vague very new to z-transforms)

Many thanks figured it out.
• Jun 9th 2010, 12:35 PM
Ackbeet
Hmm. You can do it that way. Looking ahead, it's a bit easier to work with terms that look like $1/(1-az^{-1})$. Try a partial fraction decomposition using that form. In other words, take your

$\frac{2z}{(z-1)(z-2)(z-3)}=\frac{2z^{-2}}{(1-z^{-1})(1-2z^{-1})(1-3z^{-1})}$, and expand it out that way.
• Jun 10th 2010, 05:01 AM
Ackbeet
If you're having difficulty expanding it out with $z^{-1}$'s in there, just substitute $y=z^{-1}$, expand it out in partial fractions, and then substitute back in for $z^{-1}$.
• Jun 10th 2010, 05:04 AM
Rainey77
think i may have solved it
ended up with

-4(2^t) + 1 + 3(-3^t)
• Jun 10th 2010, 06:44 AM
Ackbeet
Hmm. That doesn't jibe with what RSolve gives me in Mathematica. Also, you want to be careful with your parentheses. What's being exponentiated?

I got the partial fraction expansion of

$\frac{1}{1-z^{-1}}-\frac{2}{1-2z^{-1}}+\frac{1}{1-3z^{-1}}$.

The inverse z-transform of this is

$1-C_{1}2^{q+1}+C_{2}3^{q}$.

Plugging in the initial conditions yields two simultaneous equations:

$0=1-2C_{1}+C_{2}$
$1=1-4C_{1}+3C_{2}$.

Solving gives $C_{1}=\frac{3}{2}$, and $C_{2}=2$. Plugging this into the expression above yields

$x_{q}=1-3\cdot 2^{q}+2\cdot 3^{q}$, which is what RSolve also yields.