# 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.

what is the meaning of function in economics
Pls, I need more explanation on price Elasticity of Supply
Is the degree to the degree of responsiveness of a change in quantity supplied of goods to a change in price
Afran
Discuss the short-term and long-term balance positions of the firm in the monopoly market?
hey
Soumya
hi
Mitiku
how are you?
Mitiku
can you tell how can i economics honurs(BSC) in reputed college?
Soumya
through hard study and performing well than expected from you
Mitiku
what should i prepare for it?
Soumya
prepare first, in psychologically as well as potentially to sacrifice what's expected from you, when I say this I mean that you have to be ready, for every thing and to accept failure as a good and you need to change them to potential for achievement of ur goals
Mitiku
parna kya hai behencho?
Soumya
Hallo
Rabindranath
Hello, dear what's up?
Mitiku
cool
Momoh
good morning
Isaac
pls, is anyone here from Ghana?
Isaac
Afran
Afran
what is firms
A firm is a business entity which engages in the production of goods and aimed at making profit.
What is autarky in Economics.
what is choice
So how is the perfect competition different from others
what is choice
Tia
1
Naziru
what is the difference between short run and long run?
It just depends on how far you would like to run!!!🤣🤣🤣
Anna
meaning? You guys need not to be playing here; if you don't know a question, leave it for he that knows.
Ukpen
pls is question from which subject or which course
Is this not economics?
Ukpen
This place is meant to be for serious educational matters n not playing ground so pls let's make it a serious place.
Docky
Is there an economics expert here?
Docky
Okay and I was being serous
Anna
The short run is a period of time in which the quantity of at least one inputs is fixed...
Anna
that is the answer that I found online and in my text book
Anna
Elacisity
salihu
Meaning of economics
It will creates rooms for an effective demands.
different between production and supply
babsnof
Hii
Suraj
hlo
eshita
What is the economic?
Suraj
Economics is a science which study human behavior as a relationship between ends and scarce means which has an alternative use.
Mr
what is supply
babsnof
what is different between demand and supply
Demand refers to the quantity of products that consumers are willing to purchase at various prices per time while Supply has to do with the quantity of products suppliers are willing to supply at various prices per time. find the difference in between
Saye
Please what are the effects of rationing Effect of black market Effects of hoarding
monoply is amarket structure charecrized by asingle seller and produce a unique product in the market
yes
Niraj
I want to know wen does the demand curve shift to the right
Nana
demand curve shifts to the right when there's an increase in price of a substitute or increase in income
kin
ask me anything in economics, I promise to try and do justice to the question, you can send me an email or message, I will answer
kin
what are the factor that change the curve right
Nana
explain the law of supply in simple .....
freshwater
the Law of supply: states that all factor being equal, when the price of a particular goods increase the supply will also increase, as it decreases the supply will also decrease
kin
@Nana the factor that changes or shift the d demand curve to the right is 1) the increase in price of a substitute good or commodity 2) increase in income
kin
you can send your questions I am Comr. Kin chukwuebuka
kin
different between bill of exchange n treasure bill
Nana
yes
so would you tell me what means an apportunity cost plz?
Cali
what is true cost
Akiti
Anthonia
define an apportunity cost?
Cali
orukpe ,is my question whats wrong or u dont know anything?
Cali
In a simple term, it is an Alternative foregone.
Sule
opportunity cost is the next best value of a scale of preference
Akiti
Both of you are not correct.
Nelly
opportunity cost: is a forgone alternative
kin
Monopoly is where is one producer produces a given product with no close substitute
James
what is income effect?
if you borrow \$5000 to buy a car at 12 percent compounded monthly to be repaid over the next 4 year what is monthly payment
Researchers demonstrated that the hippocampus functions in memory processing by creating lesions in the hippocampi of rats, which resulted in ________.
The formulation of new memories is sometimes called ________, and the process of bringing up old memories is called ________.
Got questions? Join the online conversation and get instant answers!   By   By Rhodes By Dravida Mahadeo-J... By By By