[Maxima] Non-exclusive pattern matching? e.g. distributiveness of a function, was: Predictable pattern matching?

Robert Dodier robert.dodier at gmail.com
Wed Dec 24 12:29:46 CST 2008

On 12/23/08, Martin Schönecker <ms_usenet at gmx.de> wrote:

>  (1) int[a_ + b_, x] := int[a, x] + int[b, x]
>  (2) int[c_ f_, x] := c int[f, x] /; FreeQ[c, x]
>  (3) int[x^n_, x] := 1/(n + 1) * x^(n + 1) /; n != -1
>  (4) int[c_, x] := c x /; FreeQ[c, x]

The part that is difficult for the Maxima pattern matcher at present
is the freeof stuff, since the result for one pattern variable depends
on another. Maxima matches variables in the order they are
encountered in the pattern, so it matches x after c (too late).

It seems feasible to detect dependencies among pattern variables
and to order them accordingly. That would not require any change
to the run-time code, in particular, it doesn't require backtracking.
Of course, it 's easy to make up examples which have cycles in
the dependency graph.

I'll take a look at it.



PS. On second glance, it appears x is not a variable.
Is that right? If so, that makes the matching problem simpler.

More information about the Maxima mailing list