Digital Sinusoidal Oscillators and an Introduction to Difference Equations
1. A Trigonometric Identity
The following trigonometric identity holds for all real numbers a and b:
sin a + sin b = 2 sin ( (a+b)/2 ) cos ( (a-b)/2).
Since this holds for all real numbers, we may choose
a = (r+1)w0, and
b = (r-1)w0
where r and w0 are real numbers:
sin (r+1)w0 + sin(r-1)w0 = 2 sin r w0 cos w0.
Hence,
sin (r+1)w0 = - sin(r-1)w0 + 2 cos w0 sin r w0 ,
or, writing the right hand side as a dot product of two vectors,
sin (r+1)w0 = [-1 2cos w0] . [sin(r-1)w0 sin r w0].
2. Some Consequences
Choosing a specific value r = r0, it follows that we may compute for sin (r0+1)w0 provided we have all the quantities on the right hand side:
sin (r0+1)w0 = [-1 2cos w0] . [sin(r0-1)w0 sin r0w0].
We should compute the product of -1 and sin(r0-1)w0 then add to this product the product of 2cos(w0) and sin(r0 w0). We may then use the computed value of sin (r0+1)w0 to compute for sin (r0+2)w0:
sin (r0+2)w0 = [-1 2cos w0] . [sinr0w0 sin( r0+1)w0].
Next we may compute for sin (r0+3)w0:
sin (r0+3)w0 = [-1 2cos w0] . [sin( r0+1)w0 sin( r0+2)w0].
Note that the first vector in the dot product on the right hand side is constant. To compute for sin(r0+4)w0 we have:
sin (r0+4)w0 = [-1 2cos w0] . [sin( r0+2)w0 sin( r0+3)w0].
And so on.
3. The Trigonometric Identity is a Difference Equation
We may think of the values we computed as forming a sequence of samples of a sinusoid:
{sin (r0+1)w0 , sin (r0+2)w0, sin (r0+3)w0, sin (r0+4)w0, ...}
We may associate an index of 0 with the first element in the sequence, an index of 1 with the next, and so on:
y(0) = sin (r0+1)w0
y(1) = sin (r0+2)w0
y(2) = sin (r0+3)w0
y(3) = sin (r0+4)w0
In general,
y(n) = sin (r0+1 + n)w0 .
Using this indexing, we may write the trigonometric identity as
y(n) = [-1 2cos w0] . [y(n-2) y(n-1)].
or
y(n) = - y(n-2) + 2cos(w0) y(n-1).
This may be recognized as being in the form of a difference equation.
4. Initial Conditions
Each element in the sequence can be computed from the previous two, except possibly for the first few. If we extend the indexing to allow negative indices we may think of sin r0w0 as y(-1) and of sin(r0-1)w0 as y(-2). They specify "initial conditions". They are not part of the sequence computed, but are initializations needed to start off the computations.
5. Difference Equations in General
We may think of the sequence y(n) as an output of some sort. The difference equation in effect says that the outputs are computed without any input. This is true of oscillators. In general, however, difference equations specify how output is produced based on inputs x(n) and possibly previous outputs as well:
N M y(n) = - SUM [ak y(n-k)] + SUM [bk x(n-k)] . k=1
k=0 This is the most general form for a difference equation specifying a causal, linear time-invariant system. It specifies how input x(n) is processed and transformed so as to produce output y(n). N initial conditions are needed to start off the computations. N may differ among different systems.
If the system does not have to be causal then k may start at negative indices in the second sum:
N M y(n) = - SUM [ak y(n-k)] + SUM [bk x(n-k)] . k=1
k = - P This more general form says that the current output y(n) may be computed from past outputs and past and future inputs. The system is noncausal because of this dependence on future inputs.
Any system that transforms an input sequence x(n) into an output sequence y(n) in a linear time-invariant fashion may be specified using a difference equation with appropriate coefficients ak and bk .
Reference:
J. Proakis and D. Manolakis, Digital Signal Processing, 3rd ed, 1996.
This page has been accessed
times since November 21, 2002.