File: rtest_z_transform.mac

package info (click to toggle)
maxima 5.49.0-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 128,980 kB
  • sloc: lisp: 437,854; fortran: 14,665; tcl: 10,143; sh: 4,598; makefile: 2,204; ansic: 447; java: 374; python: 262; perl: 201; xml: 60; awk: 28; sed: 15; javascript: 2
file content (131 lines) | stat: -rw-r--r-- 3,893 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* tests for z-transform code
 * Copyright 2008 by Robert Dodier
 * I release this work under terms of the GNU General Public License
 */

/* for further examples, see also:
 * http://web.mit.edu/reduce_v20101007/reduce-algebra-20101007/packages/ztrans/ztrans.tst
 * and: http://www.reduce-algebra.com/docs/ztrans.pdf
 */

(if not get ('z_transform, 'present) then load (z_transform), 0);
0;

/*
 * Table 9.1.3 at: http://mathfaculty.fullerton.edu/MATHEWS/C2003/ZTRANSFORMINTROMOD.HTML
 */
 
apply_z_transform (z_transform (kron_delta (n, 0), n, z));
    1;

apply_z_transform (z_transform (kron_delta (0, n), n, z));
    1;

apply_z_transform (z_transform (1, n, z)), ratsimp, factor;
    z/(z - 1);

apply_z_transform (z_transform (b^n, n, z));
    z/(z - b);

apply_z_transform (z_transform (exp (a*n), n, z));
    z/(z - exp (a));

apply_z_transform (z_transform (n, n, z)), ratsimp, factor;
    z/(z - 1)^2;

apply_z_transform (z_transform (n^2, n, z)), ratsimp, factor;
    z*(z + 1)/(z - 1)^3;

apply_z_transform (z_transform (b^n * n, n, z));
    'subst (z/b, z, -z * 'diff (z/(z - 1), z, 1));
    
''%, nouns, ratsimp, factor;
    b*z / (z - b)^2;

apply_z_transform (z_transform (exp (a*n) * n, n, z));
    -z * 'diff (z/(z - %e^a), z, 1);
    
''%, nouns, ratsimp, factor;
    z*exp(a) / (z - exp(a))^2;

apply_z_transform (z_transform (sin (a*n), n, z)), ratsimp, factor;
    z*sin(a) / (z^2 - 2*cos(a)*z + 1);

apply_z_transform (z_transform (b^n * sin (a*n), n, z));
    'subst (z/b, z, z*sin(a) / (z^2 - 2*cos(a)*z + 1));

''%, nouns, ratsimp, factor;
    b*z*sin(a) / (z^2 - 2*cos(a)*b*z + b^2);

apply_z_transform (z_transform (cos (a*n), n, z)), ratsimp, factor;
    z * (z - cos(a)) / (z^2 - 2*cos(a)*z + 1);

apply_z_transform (z_transform (b^n * cos (a*n), n, z));
    'subst (z/b, z, z * (z - cos(a)) / (z^2 - 2*cos(a)*z + 1));
    
''%, nouns, ratsimp, factor;
    z * (z - b*cos(a)) / (z^2 - 2*cos(a)*b*z + b^2);

/*
 * Other examples.
 */

apply_z_transform (z_transform (kron_delta (m, x), m, u));
    1/u^x;

apply_z_transform (z_transform (kron_delta (y, m), m, u));
    1/u^y;

apply_z_transform (z_transform (convolution (f(m, u), g(m, u)), m, u));
    z_transform(f(m,u),m,u)*z_transform(g(m,u),m,u);

apply_z_transform (z_transform (kron_delta (m, x) + 1, m, u));
    1/u^x + u/(u - 1);

apply_z_transform (z_transform (10 * m - convolution (f(m, u), g(m, u)) / %pi, m, u));
    10*u/(u - 1)^2 - z_transform(f(m,u),m,u)*z_transform(g(m,u),m,u) / %pi;

apply_z_transform (z_transform (sin (m*omega) - %i * sin (m*omega) * c^m + %pi, m, u));
    sin(omega)*u / (u^2 - 2*cos(omega)*u + 1)
      - %i * 'subst (u/c, u, sin(omega)*u / (u^2 - 2*cos(omega)*u + 1))
      + %pi * u/(u - 1);

/* from the mailing list 2009-02-14 */

e1a : apply_z_transform (z_transform (a+b*(e^(-p*T))^(m) , m, z));
b*z/(z-1/e^(p*T))+a*z/(z-1);

e1b : apply_z_transform (z_transform (a+b*(e^(p*T))^(m) , m, z));
b*z/(z-e^(p*T))+a*z/(z-1);

e2a : apply_z_transform (z_transform (a+b*(%e^(-p*T))^(m) , m, z));
(b*z)/(z - exp(-p*T)) + (a*z)/(z - 1);

e2b : apply_z_transform (z_transform (a+b*(%e^(p*T))^(m) , m, z));
(b*z)/(z - exp(p*T)) + (a*z)/(z - 1);

is (equal (e2a, subst (e=%e, e1a)));
true;

is (equal (e2b, subst (e=%e, e1b)));
true;

/* more about negative exponents */

apply_z_transform (z_transform (b^-n, n, z));
    z/(z - 1/b);

apply_z_transform (z_transform ((b^-a)^m, m, u));
    u/(u - 1/b^a);

apply_z_transform (z_transform (b^-n * n, n, z));
    'subst (z*b, z, -z * 'diff (z/(z - 1), z, 1));

apply_z_transform (z_transform ((a + b)^-m * m, m, s));
    'subst (s*(a + b), s, -s * 'diff (s/(s - 1), s, 1));

apply_z_transform (z_transform (b^-n * sin (a*n), n, z));
    'subst (z*b, z, z*sin(a) / (z^2 - 2*cos(a)*z + 1));
    
apply_z_transform (z_transform ((%pi - 1)^-k * cos (a*k), k, y));
    'subst (y*(%pi - 1), y, y * (y - cos(a)) / (y^2 - 2*cos(a)*y + 1));