Re: Going mad with pattern matching
Martin Rubey <[email protected]>
| Newsgroups | gmane.comp.mathematics.axiom.user |
|---|---|
| Message-ID | <[email protected]> |
"Alasdair McAndrew" <[email protected]> writes: > 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.) it seems that rules don't like local function definitions too much. The usual syntax would be (op1; op2; ...; opn) which returns the value of opn, but I had no luck with this construction. zt:=operator 'zt help(z,a) == tmp := z/(z-1) for i in 1..a repeat tmp:=-D(tmp,z) tmp 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) == help(z, a) ztrans(f,n,z)==ztransrules zt(f,n,z) Does this answer your question? I'm a little in the dark, I must say. Martin