# [Maxima] matchdeclare and tellsimpafter

Michel Talon talon at lpthe.jussieu.fr
Fri Nov 19 16:23:10 CST 2010

```Edwin Woollett wrote:

> I am looking at commutator algebra and want to
> pull out numbers and declared scalars from the
> commutator symbol comm(x,y).
>
> Here I am only trying to pull out numerical factors.
>
> (%i1) matchdeclare (aa, all,bb, all,cc, all,dd, all)\$

Is this useful? Maybe it spoils your computation.

>
> /* try just using the predicate numberp  */
>
> (%i2) matchdeclare (mm, numberp)\$
>
> (%i3) tellsimpafter (comm (mm*aa, bb), mm*comm (aa, bb))\$
>
> (%i4) tellsimpafter (comm (aa, mm*bb), mm*comm (aa, bb))\$
>
> /* it works for first arg but not the second */
>

Works for me this way:
niobe% maxima
(%i1) ? numberp
....
(%i2) matchdeclare (mm, numberp)\$
(%i3) tellsimpafter (comm (mm*aa, bb), mm*comm (aa, bb))\$

(%i4) tellsimpafter (comm (aa, mm*bb), mm*comm (aa, bb))\$

(%i5) comm (2*a, b);
(%o5)                            comm(2 a, b)
(%i6) comm(2*aa,bb);
(%o6)                           2 comm(aa, bb)
(%i7) comm(aa,2*bb);
(%o7)                           2 comm(aa, bb)
(%i8) comm(aa/2,bb);
comm(aa, bb)
(%o8)                            ------------
2
(%i9) comm(aa,bb/2);
comm(aa, bb)
(%o9)                            ------------
2
(%i10)

Of course you then need to use the Lie algebra commutators (like i did for
the Poisson brackets and Jacobi identity) to transform any monomial in the
enveloping algebra into ordered basis elements according to Poincaré
Birkhoff Witt theorem. In principe this way you discover all identities
stemming from the Lie algebra structure. Of course if you are in a concrete
representation there are more identities to implement such as sigma^2=1
for the Pauli matrices.

--
Michel Talon

```