# How do we define commutation relations?

Let us say I have the following commutation relations for an algebra:

$[J0,J1]=J2$

$[J0,J2]=-J1$

$[J1,J2]=2J0$

I would like to define these commutation relations and do manipulations with them. For example, I would like to calculate

$[J0,[J0,J1]]+[[J1,J2],J1]$.

How do (or, can) we do this in SageMath?

Bonus question: Can we find the Casimir operator for this algebra in SageMath?

edit retag close merge delete

Searching the source code for 'Casimir' comes up almost empty.

Thank you! I was expecting that as it is not a straightforward calculation.

Maybe I am pushing my luck but can we define calculations like

$[J1,J0J2]=[J1,J0]J2+J0[J1,J2]$

?

You could define F as in my answer and then use A = F.enveloping_algebra(), and take a quotient of A by A.ideal( <your relation> , side='twosided').

Thank you, I changed .enveloping_algebra() to .universal_enveloping_algebra() as in the following

d = {('J0', 'J1'): {'J2': 1}, ('J0', 'J2'): {'J1': -1}, ('J1', 'J2'): {'J0': 2}}
F.<J0, J1, J2> = LieAlgebra(QQ, d)
A = F.universal_enveloping_algebra()
A.ideal(side='twosided')
A.bracket(J0*J2, J2)


and it worked. However, if I change QQ to CC or SR, this yields the error "AttributeError: 'LieAlgebraWithStructureCoefficients_with_category' object has no attribute 'lift'". I may need to use imaginary numbers or symbolic variables in the future.

Sort by » oldest newest most voted Lie algebra approach:

sage: d = {('J0', 'J1'): {'J2': 1}, ('J0', 'J2'): {'J1': -1}, ('J1', 'J2'): {'J0': 2}}
sage: F.<J0, J1, J2> = LieAlgebra(QQ, d)
sage: F
Lie algebra on 3 generators (J0, J1, J2) over Rational Field
sage: F.bracket(J0, J1)
J2
sage: F.bracket(J0, F.bracket(J0, J1))
-J1
sage: F.bracket(J0, F.bracket(J0, J1)) + F.bracket(F.bracket(J1, J2), J1)
-J1 + 2*J2


Flawed approach below; feel free to ignore (or work on Sage to improve things!).

The following naïve approach doesn't seem to work well in Sage:

sage: F.<J0,J1,J2> = FreeAlgebra(QQ)
sage: def comm(x,y): return x*y-y*x
sage: I = F.ideal(comm(J0, J1) - J2, comm(J0, J2) + J1, comm(J1, J2) - 2*J0)
sage: A = F.quotient(I)

sage: comm(J0, comm(J0, J1)) + comm(comm(J1, J2), J1)
J0^2*J1 - 2*J0*J1*J0 + J1*J0^2 - J1^2*J2 + 2*J1*J2*J1 - J2*J1^2
sage: A(comm(J0, comm(J0, J1)) + comm(comm(J1, J2), J1))
J0bar^2*J1bar - 2*J0bar*J1bar*J0bar + J1bar*J0bar^2 - J1bar^2*J2bar + 2*J1bar*J2bar*J1bar - J2bar*J1bar^2


This is clearly flawed. It can't even tell that the generators of the ideal are sent to zero in the quotient:

sage: [A(x)==0 for x in I.gens()]
[False, False, False]


Another approach would be to construct the algebra from scratch. You should be able to describe a vector space basis for it, so you can then construct it using CombinatorialFreeModule, the way Clifford algebras (among many other examples) are constructed in Sage.

more