Going mad with pattern matching
"Alasdair McAndrew" <[email protected]>
| Newsgroups | gmane.comp.mathematics.axiom.user |
|---|---|
| Message-ID | <[email protected]> |
I'm experimenting with the pattern matching facility of Axiom; with the aim
of developing a z-transform routine. This is what I have so far:
zt:=operator 'zt
ztransrules := rule
zt(f+g,n,z) == ztrans(f,n,z)+ztrans(g,n,z) -- two lines for linearity
zt((a | freeOf?(a,n)),n,z) == a*ztrans(f,n,z)
zt(0,n,z) == 0 -- a couple of end cases, probably not needed
zt(1,n,z) == z/(z-1)
zt(a | freeOf?(a,n),n,z) == a*z/(z-1) -- now some standard rules
zt((a | freeOf?(a,n))^n,n,z) == z/(z-a)
zt(n,n,z) == z/(z-1)^2
zt(n^(a | integer?(a) and a>1),n,z) == tmp:=z/(z-1)
for i in 1..a repeat
tmp:=-D(tmp,z)
tmp
ztrans(f,n,z)==ztransrules zt(f,n,z)
But this doesn't quite work. I'd be grateful for a little help here! (Then
I'll see if I can use the z-transform to solve some difference equations.)
Thanks,
Alasdair
_______________________________________________
Axiom-mail mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-mail