Re: Going mad with pattern matching
"Alasdair McAndrew" <[email protected]>
| Newsgroups | gmane.comp.mathematics.axiom.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks, Martin, As always I am helped by you! I have two questions; maybe you can answer them: 1) How do I include linearity in the pattern matching rules? At present, the command ztrans(2+3^n,nz) which should return the result 2z/(z-1)+z/(z-3) produces (2+3^n)z/(z-1). That is, the pattern matcher incorrectly applies the rule zt(a | freeOf?(a,n),n,z) == a*z/(z-1) even though 2+3^n is not free of n! 2) How do I force answers to be returned in factored form? Thanks, Alasdair On 28 May 2007 18:52:36 +0200, Martin Rubey <[email protected]> wrote: > > "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 > > _______________________________________________ Axiom-mail mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/axiom-mail