Professional Documents
Culture Documents
Z-Transform and Its Application To Development of Scientific Simulation Algorithms
Z-Transform and Its Application To Development of Scientific Simulation Algorithms
Z-Transform and Its Application To Development of Scientific Simulation Algorithms
Application to Development
of Scientic Simulation
Algorithms
ZVONKO FAZARINC
620 Sand Hill Road, 417D, Palo Alto, California 94304
ABSTRACT: Engineers and educators nd in computer simulations a powerful substitute for inability of cal-
culus to produce closed form solutions to modern problems. But the validity of quasi-closed-form solutions
produced by computers remains suspect. While no magic test exists, pieces of algorithms can individually be
examined by the Z-transform [E. I. Jury, Sampled-data control systems, John Wiley & Sons, 1958]. Two examples
from engineering and three from education are presented. 2010 Wiley Periodicals, Inc. Comput Appl Eng Educ
21: 7588, 2013; View this article online at wileyonlinelibrary.com; DOI 10.1002/cae.20452
Keywords: Z-transform; science simulations; algorithm development; physics algorithms; mathe algorithms
75
76 FAZARINC
tion. First we will show a simple derivation of the Z-transform. Its n[ns]
-2
engineering principles and a formal solution of a generic second
order difference equation appearing throughout the paper will be -3
found in the Appendix.
Figure 1 Result of direct digitization of harmonic motion equation.
Z-TRANSFORM DIRECTLY FROM LAPLACE In it h(t) is the function subject to harmonic behavior and
TRANSFORM is the circular frequency. The Laplace transform solution of this
equation is
The causal Laplace transform H(s) of a time function h(t)
+ 1 dh(t)
is dened as H(s) = h(t)est dt and its inverse as h(t) = h(t) = h(0)cos t + = h(0)cos t + g(0)sin t (4)
dt t=0
0
1
+
st An algorithm for computer generated harmonic motion or for
2j
H(s)e ds where t is time and s is a complex variable. We
evaluation of trigonometric functions in general is desirable and
discretize time t into n integer increments to obtain an equivalent may be found directly from the harmonic motion equation. But this
+ task soon encounters a surprising number of unpredictable obsta-
discrete forward transform H(s) = h(n)esn . Using the substi- cles, which we will address with the Z-transform. The rst obvious
n=0
idea that offers itself is to convert the differential harmonic equa-
tution z = eS we can write an equivalent H(s) function but in terms
+ tion into its discrete equivalent and then submit it to the computer
of z as H(z) = h(n)zn . This is the causal forward Z-transform. for evaluation. It is convenient to rst split the second order Equa-
n=0 tion (3) into two rst order equivalents as dh(t)/dt = g(t) and
Let us now turn our attention to the inverse. Replacing dg(t)/dt = h(t). These are now easily converted into discrete
again the continuous time t with its discrete equivalent n in the forms
+
inverse Laplace transform we obtain h(n) = 1
H(z)esn ds.
2j
0
h(n + 1) h(n) = g(n) g(n + 1) g(n) = h(n) (5)
The differential ds is found from the denition z = e as ds = dz/z. s
+ When presented in a language using arrayed variables
Substituting this we get h(n) = 1
2j
H(z)zn1 dz. The common these equations are easily digested by the computer as for
example: for (n = 0; n < 30; n++) {h[n + 1] = h[n] + *g[n];
Z-transform denitions are then
g[n + 1] = g[n]*h[n];}.The choice of 30 increments is arbi-
+ trary and if we think of them as nanoseconds the scaling is nine
H(z) = h(n)zn (1) orders of magnitude. So if we wish the frequency to be say
n=0 50 MHz we must choose to be 250 106 scaled down by
the power of nine or = 0.314159. The result of executing this
and algorithm with these numbers and with initial conditions h = 0
and g = 1 is plotted in Figure 1. There is not much doubt that we
+ are dealing with an unstable algorithm.
1
h(n) = H(z)zn1 dz (2) This author has met many frustrated designers of physics
2j
z= algorithms, who like him have encountered similar problems
in their practice. They have either blamed themselves for not
More about the practice of Z-transformations is found in the understanding the calculus of discrete mathematics, blamed their
Appendix. computers for misinterpreting their logical inputs or gave up in
despair. We intend to demonstrate that the Z-transform lets us
diagnose such misbehaved algorithms and then point to their
HARMONIC MOTION ALGORITHM DERIVED WITH possible cures. To this end we must derive the numeric expression
Z-TRANSFORM for h(n) as seen by the computer while executing our simple
algorithm. From it we may then gain an insight into the origin of
The harmonic motion, which is at the root of many resonance instability.
phenomena in physics is captured in the second order differential The closed form solution for h(n) can be derived from (5).
equation We take the backward difference [1] of the rst equation, which
amounts to h(n + 2) 2h(n + 1) + h(n) = [g(n + 1) g(n)].
d 2 h(t) Then we substitute the second equation for the bracketed term
+ 2 h(t) = 0 (3)
dt 2 and get after some simple algebraic manipulation the second order
DEVELOPMENT OF SCIENTIFIC SIMULATION ALGORITHMS 77
h(n + 1) = h(n) + g(n) g(n + 1) = g(n) h(n) Substituting A and B from (11) we nd after some lengthy
h(n + 1) = h(n) + g(n) g(n + 1) = g(n) h(n + 1) but elementary algebra the following answer to our function
h(n + 1) = h(n) + g(n + 1) g(n + 1) = g(n) h(n)
n/2
h(n + 1) = g(n) + g(n + 1) g(n + 1) = g(n) h(n + 1) 1 + ab2
h(n) =
There are many other possibilities available as combinations 1 + (1 a)(1 b)2
of the pairs shown above and we propose a generalized form that
includes them all h(0)(a b)/2 + g(0)
h(0)cos n + sin n
h(n + 1) = h(n) + [ag(n) + (1 a)g(n + 1)] (8) 1 (a b)2 2 /4
g(n + 1) = g(n) [bh(n) + (1 b)h(n + 1)] (9) 1
1 (a b)2 (/2)2
= tan (13)
1 (a + b 2ab)()2 /2
Factors a and b may adopt any values desired. We will now
combine these two equations into a second order difference equa- In deriving (13) we have evaluated the term h(1) from (8)
tion containing only h(n) and then derive its closed-form solution. and (9) by setting n equal to zero. Equation (13) exhibits again the
By inspecting it we should then be able to decide what values our divergence term that grows with the number of executions n. It is
factors a and b we should adopt to match the true solution (4). easy to see that this factor becomes unity when we set a + b = 1.
To accomplish this we take the rst difference of (8), which after This, in turn, produces the new expression
simple algebraic operations yields.
h(0)(a 1/2) + g(0)
h(n + 2) = 2h(n + 1) h(n) + {a[g(n + 1) g(n)] h(n) = h(0)cos n + sin n
1 (a2 a + 1/4)2
+ (1 a)[g(n + 2) g(n + 1)]}
(14)
The bracketed expressions are directly available from (9) and
when inserted into the above we get, again after some straightfor- If we now set a to 0.5 then the above becomes h(n) =
ward but messy algebra the expression h(0)cos n + g(0)sin n, which matches the continuous solu-
tion (4) quite well with the exception of the argument . This
h(n + 2) 2h(n + 1)A + h(n)B = 0 (10) differs from and is as such a source of frequency error with
respect to it. In Figure 2 we have plotted the fractional frequency
error ( )/ for the divergent case a = b = 1 and for cases
1 + ab2 (a + b)2 /2
A= and that produce stable, non-divergent solutions with a + b = 1.
1 + (1 a)(1 b)2
With this much knowledge about the effect of our factors a
1 + ab2 and b we can now return to our algorithm (8) and (9) and make
B= (11) it stable by selecting the proper sequencing. The case a = b = 0.5
1 + (1 a)(1 b)2
matches the continuous solution (4) and would be written as
We have encountered this equation earlier and found its solu-
g(n) + g(n + 1)
tion in (A15) as h(n + 1) = h(n) +
2
h(1) h(0)A
h(n) = h(0)Bn/2 cos n + Bn/2 sin n h(n) + h(n + 1)
B A2 g(n + 1) = g(n)
2
= tan 1 B A2 /A (12) This happens to be an implicit algorithm that the computers
do not accept kindly. Of course, there are numerous methods that
78 FAZARINC
1.5 t t
s(t) = s(0) + v(0)t + dt D(t)dt (18)
1
h(n) 0 0
0.5
An algorithm to simulate accelerated motion on a computer
0 can be elicited from Equations (16) and (17), respectively by equiv-
0 5 10 15 20 25 alent backward differences
-0.5
v(n + 1) = v(n + 1) v(n) = D
-1 n[ns]
s(n + 1) = s(n + 1) s(0) = v (19)
-1.5
In (19) we have intentionally avoided specications of tempo-
Figure 3 Results of correct digitization of the harmonic motion equation. ral arguments for acceleration D and velocity v because a number
of choices are available. We have demonstrated this earlier before
arriving at forms (8) and (9). Here we could also use the acceler-
deal with implicit algorithms but we can circumvent them, yet still ation D(n + 1) and velocity v(n + 1) or their previously evaluated
satisfy the stability condition in a very straightforward way by values D(n) and v(n) or we could also use some combinations
choosing a = 1 and b = 0. The resulting algorithm is then thereof.
h(n + 1) h(n) = g(n) and g(n + 1) g(n) = h(n + 1) Without knowing the outcomes produced by a given choice,
we have no reason to prefer any one of them. Therefore we will
This can now be cast into an appropriate computer lan- again employ the parameter optimization procedure, similar to the
guage as we have done before for (n = 0; n < 30; n++) one encountered in the previous section. This time we will use the
{h[n + 1] = h[n] + *g[n]; g[n + 1] = g[n] *h[n + 1];} Now a expected answer (18) as the target. To this end we choose as yet
keen eye of a computer programmer would quickly note that the undened fractions of the two primary choices with the parameters
arrays can be eliminated for this specic case so that the natural a and b determining their contributions as
computer sequencing of statement evaluations can be exploited.
We then simply write the program as for (n = 0; n < 30; n++) v(n + 1) = v(n) + aD(n) + (1 a)D(n + 1) (20)
{h = h + *g; g = g *h;}. This algorithm with same parame-
ters as before produces Figure 3 which meets our expectations for s(n + 1) = s(n) + bv(n) + (1 b)v(n + 1) (21)
extended periods of time [2]. In order to make a comparison with (18) possible we need a
The forgoing example illustrates how the Z-transform may closed form solution for s(n), which calls for elimination of veloc-
be used to develop algorithms of prescribed behavior. General ity terms from (21). We do this by taking the rst difference of
algebra though, limits the extraction of poles, required for inverse s(n + 1) yielding
Z-transformation to orders of less than ve. Consequently the tech-
nique is also limited to low orders. But there is no known technique s(n + 2) s(n + 1) = s(n + 1) s(n) + b[v(n + 1) v(n)]
other than trial and error that can be employed to complex simula-
tion algorithm development. In the next section we show another + (1 b)[v(n + 2) v(n + 1)]
example of Z-transforms power to accomplish this task.
The bracketed expressions are easily found from (20) and
their substitution produces
ACCELERATED MOTION ALGORITHM DERIVED WITH s(n + 2) 2s(n + 1) + s(n)
Z-TRANSFORM
= abD(n) + (1 a)bD(n + 1) + a(1 b)D(n + 1)
In this example we will demonstrate the use of convolution + (1 a)(1 b)D(n + 2) (22)
to derive algorithm parameters when the driving function is ill
dened. We will apply it to the most frequently encountered tasks We recognize Equation (A10) in the Appendix as possessing
in simulations of dynamics, that is, the algorithm of accelerated the form of (22) when A = B = 1 and f(n) is equal to the RHS of
motion based on Newtons Laws. (22). The specic solution of this equation is then as given by
A constant mass m, subjected to force F(t) experiences an (A16) in which the asterisk * denotes the convolution in the n
acceleration domain
dv(t) = D(t)dt (16) The s(1) term can be obtained directly from (20) and (21) for
n = 0. s(1) = s(0) + v(0) + a(1 b)D(0) + (1 a)(1 b)D(1).
and a position differential With this the inverse transform is
ds(t) = v(t)dt (17) s(n) = s(0) + v(0)n + a(1 b)nD(0) + (1 a)(1 b)nD(1)
+ [abD(n) + (a + b 2ab)D(n + 1)
A direct integration of (16) and (17) produces for the position
of the object +(1 a)(1 b)D(n + 2)] (n 1) (23)
DEVELOPMENT OF SCIENTIFIC SIMULATION ALGORITHMS 79
+ [abD(j) + (a + b 2ab)D(j + 1)
j=0
D(j + 1)(n 1 j)
-1 0 1 2
n
j=0
n
n
s(n) = s(0) + v(0)n + a(1 b)nD(0) + (1 a)(1 b)nD(1) We dene the step acceleration as Ds (n) = Ds u(n) where u(n) is
the unit step function
n
0 if t < 0
+ [abD(j)(n 1 j) + (a + b 2ab)D(j)(n j)
u(n) =
j=0 1 otherwise
+ (1 a)(1 b)D(j)(n + 1 j)] It is illustrated in Figure 4 as a continuous function by dashed
lines and as its discrete equivalent by dots appearing at unit time
(a + b 2ab)[nD(0) + D(n + 1)] intervals. This type of acceleration can be employed to represent
(1 a)(1 b)[(n + 1)D(0) + nD(1) + D(n + 2)] a multitude of cases. If we think of it as having started at minus
innity, we have a constant acceleration case at hand. We can
We will drop the terms D(n + 1) and D(n + 2) from the above think of an arbitrary force as a sequence of steps, following one
expressions because they are meaningless to our goal. This deci- another. For the continuous domain, such a sequence would con-
sion has nothing to do with mathematical practice but only with sist of innitesimally small steps occurring at innitesimally small
common sense. It is namely quite obvious that the position s(n) at time intervals. In the discrete domain, nite steps, occurring at unit
time n cannot possibly depend on accelerations at later times n + 1 intervals would represent such an arbitrary acceleration function.
or n + 2. Consequently, the results obtained for a single step will be repre-
Combine the sums and after an elementary but lengthy alge- sentative of a whole array of acceleration functions, including zero
braic manipulation we end up with and constant acceleration.
To enable the comparison of results we must limit ourselves
s(n) = s(0) + v(0)n + (a 1)nD(0) (1 a)(1 b)D(0) to discrete times t = n where the information is available to us.
n The acceleration is equal to Ds for all times equal to or greater
+ D(j)[ab(n 1 j) + (a + b 2ab)(n j) than zero. When we perform the integrations indicated in (18) we
j=0 obtain for the objects position, expressed at discrete times, the
expression
+ (1 a)(1 b)(n + 1 j)] (25)
Without specifying the acceleration function D(j) one cannot n2
s(n) = s(0) + v(0)n + Ds (26)
further expand expression (25). But we do have the freedom to 2 n0
specify any acceleration within reason to nd the resulting position
s(n) of the object in question. It should be pointed out that we have We will now substitute the same step acceleration into (25).
arrived at this universal answer by means of the use of convolution. In conformance with its notation we must use the summation index
This can be a real time saver, whenever we wish to examine an j which results in the following denition of the step acceleration
80 FAZARINC
+ Ds [ab(n 1 j) + (a + b 2ab)(n j)
j=0 40
+ (1 a)(1 b)(n + 1 j)]
20
Applying the following identities
n
n(n 1)
n
n(n + 1)
n1j = nj = 0
2 2
j=0 j=0 2 4 6 8 10
n
n(n + 1)
n+1j = +n+1 n
2
j=0
Figure 5 Simulation of uniformly accelerated motion.
we get
n2
s(n) = s(0) + v(0)n + Ds + n(0.5 b) (27)
2
The impulsive acceleration is illustrated in Figure 6 by dashed lines Equation (29) will be used as reference for establishing the
for the continuous domain and by discrete points for the discrete parameters a and b in (25) for this case. If we apply the same
time domain. It appears at a given time instant and then vanishes. impulsive acceleration to (25) the summation term has a value only
Such accelerations arise frequently in nature when particles are when the index j is zero. Then (25) assumes the following form
DEVELOPMENT OF SCIENTIFIC SIMULATION ALGORITHMS 81
0
Money after appreciation m(n + 1) = [m(n) w(n)]P (31)
1 2 n
Inated withdrawal w(n + 1) = w(n)I (32)
Figure 7 Discrete motion following a stepwise acceleration compared to
theoretical expectation.
The shorthand used in the above : P = 1 + p; I =1+i
Take the rst difference of (31), which is m(n + 2) m(n +
1) = m(n + 1)P m(n)P w(n + 1)P + w(n)P and can be pre-
3.5 sented in the form
s(n)
m(n + 2) m(n + 1)(1 + P) + m(n)P + [w(n + 1) w(n)]P
2.5
=0 (33)
Plain intuition would tell a gambler that the odds of winning are
steadily improving with the number of attempts at the same game.
But the facts are different as we will prove by an analysis, which
will at the same time allow us to demonstrate the use of a two
dimensional Z-transform. An example of such in physics is found
in Ref. [3], Here we will attempt to nd the probability of the
number of successes s in n trials, p(s, n) at a game for which the
probability of a success in a single trial, p(1, 1) is known. Let us
designate this probability as being equal to p. Then
Figure 10 Ratio of investment status m to inated annual withdrawal w This is a partial difference equation in variables s and n. It
as a function of time in years n for different ratios of investment P and can be solved by a two-dimensional Z-transformation. To this end
ination rate I for an initial ratio m/w = 20. we will introduce some needed z-domain variables
nd that if we have not had two successes in six trials the chances Dene the transform of f(n) as Z[f(n)] = F(z) and using Table
of that happening are fading. If this was a gambling lesson there 1 we can nd the transform of n f(n) to be zdF(z)/dz. With
would be much more to say about Equation (42) but the purpose these denitions we can write the transform of (44) as a differential
of this exercise was to demonstrate the use of a two dimensional equation
Z-transform.
dF (z) 1
+ F (z) F (z) = 0
dz z
APPPLICATION OF THE Z-TRANSFORM TO Separation of variables yields dF (z)/F (z) = dz/(z 1),
CONNECTIVITY which after integration produces ln F (z) = ln z z + c. This is
further developed into
If we have n nodes connected to each other how many total links
do we have? F (z) = eln zz+c = kzez (45)
It is very easy to tell from the illustration Figure 14 that a new
node added to the previous n nodes creates exactly n new links. Constant k in (45) arises from the integration constant c. F(z)
If we call the number of initial links l(n) then the number of links is the factorial function in the z domain. To bring it back into the
between n + 1 nodes will be l(n + 1) = l(n) + n. This is a difference n domain we must perform an inverse transformation. Because
equation for l for which a closed form solution can be obtained with we have set no restrictions on n, the resulting expression will be
the Z-transform. Dene Z[l(n)] = L(z) and from Table 1 we get for applicable to any value of n, including complex numbers. Using
the transform of l(n + 1) the expression Z[l(n + 1)] = Z[l(z)] z (2) and substituting (45) for the transformed function we can write
l(0) and for the transform of n the expression z/(z 1)2 . We can now the inverse transform
transcribe our equation in the z-domain as zL(z) zl(0) = L(z) +
z/(z 1)2 . There are zero links for zero nodes, thus l(0) = 0. This 1 k
f (n) = F (z)z n1
dz = ez zn dz.
leads to the nal transformed number of nodes 2j 2j
z
L(z) = (43)
(z 1)3 A straightforward probing of the integrand reveals that its
region of convergence is limited to positive values of z, meaning
Expression (43) consists of a third order pole at z = 1. Using that the transform exists only when the lower limit of z is zero. For
(A7) with k = 3 and z1 = 1 we obtain for the inverse transform this case we can establish the constant k from the well-known fact
1 d2 that the factorial of 1 is 1. A per-partem integration of our modied
l(n) = [L(z)(z 1)3 zn1 ] | expression yields
2! dz2 z=1
1 d2 n 1 k k
= z | = n(n 1)zn2 | f (1) = 1 = ez zdz =
2! dz2 z=1 2 z=1 2j 2j
0
Substitute the value of z at the pole and obtain the famil-
for n = 1. Consequently k = 2j and we have
iar nal answer l(n) = n(n 1)/2. This answer could have been
derived in a less formal way by mathematical induction but not so
for our next example.
f (n) = zn ez dz (46)
0
Figure 14 Illustration of why the addition of one new node to the network
of n nodes produces n new links.
What the factorial function does for integers Eulers Gamma func-
tion does for all real numbers. It is considered to be a rare function
that does not originate in the solution of a differential equation.
We will derive it by means of Z-transform.
The factorial functions f (n) = n! = n (n 1)! basic def-
inition is f (n) = n f (n 1). Let us increment n in this Figure 15 Gamma function of a complex number nr + jni .
expression by one to obtain the following difference equation
This is the ultimate factorial function applicable to any real
f (n + 1) = n f (n) + f (n) (44) or complex number. Expression (46) with the argument (n 1) is
DEVELOPMENT OF SCIENTIFIC SIMULATION ALGORITHMS 85
known as the Gamma function [4] If h(n) happens to be a constant c its transform is simply
z
(n) = f (n 1) = zn1 ez dz (47) C(z) = c zn = c (A3)
z1
n=0
0
It is plotted in Figure 15 for complex values of n. For all If a function h(n) has a Z-transform H(z) then h(n + k), where
positive integers (n + 1) = n! As expected it produces the correct k is a positive integer has a transform
answer for say (4) = f(3) = 6. An important recursive relationship
(n + 1) = n(n), is found from a per-partem integration of (47)
that the Z-transform can serve as a tool for testing validities of Z[h(n + k)] = zk h(n)zn zk h(n)zn
small segments of scientic simulation algorithms. Its predictive n=0 n=0
power can benet the development of new algorithms and the
troubleshooting of existing ones. Closed-form solutions of stud-
k1
Z[n] = nzn = z z
h(1) h(2) h(n) dz
= h(0) + + 2 + + n + (A1) n=0 n=0
z z z
Using (A3) with the constant being one, we get for the trans-
Its causality demands.
form of the timing argument n the following expression
h(n) = 0 if n < 0 (A2) d z z
Z[n] = z =
dz z 1 (z 1)2
Table 1 Some Z-Transforms
This and some other transforms are summarized in Table 1.
n Let us apply the acquired knowledge to a trivial example.
Z[h(n)] = H(z) = h(n)z
n=0 We have invested an amount of money at 5% annual interest. We
Z[h(n + 1)] = zH(z) zh(0) want to know how much money we will have after n years. In 1
Z[h(n + 2)]z2 H(z) z2 h(0) zh(1) year this is h(n + 1) = h(n) 1.05. Using (A4) we can transform
Z(c) = c z1 z
Z(n) = (z1) z
2 this into zH(z) zh(0) = H(z) 1.05 Solving for H(z) we get
Z[nh(n)] = z dz d
H(z) H(z) = zh(0)/(z 1.05). While H(z) does carry the answer to our
z(z+1)
Z[n2 ] (z1) 2 Z[an ] = za z
original question it happens to be in the wrong domain, that is, in
Z[1/n!] = e1/z Z[ean ] = zez a the z-domain. We must transform it back into the n-domain and
Z[sin n] = z2 2z
z sin
cos +1 how to do that we will learn in the next section.
86 FAZARINC
Table 2 Some Inverse Z-Transforms It is common to use an asterisk (*) to denote the convolution,
1
so we can symbolize our statement as Z1 [H(z) W(z)] = h(n)
Z [H(z)] = h(n) = H(z)z 1 n1
1 n1 2j
dz
w(n). Apply the denition of the Z-transform from (1) to each of
Z1 = z1
1 z z
zz 1
n1 n1 the two factors in the above expression and then substitute j = k n
Z1 (zz )(zz
) = z z
1 2
1 2 1 2
Z1 (zz1 ) = (n 1)zn2
1
1 (n1)(n2)z1
1
2
n3
Z1 h(n)zn w(j)zj
Z (zz1 )3
= 2
1
n=0 j=0
1 n k n
The Inverse Z-Transformation =Z h(n)z w(k n)z z
1 n=0 k=n
We will use the notation h(n) = Z [H(z)] to indicate the inverse
transformation. We have shown in (2) that the following integral To the inverse transformation functions of n are just con-
accomplishes this procedure
we cancel out the two n powers of z we can
stants and after
position the h(n) term outside the transform operator. Then we
1
h(n) = H(z)zn1 dz (A5) have h(n) w(n) = h(n)Z1 w(k n)zk According to
2j
n=0 k=n
(A2), w(k n) vanishes for n > k. Therefore we can freely set the
A powerful method for evaluation of integrals of analytic lower limit of the second sum to k = 0. Then that sum becomes
functions is the Cauchys residue theorem [5]. If F(z) happens to a plain Z-transform of w(k n). Its inverse is then obviously the
be analytic its integral is found as function w(k n) itself. Consequently we end up with the answer
1 h(n) w(n) = h(n)w(k n) (A9)
F (z)dz = Res[F (z)] (A6)
2j n=0
In Table 3 we have summarized some useful inversion formu-
Res stands for the residuum at the pole of the function F(z).
las, employing discrete convolution. Particular attention was paid
This is dened for the kth order pole at z = z1 as
to the power of convolution when faced with having to transform
1 d k1 an as yet undened function w(n).
Resz1 ,k [F (z)] = F (z)(z z1 )k z=z (A7) With these preparations we are now ready to apply the Z
(k 1)! dzk1 1
transform techniques to solve an all important difference equation
Using (A6) we can then rewrite (A5) as that we will encounter in all our examples.
h(n) = Res[H(z)zn1 ] (A8)
Generic Solution of the Second Order Difference
Expression (A8) in conjunction with (A7) provides a rel- Equation
atively simple inversion method for most practical problems in
The equation we wish to solve for h(n) is
natural sciences, statistics and nance. Expression (A7) is by far
simpler to use than it may appear at rst glance. In Table 2 we
h(n + 2) 2h(n + 1)A + h(n)B = f (n) (A10)
see some of the results arising from it. A trivial example of its
application is our problem, which we left hanging in the previ- where f(n) is an arbitrary function of n. We employ (A4) to perform
ous section. In order to invert H(z) = zh(0)/(z 1.05), we must the transformation of h(n) into H(z) such that Z[h(n)] = H(z). The
rst nd the residuum of R(z) = H(z)zn1 at the pole located at relevant recipes are found in Table 1
z1 = 1.05. It happens to be a single pole thus k = 1. Using these
values the residuum is Res1.05,1 [H(z)zn1 ]z=1.05 = h(0)1.05n z2 H(z) h(0)z2 h(1)z 2H(z)zA + 2h(0)zA + H(z)B
Here h(0) is obviously our initial investment in year 0. Some
more serious problems are addressed in the body of this paper. = Z[f (n)].
into the n-domain and can be incorporated into the inverted solu-
1
(zz )(zz ) 2 1 2
A
+f (n) Bn/21 sin n + Bn/21 cos n
B A2
(A15)
Case of Real Unequal Poles A2 > B
Equation (A8) explains the rst two terms in the next expression
h(n) = H(z)(z z1 )zn1 |z=z1 + H(z)(z z2 )zn1 |z=z2 Case of Identical Poles A2 = B
1
+ Z1 [Z[f (n)]] Z1 In this case z1 = z2 = A and expression (A11) becomes
(z z1 )(z z2 )
h(0)z2 + h(1)z 2h(0)zA 1
In the third term the asterisk denotes the convolution oper- H(z) = + Z[f (n)]
ator dened and derived in (A9). The inverse transform of (z A)2 (z A)2
the last expression is found in Table 2 in the form (zn1 1 = H1 (z) + H2 (z)
zn1
2 )/(z1 z2 ) and the tentative solution of our Equation (A10) is
then We will invert each term separately and start with H1 (z),
zn+1 zn+1 zn zn2 which exhibits a double pole at A and according to (A6) transforms
h(n) = h(0) 1 2
+ [h(1) 2h(0)A] 1 into
z1 z2 z1 z2
d
zn1 zn1 Z1 [H1 (z)] = H1 (z)(z A)2 zn1
+ f (n) 1 2
(A13) dz z=A
z1 z2
The pole locations z1 and z2 are given in (A12). No further = h(0)A (1 n) + nh(1)An1
n
BIOGRAPHY