# [Maxima] pattern matching

Marcello Musso musso at physics.utexas.edu
Tue Mar 11 02:32:00 CDT 2008

```Thanks Robert for the suggestion. It seems to work well for diff, but not
for idiff.

defmatch(check,'idiff(arg,t));
disprule(check);
=>  check:idiff(arg,t)->[]

and this behavior doesnt seem to change with or without the quotation
mark. in this case i still get

check(idiff(N([],[]),t));
=> false

which from what you say can be expected since idiff(N([],[]),t) dsplays as
N([],[],t). However i also get

check(idiff(diff(N([],[]),t),i));
=> false

even if idiff(diff(N([],[]),t),i) doesnt evaluate idiff.
I am doing this because i want maxima to display

idiff(diff(N([],[]),t),i)

as

(d/dt) N([],[],i)

so any other way to achieve this would help too.

Thanks,
Marcello

On Mon, 10 Mar 2008, Robert Dodier wrote:

> On 3/10/08, Marcello Musso <musso at physics.utexas.edu> wrote:
>
>>  (%i1) matchdeclare([arg,t],all);
>>  (%o1) done
>>  (%i2) defmatch(check,diff(arg,t));
>>  (%o2) check
>>  (%i3) depends(N,t);
>>  (%o3) [N(t)]
>>  (%i3) check(diff(N,t));
>>  (%o3) false
>
> Maxima distinguishes so-called noun and verb expressions.
> defmatch(check, diff(arg, t)) matches against a verb.
> Looks like defmatch(check, 'diff(arg, t)) (note the quote mark)
> matches against a derivative noun (i.e. something displayed by
> Maxima as dfoo/dx) as expected.
>
> matchdeclare ([arg, t], all);
> defmatch (check, 'diff (arg, t));
> disprule (check);
> => check : darg/dt -> []
> depends (N, t);
> check (diff (N, t));
> => [t = t, arg = N]
>
> Hope this helps,
>
> Robert Dodier
>

************************************************
*  Marcello Musso                              *
*  University of Texas at Austin               *
*  Department of Physics - Theory group        *
*  1, University Station C1608                 *
*  Austin, TX 78712-0269 - USA                 *
*  office phone: (512)-471-4108                *
*  VoIP phone: +39-02-303129852                *
************************************************
```