Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OK. I think I've figured out how to implement the Lie bracket. If there is a cleverer way to do this, I'd be grateful for improvements. It still seems rather clunky.

My code is the following:

Vir = CombinatorialFreeModule(QQbar,[Integer(), 'c'], prefix='L')

The Virasoro generators are output as L[n] for integers n, while the central element is output as L['c'] (just C would be nicer, but I haven't figured out how to do that).

I've implemented the Lie bracket as

def lie_bracket(element1, element2):
comp1=element1.monomial_coefficients().items()
comp2=element2.monomial_coefficients().items()
bracket=Vir.zero()
for i in comp1:
    for j in comp2:
        bracket= i[1]*j[1]*(i[0]-j[0])*Vir.monomial(i[0]+j[0]) + kronecker_delta(i[0],-j[0])*(i[0]^3-i[0])*Vir.monomial('c')/12 + bracket
return bracket

This code seems to work. E.g.

lie_bracket(Vir.monomial(2),Vir.monomial(-2))
----->    4*L[0] + 1/2*L['c']

Which is the correct output.