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: > 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! I doubt this. I'm a little short on time though. Thus, please do me a favour: replace all rules with little local functions -- as I have done with "help". Then you can say )trace help (replace "help" with the name of the functions you want to trace) and you should see which rule was invoked. To see the arguments in a nicer form, you can use )trace help )mathprint but this works only after help was invoked already once. > 2) How do I force answers to be returned in factored form? Later... Short answer: you need to coerce them to an appropriate domain. Martin