Assignment (Difference Equations)
Assignment (Difference Equations)
Recursive Equations
A recursive equation, also called recurrence equation, is an equation that defines a
sequence recursively i.e. each term of the sequence is defined as a function of the
previous terms of the sequence.
Xn = f (Xn-1, Xn-2, X0)
The order of the recurrence equation is the number of the preceding terms required
by the definition. The general form of the a linear recurrence relation of order p is as
follows,
Xn = an-1Xn-1 + an-2Xn-2 + ... + an-pXn-p + a0
Here Xn is the nth term of the recursive equation and depends on the previous p (Xn1, Xn-2, Xn-p) terms and a0 (constant). If a0 is zero the recursive equation is called
homogeneous otherwise nonhomogeneous.
Example#1
A Malthusian Growth Model, sometimes called a simple exponential growth model,
is an
exponential growth based on a constant rate. The model is named after
Thomas Robert Malthus, who wrote An Essay on the Principle of Population (1798),
one of the earliest and most influential books on population.
Malthusian models have the following form:
P (n) =P0ern
Where,
n= time in years.
Example#2
For an annual interest rate of p% and conversion period equal to , the interest
earned for the period is equal to p% of the amount on deposit at the start of the
period, that is,
Amount on deposit
after k + 1 conversion
periods
= Amount on
deposit after k
conversion
periods
+ (p/100)*(amount
deposit after k
conversion periods)
To express this as a difference equation, for each k let S(k) denote the amount on
deposit after k conversion periods. Thus,
S (k+1) = S (k) + (p/100)*S (k)
This is a simple first-order (that is, expressing the relation only between the
consecutive values of the unknown sequence) difference equation.
Example#3
According to Walras, the market price is the equilibrium price; that is, it is the price
at which demand D for this commodity equals supply S of it. Let p (n) denotes the
price in period n. The assumptions are that D (n) = f (p (n)) where f is a decreasing
function and S (n) = g (p (n 1)), where g is an increasing function. The fact that S
depends on p(n 1) and D depends on p(n) is due to the fact that producers need
some time to react to changing prices whereas consumers react almost
immediately. Thus, following the equilibrium hypothesis,
f (p(n)) = g(p(n 1))
Which is highly nonlinear first order equation. If f is strictly decreasing and the
ranges of f and g are the same, this equation can be solved for p (n) giving,
p(n) = f
(g(p(n 1)))
Still, to proceed we have to make some further assumptions on the functions f and
g. The simplest functions satisfying the assumptions are,
f (p(n)) = mdp(n) + bd
g(p(n 1)) = msp(n 1) + bs
Where md, ms, bd > 0, bs 0 are constants. Coecients md and ms are called,
respectively, consumers and suppliers sensitivity to price. For these assumptions
we obtain the following linear first order equation for price,
P (n) = -(ms/md) (p(n-1)) + (bd - bs)/md
Example#1
Fibonacci sequence is defined by the following second order linear recursive
equation,
Fn = Fn-1 + Fn-2
Where F0 = 0 and F1 = 1.
Fibonacci sequence is used in many fields. It is found almost everywhere in nature,
from the leaf arrangement in the plants, to the pattern of florets of a flower, the
bracts of pinecone or the scales of pineapple.
Example#2
A gambler plays a sequence of games against an adversary. The probability that the
gambler wins in any given game is q and the probability of him losing is 1-q. He
quits the game if he either wins a prescribed amount of N rands, or loses all his
money; in the latter case we say that he has been ruined. Let p (n) denotes the
probability that the gambler will be ruined if he starts gambling with n rands. We
build the difference equation satisfied by p (n) using the following argument. Firstly,
note that we can start observation at any moment, that is, the probability of him
being ruined with n rands at the start is the same as the probability of him being
ruined if he acquires n rands at any moment during the game. If at some moment
during the game he has n rands, he can be ruined in two ways: by winning the next
game and ruined with n + 1 rand, or by losing and then being ruined with n
1rands. Thus,
p(n) = (q)(p(n+1)) + (1-q)p(n-1)
Replacing n by n+1, we obtain and dividing by q,
p(n+2) = (1/q)[P(n+1) -(1-q)p(n)]
This is a second order linear difference equation.
Example#3
In digital signal processing filter are used to remove the unwanted noise from a
digital signal. This is done by means of designing a digital FIR or IIR filter. Various
order filters can be designed and the outputs of such filters can be expressed using
second order or higher order difference equations depending upon the order of the
filter.
Question#2
Solution
The difference equation for the system is,
X (n) = -0.03X (n-1) + 180 + 65 + X (n-1)
(n1)
Days(n)
0
1
2
3
4
Water(X(n)) in tons
5000
5095
5187.15
5276.54
5363.24
The MATLAB code for the above system is with the plots obtained is given below,
a = [0:0.5:365]; %the number of days
s = size(a);
r = zeros(1,s(2)); %the water amount in reservoir
r(1) = 5000;
r(2) = 5000;
for j = 3:s(2)
if (rem(j,2)==0)
r(j) = r(j-1);
else
r(j) = 0.97*r(j-1)+245;
end
end
stem(a,r);
grid on
The reservoir system is a stable system because as can be seen from the plot the
water in the tank approaches a constant level. As the numbers of days are
increased the output approaches a steady level and does not increase without a
bound. Hence the system is a stable one.
Question # 3
Solution
The recursive equation for the system is defined piecewise,
X (n) = (1.09) X(n-1) + 1000 for n=odd
X (n) = (1.09) X(n-1) -2500
for n=even
Years (n)
1
2
3
4
5
Balance(TL)
44600
46114
51264
53378
59182
The MATLAB script file for the above problem with the plot is given below,
a = [0:1:30]; %Years
s = size(a);
r = zeros(1,s(2)); % Balance in TL
r(1) = 40000;
for j = 2:s(2)
if (rem(j,2)==0)
r(j) = 1.09*r(j-1)+1000;
else
r(j) = 1.09*r(j-1)-2500;
end
end
stem(a,r);
grid on
From the above plot it can be seen that as n is increased without bound the
Balance also increases without bound. Hence the system is not stable.