You are on page 1of 11

ECE

EE 8443
3512 – PatternContinuous
– Signals: Recognition
and Discrete

LECTURE 06: DIFFERENCE AND DIFFERENTIAL


EQUATIONS AND THEIR SOLUTIONS
• Objectives:
Difference Equations
Recursive Solutions
Differential Equations
Numerical Solutions
Representation of CT SIgnals

• Resources:
Wiki Difference Equations
DS: Diff. To. Differential
TK: Diff. Eq. Tutorial
MIT 6.003: Lecture 4

URL:
Linear Constant-Coefficient Difference Equations
• We can model the input/output behavior of a DT
LTI systems using an Nth-order input/output
difference equation (also called a digital filter): x[n ] DT LTI y[n]
N M h[n ]
y[n]   ai y[n  i ]   bi x[n  i ]
i 1 i 0

• Solution of such equations can be easily computed by solving for y[n]:


N M
y[n]   ai y[n  i ]   bi x[n  i ]
i 1 i 0

• Let us consider a simple example: y[n]  1.5 y[n  1]  y[n  2]  2 x[n  2]


Let us assume: x[n]   [n] y[1]  0 y[2]  0 (the latter are referred to as
initial conditions). The output can be computed using a table:
n x[n] x[n-1] x[n-2] y[n] y[n-1] y[n-2]
0 1 0 0 0 0 0
1 0 1 0 0 0 0
2 0 0 1 2 0 0
3 0 0 0 3 2 0
4 0 0 0 2.5 3 2
EE 3512: Lecture 06, Slide 1
Difference Equations in MATLAB

• The solutions to these equations can


be easily programmed in MATLAB.
• Note that the key step is actually a dot
product between the equation’s
coefficients and the previous samples
of the output and input (often referred
to as the filter memory).

• The response to a unit step function


can also be computed using the
function recur.
• The unit step function is created by
assigning values of “1” to x,
followed by the invocation of the
recur function that performs the
difference equation computations.

EE 3512: Lecture 06, Slide 2


Complete Response of a First-Order Equation
• Consider the first-order linear difference equation:
y[n]  ay[n  1]  bx[n]
• Let us assume that: y[1]  0
y[0]  ay[1]  bx[0]
y[1]  ay[0]  bx[1]  a(ay[1]  bx[0])  bx[2]  a 2 y[1]  abx[0]  bx[1]
y[2]  a(a 2 y[1]  abx[0]  bx[1])  bx[3]  a 3 y[1]  a 2 bx[0]  abx[1]  bx[2]
...
n
y[n]  a y[0]   a n i bx[i ]
n

i 0

• The first part of the response is due to the initial condition being nonzero. The
second part of the response is due to the forcing function, x[n].
• Together, they comprise the complete response of the system.
• We will see that closed-form solutions of these equations can be easily
computed using the z-transform, which is very similar to the Laplace
transform. The z-transform converts the difference equation to an algebraic
equation.
• Closed-form solutions can also be found using summation tables.
EE 3512: Lecture 06, Slide 3
Differential Equations
• For CT systems, such as
circuits, our principal tool is
the differential equation.
• For the circuit shown, we can
easily compute the
input/output differential
equation using Kirchoff’s Law.

• What is the nature of the impulse


Ri (t )  y (t )  x(t )  0 response for this circuit?
dv (t ) dy (t )
i (t )  C C C
dt dt
dy (t )
RC  y (t )  x(t )  0
dt
dy (t ) 1 1
 y (t )  x(t )
dt RC RC

EE 3512: Lecture 06, Slide 4


Numerical Solutions to Differential Equations
• Consider our 1st-order diff. eq.: • We can replace n by n-1 to obtain:
dy (t ) y[n]  (1  aT ) y[n  1]  bTx[n  1]
 ay (t )  bx(t )
dt
• We can solve this numerically by • This is called the Euler approximation
setting t = nT: to the differential equation.
dy(t ) • With x[n]  0 n and initial condition,
 ay(nT )  bx(nT )
