axiom-mail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-mail] Going mad with pattern matching


From: Alasdair McAndrew
Subject: [Axiom-mail] Going mad with pattern matching
Date: Mon, 28 May 2007 16:32:00 +1000

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]