# Difference equation  (Page 2/2)

 Page 2 / 2

## Finding difference equation

Below is a basic example showing the opposite of the steps above: given a transfer function one can easily calculate thesystems difference equation.

$H(z)=\frac{(z+1)^{2}}{(z-\frac{1}{2})(z+\frac{3}{4})}$
Given this transfer function of a time-domain filter, we want to find the difference equation. To begin with, expand bothpolynomials and divide them by the highest order $z$ .
$H(z)=\frac{(z+1)(z+1)}{(z-\frac{1}{2})(z+\frac{3}{4})}=\frac{z^{2}+2z+1}{z^{2}+2z+1-\frac{3}{8}}=\frac{1+2z^{-1}+z^{-2}}{1+\frac{1}{4}z^{-1}-\frac{3}{8}z^{-2}}$
From this transfer function, the coefficients of the two polynomials will be our ${a}_{k}()$ and ${b}_{k}()$ values found in the general difference equation formula, [link] . Using these coefficients and the above form of the transferfunction, we can easily write the difference equation:
$x(n)+2x(n-1)+x(n-2)=y(n)+\frac{1}{4}y(n-1)-\frac{3}{8}y(n-2)$
In our final step, we can rewrite the difference equation in its more common form showing the recursive nature of the system.
$y(n)=x(n)+2x(n-1)+x(n-2)+\frac{-1}{4}y(n-1)+\frac{3}{8}y(n-2)$

## Solving a lccde

In order for a linear constant-coefficient difference equation to be useful in analyzing a LTI system, we must be able tofind the systems output based upon a known input, $x(n)$ , and a set of initial conditions. Two common methods exist for solving a LCCDE: the direct method and the indirect method , the later being based on the z-transform. Below we will briefly discussthe formulas for solving a LCCDE using each of these methods.

## Direct method

The final solution to the output based on the direct method is the sum of two parts, expressed in the followingequation:

$y(n)={y}_{h}(n)+{y}_{p}(n)$
The first part, ${y}_{h}(n)$ , is referred to as the homogeneous solution and the second part, ${y}_{h}(n)$ , is referred to as particular solution . The following method is very similar to that used to solve many differential equations, so if youhave taken a differential calculus course or used differential equations before then this should seem veryfamiliar.

## Homogeneous solution

We begin by assuming that the input is zero, $x(n)=0$ .Now we simply need to solve the homogeneous difference equation:

$\sum_{k=0}^{N} {a}_{k}()y(n-k)=0$
In order to solve this, we will make the assumption that the solution is in the form of an exponential. We willuse lambda, $\lambda$ , to represent our exponential terms. We now have to solve thefollowing equation:
$\sum_{k=0}^{N} {a}_{k}()\lambda ^{(n-k)}=0$
We can expand this equation out and factor out all of thelambda terms. This will give us a large polynomial in parenthesis, which is referred to as the characteristic polynomial . The roots of this polynomial will be the key to solving the homogeneousequation. If there are all distinct roots, then the general solution to the equation will be as follows:
${y}_{h}(n)={C}_{1}(){\lambda }_{1}()^{n}+{C}_{2}(){\lambda }_{2}()^{n}+\dots +{C}_{N}(){\lambda }_{N}()^{n}$
However, if the characteristic equation contains multiple roots then the above general solution will be slightlydifferent. Below we have the modified version for an equation where ${\lambda }_{1}$ has $K$ multiple roots:
${y}_{h}(n)={C}_{1}(){\lambda }_{1}()^{n}+{C}_{1}()n{\lambda }_{1}()^{n}+{C}_{1}()n^{2}{\lambda }_{1}()^{n}+\dots +{C}_{1}()n^{(K-1)}{\lambda }_{1}()^{n}+{C}_{2}(){\lambda }_{2}()^{n}+\dots +{C}_{N}(){\lambda }_{N}()^{n}$

## Particular solution

The particular solution, ${y}_{p}(n)$ , will be any solution that will solve the general difference equation:

$\sum_{k=0}^{N} {a}_{k}(){y}_{p}(n-k)=\sum_{k=0}^{M} {b}_{k}()x(n-k)$
In order to solve, our guess for the solution to ${y}_{p}(n)$ will take on the form of the input, $x(n)$ . After guessing at a solution to the above equation involving the particular solution, one onlyneeds to plug the solution into the difference equation and solve it out.

## Indirect method

