This is a problem involving polynomials of SU(2) operators (or matrices) multiplied by scalar variables (e.g. x, y, etc.).
I'm trying to do something that I think should be relatively simple.  It is a physics problem involving two
spins A and B that are represented by components (Ax,Ay,Az) and (Bx,By,Bz) with commutation relations
[Ax,Ay] = Az, etc. similarly for the B's.  A's commute with B's [Ax, By] = 0, etc.
I want to be able to define a polynomial in the A's and B's and perform various functions involving multiplication
to form polynomials in the A's and B's multiplied by symbolic variables.  Each time a product of A's or B's
arises in the polynomial, I want to invoke the commutation relation to give, for example, AxAy = Az/2.  Then
I want to gather all terms together involving a certain product of A's and B's and extract the coefficient.  For example
if I define such a polynomial and square it, I want to be able to extract, say, the coefficient of the term AxBy.
Can someone please tell me how to set up polynomial operations involving scalar variables and SU(2) 
operators/matrices?  Any help would be greatly appreciated.