# Constructing a non-commutative algebra over Z[q, q^-1] given some relations

I would like to construct a non-commutative alegebra over Z[q, q^-1] generated by the variables u1, u2, u3 with the relations:

u2*u1 = q*u1*u2

u3*u2 = (q^2)*u2*u3

u3*u1 = u1*u3

but I am having some trouble getting this to work. I have primarily been trying to do this using the FreeAlgebra structure. Here is what I have tried:

```
Zq.<q> = LaurentPolynomialRing(ZZ)
A.<u1,u2, u3> = FreeAlgebra(Zq, 3)
G = A.g_algebra({u2*u1: q*u1*u2, u3*u2: (q**2)*u2*u3})
G
```

but I get the errors:

```
AttributeError: 'FreeAlgebra_generic_with_category.element_class' object has no attribute 'lift'
TypeError: unable to coerce <class 'sage.algebras.free_algebra.FreeAlgebra_generic_with_category.element_class'> to `an integer`
```

```
Zqring.<q, qinv> = ZZ[]
qideal = Zqring.ideal(q*qinv - 1)
Zq.<q, qinv> = Zqring.quotient(qideal)
A.<u1,u2,u3> = FreeAlgebra(Zq, 3)
I = A.ideal(u2*u1-q*u1*u2, u3*u2-(q**2)*u2*u3, side = "twosided")
W.<u1, u2, u3> = quotient(A,I)
u2*u1-q*u1*u2
```

but this outputs "(-q)*u1*u2 + u2*u1" and not "0"

```
Zqring.<q, qinv> = ZZ[]
qideal = Zqring.ideal(q*qinv - 1)
Zq.<q, qinv> = Zqring.quotient(qideal)
A.<u1,u2,u3> = FreeAlgebra(Zq, 3)
I = A*[u2*u1-q*u1*u2]*A
W.<u1,u2,u3> = A.quo(I)
W(u2*u1-q*u1*u2)
```

and, again, the output is not "0".

Is there a better way I can construct such a non-commutative algebra? Thanks!

Welcome to Ask Sage! Thank you for your question.