The indirect method utilizes the relationship between the difference equation and z-transform, discussed earlier , to find a solution. The basic idea is to convert the differenceequation into a z-transform, as described above , to get the resulting output, $Y(z)$ . Then by inverse transforming this and using partial-fractionexpansion, we can arrive at the solution.

$Z\left\{y,\left(n+1\right),-,y,\left(n\right)\right\}=zY\left(z\right)-y\left(0\right)$

This can be interatively extended to an arbitrary order derivative as in Equation [link] .

$Z\left\{-,\sum _{m=0}^{N-1},y,\left(n-m\right)\right\}={z}^{n}Y\left(z\right)-\sum _{m=0}^{N-1}{z}^{n-m-1}{y}^{\left(m\right)}\left(0\right)$

Now, the Laplace transform of each side of the differential equation can be taken

$Z\left\{\sum _{k=0}^{N},{a}_{k},\left[y,\left(n-m+1\right),-,\sum _{m=0}^{N-1},y,\left(n-m\right),y,\left(n\right)\right],=,Z,\left\{x,\left(,n,\right)\right\}\right\}$

which by linearity results in

$\sum _{k=0}^{N}{a}_{k}Z\left\{y,\left(n-m+1\right),-,\sum _{m=0}^{N-1},y,\left(n-m\right),y,\left(n\right)\right\}=Z\left\{x,\left(,n,\right)\right\}$

and by differentiation properties in

$\sum _{k=0}^{N}{a}_{k}\left({z}^{k},Z,\left\{y,\left(,n,\right)\right\},-,\sum _{m=0}^{N-1},{z}^{k-m-1},{y}^{\left(m\right)},\left(0\right)\right)=Z\left\{x,\left(,n,\right)\right\}.$

Rearranging terms to isolate the Laplace transform of the output,

$Z\left\{y,\left(,n,\right)\right\}=\frac{Z\left\{x,\left(,n,\right)\right\}+{\sum }_{k=0}^{N}{\sum }_{m=0}^{k-1}{a}_{k}{z}^{k-m-1}{y}^{\left(m\right)}\left(0\right)}{{\sum }_{k=0}^{N}{a}_{k}{z}^{k}}.$

Thus, it is found that

$Y\left(z\right)=\frac{X\left(z\right)+{\sum }_{k=0}^{N}{\sum }_{m=0}^{k-1}{a}_{k}{z}^{k-m-1}{y}^{\left(m\right)}\left(0\right)}{{\sum }_{k=0}^{N}{a}_{k}{z}^{k}}.$

In order to find the output, it only remains to find the Laplace transform $X\left(z\right)$ of the input, substitute the initial conditions, and compute the inverse Z-transform of the result. Partial fraction expansions are often required for this last step. This may sound daunting while looking at [link] , but it is often easy in practice, especially for low order difference equations. [link] can also be used to determine the transfer function and frequency response.

As an example, consider the difference equation

$y\left[n-2\right]+4y\left[n-1\right]+3y\left[n\right]=cos\left(n\right)$

with the initial conditions ${y}^{\text{'}}\left(0\right)=1$ and $y\left(0\right)=0$ Using the method described above, the Z transform of the solution $y\left[n\right]$ is given by

$Y\left[z\right]=\frac{z}{\left[{z}^{2}+1\right]\left[z+1\right]\left[z+3\right]}+\frac{1}{\left[z+1\right]\left[z+3\right]}.$

Performing a partial fraction decomposition, this also equals

$Y\left[z\right]=.25\frac{1}{z+1}-.35\frac{1}{z+3}+.1\frac{z}{{z}^{2}+1}+.2\frac{1}{{z}^{2}+1}.$

Computing the inverse Laplace transform,

$y\left(n\right)=\left(.25{z}^{-n}-.35{z}^{-3n}+.1cos\left(n\right)+.2sin\left(n\right)\right)u\left(n\right).$

One can check that this satisfies that this satisfies both the differential equation and the initial conditions.

#### Questions & Answers

what does nano mean?
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
what is fullerene does it is used to make bukky balls
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
so some one know about replacing silicon atom with phosphorous in semiconductors device?
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
for screen printed electrodes ?
SUYASH
What is lattice structure?
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
what's the easiest and fastest way to the synthesize AgNP?
China
Cied
types of nano material
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
what is nano technology
what is system testing?
preparation of nanomaterial
how to synthesize TiO2 nanoparticles by chemical methods
Zubear
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Berger describes sociologists as concerned with
Got questions? Join the online conversation and get instant answers!