dt t nT y[0] , the solution is:
• The derivative can be approximated: y[n]  (1  aT ) n y[0], n  0, 1, 2, ...
dy(t ) y(nT  T )  y(nT )
 • The CT solution is:
dt t nT T  at
• Substituting into our diff. eq.: y (t )  e y(0), t  0
y (nT  T )  y (nT ) • Later, we will see that using the
 ay (nT )  bx(nT )
T Laplace transform, we can obtain:
• Let x(nT )  x[n] and y (nT )  y[n] : y[n]  e  anT y[0], n  0, 1, 2, ...
y[n  1]  y[n] • But we can approximate this:
 ay[n]  bx[n]
T  aT a 2T 2 a 3T 3
e  1  aT    ...
y[n  1]  y[n]  aTy[n]  bTx[n] 2 6
• Which tells us our 1st-order
y[n  1]  (1  aT ) y[n]  bTx[n]
approximation is accurate!
EE 3512: Lecture 06, Slide 5
Higher-Order Derivatives
• We can use the same approach for the second-order derivative:
dy (t ) dy (t )

d 2 y (t ) dt dt
 t  nnT T t  nnT

dt t  nT T
y (nT  2T )  2 y (nT  T )  y (nT )

T
• Higher-order derivatives can be similarly approximated.
• Arbitrary differential equations can be converted to difference equations using
this technique.
• There are many ways to approximate derivatives and to numerically solve
differential equations. MATLAB supports both symbolic and numerical
solutions.
• Derivatives are quite tricky to compute for discrete-time signals. However, in
addition to the differences method shown above, there are powerful methods
for approximating them using statistical regression.
• Later in the course we will consider the implications of differentiation in the
frequency domain.
EE 3512: Lecture 06, Slide 6
Series RC Circuit Example

dy (t ) 1 1
 y (t )  x(t )
dt RC RC

Difference Equation:
R=1;C=1;T=0.2;
a=-(1-T/R/C);b=[0 T/R/C];
y0=0; x0=1;
n=1:40;
x=ones(1,length(n));
y1=recur(a, b, n, x, x0, y0);
Analytic Solution:
t=0:0.04:8;
y2=1-exp(-t);
y1=[y0 y1];
n=0:40;
plot(n*T, y1, ’o’, t, y2, ’-’);
EE 3512: Lecture 06, Slide 7
Representation of CT Signals
• Recall from calculus how we approximated a function by a sum of time-
shifted, scaled pulse functions:

• We approximate the signal’s amplitude value as a constant over the interval


k  t  (k  1) : xˆ (t )  x(k) for k  t  (k  1)

• The signal changes discontinuously at the next step.

• What happens as   0 ? Recall our


representation of a CT impulse function:

EE 3512: Lecture 06, Slide 8


Representation of CT Signals Using Impulse Functions
• We approximate a CT signal
as a weighted pulse function.
• The signal can be written as a
sum of these pulses:

xˆ (t )   x(k)
k  
 (t  k)

• In the limit, as   0 :

x(t )   x( )

 (t   )d
0 for t  0
• Mathematical definition of an impulse
 (t )  
 for t  0
function (the equivalent of the unit pulse 0

  (t )dt  1
for DT signals and systems):
0

• Unit pulses can be constructed from many functional shapes (e.g.,


triangular or Gaussian) as long as they have a vanishingly small width. The
rectangular pulse is popular because it is easy to integrate 

EE 3512: Lecture 06, Slide 9


Summary
• We introduced a linear constant coefficient difference equation.
• We demonstrated how to solve such equations numerically.
• We demonstrated how these difference equations can be used to
approximate differential equations.
• We discussed how to convert derivatives to differences.
• We compared the accuracy of the analytic and approximate solutions for a
series RC circuit.
• We introduced a method for representing CT signals as a combination of
impulse functions. We will use this representation to derive the convolution
integral for CT signals.

EE 3512: Lecture 06, Slide 10

You might also like