[Maxima] Rule-based symbolic programming in Maxima?
robert.dodier at gmail.com
Thu Feb 1 00:13:42 CST 2007
I've kind of jumped the gun, so to speak. As programming rules in
Maxima is something of a black art, I got started on some rules for
z-transforms to make sure it's actually possible before I tell you so...
Anyway, I've appended this attempt (such as it is) to this message.
To learn about rules, in the reference manual see defrule,
tellsimpafter, and matchdeclare. There are some share packages
which construct and apply rules; one of them is ezunits.mac.
I think vect.mac defines some rules too.
The stuff below is sketchy, but I think we can beef it up.
It would be nice to get this z-transform stuff working since the
basic model of general rules + some special cases applies to
other integral transforms.
I hope I haven't spoiled the fun. I'm pretty sure there remains
a lot of work (maybe meaning a completely different approach)
to make a practically useful package.
PS. Here's the script as it stands (unfinished).
/* z-transform stuff
e0 : z_transform (kron_delta (m, x), m, u);
e1 : z_transform (1, m, u);
e2 : z_transform (m, m, u);
e3 : z_transform (convolution (f(m, u), g(m, u)), m, u);
e4 : z_transform (sin (m*omega), m, u);
matchdeclare ([nn, zz], symbolp);
/* Reverse the arguments so zz and nn are known when
* Maxima tries to match the expression to be transformed
matchdeclare (aa, all);
z_transform (aa, nn, zz),
mrofsnart_z (zz, nn, aa));
mrofsnart_z (zz, nn, 1),
1/(1 - 1/zz));
/* Have to try kron_delta both ways ... sigh */
simp : false;
mrofsnart_z (zz, nn, kron_delta (nn, aa)),
mrofsnart_z (zz, nn, kron_delta (aa, nn)),
simp : true;
mrofsnart_z (zz, nn, nn),
(1/zz)/(1 - 1/zz)^2);
mrofsnart_z (zz, nn, nn^2),
(1/zz)*(1 + 1/zz)/(1 - 1/zz)^3);
matchdeclare (cc, lambda ([e], not atom(e) and op(e) = 'convolution));
mrofsnart_z (zz, nn, cc),
block ([a : args(cc)], product (z_transform (a[i], nn, zz), i, 1 ,
matchdeclare (aa, lambda ([e], e # n));
mrofsnart_z (zz, nn, sin (aa*nn)),
sin(aa)*(1/zz)/(1 - 2*(1/zz)*cos(aa) + 1/zz^2));
mrofsnart_z (zz, nn, cos (aa*nn)),
(1 - cos(aa)*(1/zz))/(1 - 2*(1/zz)*cos(aa) + 1/zz^2));
matchdeclare (aa, all);
mrofsnart_z (zz, nn, aa),
z_transform (aa, nn, zz));
apply_z_transform (e) :=
apply1 (e, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10);
declare (z_transform, linear);
More information about the Maxima