Lie Algebras

AUTHORS:

  • Travis Scrimshaw (2013-05-03): Initial version

class sage.algebras.lie_algebras.lie_algebra.FinitelyGeneratedLieAlgebra(R, names=None, index_set=None, category=None)[source]

Bases: LieAlgebraWithGenerators

A finitely generated Lie algebra.

class sage.algebras.lie_algebras.lie_algebra.InfinitelyGeneratedLieAlgebra(R, names=None, index_set=None, category=None, prefix='L', **kwds)[source]

Bases: LieAlgebraWithGenerators

An infinitely generated Lie algebra.

class sage.algebras.lie_algebras.lie_algebra.LieAlgebra(R, names=None, category=None)[source]

Bases: Parent, UniqueRepresentation

A Lie algebra \(L\) over a base ring \(R\).

A Lie algebra is an \(R\)-module \(L\) with a bilinear operation called Lie bracket \([\cdot, \cdot] : L \times L \to L\) such that \([x, x] = 0\) and the following relation holds:

\[\bigl[ x, [y, z] \bigr] + \bigl[ y, [z, x] \bigr] + \bigl[ z, [x, y] \bigr] = 0.\]

This relation is known as the Jacobi identity (or sometimes the Jacobi relation). We note that from \([x, x] = 0\), we have \([x + y, x + y] = 0\). Next from bilinearity, we see that

\[0 = [x + y, x + y] = [x, x] + [x, y] + [y, x] + [y, y] = [x, y] + [y, x],\]

thus \([x, y] = -[y, x]\) and the Lie bracket is antisymmetric.

Lie algebras are closely related to Lie groups. Let \(G\) be a Lie group and fix some \(g \in G\). We can construct the Lie algebra \(L\) of \(G\) by considering the tangent space at \(g\). We can also (partially) recover \(G\) from \(L\) by using what is known as the exponential map.

Given any associative algebra \(A\), we can construct a Lie algebra \(L\) on the \(R\)-module \(A\) by defining the Lie bracket to be the commutator \([a, b] = ab - ba\). We call an associative algebra \(A\) which contains \(L\) in this fashion an enveloping algebra of \(L\). The embedding \(L \to A\) which sends the Lie bracket to the commutator will be called a Lie embedding. Now if we are given a Lie algebra \(L\), we can construct an enveloping algebra \(U_L\) with Lie embedding \(h : L \to U_L\) which has the following universal property: for any enveloping algebra \(A\) with Lie embedding \(f : L \to A\), there exists a unique unital algebra homomorphism \(g : U_L \to A\) such that \(f = g \circ h\). The algebra \(U_L\) is known as the universal enveloping algebra of \(L\).

INPUT:

See examples below for various input options.

EXAMPLES:

1. The simplest examples of Lie algebras are abelian Lie algebras. These are Lie algebras whose Lie bracket is (identically) zero. We can create them using the abelian keyword:

sage: L.<x,y,z> = LieAlgebra(QQ, abelian=True); L
Abelian Lie algebra on 3 generators (x, y, z) over Rational Field
>>> from sage.all import *
>>> L = LieAlgebra(QQ, abelian=True, names=('x', 'y', 'z',)); (x, y, z,) = L._first_ngens(3); L
Abelian Lie algebra on 3 generators (x, y, z) over Rational Field
L.<x,y,z> = LieAlgebra(QQ, abelian=True); L

2. A Lie algebra can be built from any associative algebra by defining the Lie bracket to be the commutator. For example, we can start with the descent algebra:

sage: D = DescentAlgebra(QQ, 4).D()
sage: L = LieAlgebra(associative=D); L
Lie algebra of Descent algebra of 4 over Rational Field
 in the standard basis
sage: L(D[2]).bracket(L(D[3]))
D{1, 2} - D{1, 3} + D{2} - D{3}
>>> from sage.all import *
>>> D = DescentAlgebra(QQ, Integer(4)).D()
>>> L = LieAlgebra(associative=D); L
Lie algebra of Descent algebra of 4 over Rational Field
 in the standard basis
>>> L(D[Integer(2)]).bracket(L(D[Integer(3)]))
D{1, 2} - D{1, 3} + D{2} - D{3}
D = DescentAlgebra(QQ, 4).D()
L = LieAlgebra(associative=D); L
L(D[2]).bracket(L(D[3]))

Next we use a free algebra and do some simple computations:

sage: R.<a,b,c> = FreeAlgebra(QQ, 3)
sage: L.<x,y,z> = LieAlgebra(associative=R.gens())
sage: x-y+z
a - b + c
sage: L.bracket(x-y, x-z)
a*b - a*c - b*a + b*c + c*a - c*b
sage: L.bracket(x-y, L.bracket(x,y))
a^2*b - 2*a*b*a + a*b^2 + b*a^2 - 2*b*a*b + b^2*a
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(3), names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3)
>>> L = LieAlgebra(associative=R.gens(), names=('x', 'y', 'z',)); (x, y, z,) = L._first_ngens(3)
>>> x-y+z
a - b + c
>>> L.bracket(x-y, x-z)
a*b - a*c - b*a + b*c + c*a - c*b
>>> L.bracket(x-y, L.bracket(x,y))
a^2*b - 2*a*b*a + a*b^2 + b*a^2 - 2*b*a*b + b^2*a
R.<a,b,c> = FreeAlgebra(QQ, 3)
L.<x,y,z> = LieAlgebra(associative=R.gens())
x-y+z
L.bracket(x-y, x-z)
L.bracket(x-y, L.bracket(x,y))

We can also use a subset of the elements as a generating set of the Lie algebra:

sage: R.<a,b,c> = FreeAlgebra(QQ, 3)
sage: L.<x,y> = LieAlgebra(associative=[a,b+c])
sage: L.bracket(x, y)
a*b + a*c - b*a - c*a
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(3), names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3)
>>> L = LieAlgebra(associative=[a,b+c], names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.bracket(x, y)
a*b + a*c - b*a - c*a
R.<a,b,c> = FreeAlgebra(QQ, 3)
L.<x,y> = LieAlgebra(associative=[a,b+c])
L.bracket(x, y)

Now for a more complicated example using the group ring of \(S_3\) as our base algebra:

sage: G = SymmetricGroup(3)
sage: S = GroupAlgebra(G, QQ)
sage: L.<x,y> = LieAlgebra(associative=S.gens())
sage: L.bracket(x, y)
(2,3) - (1,3)
sage: L.bracket(x, y-x)
(2,3) - (1,3)
sage: L.bracket(L.bracket(x, y), y)
2*(1,2,3) - 2*(1,3,2)
sage: L.bracket(x, L.bracket(x, y))
(2,3) - 2*(1,2) + (1,3)
sage: L.bracket(x, L.bracket(L.bracket(x, y), y))
0
>>> from sage.all import *
>>> G = SymmetricGroup(Integer(3))
>>> S = GroupAlgebra(G, QQ)
>>> L = LieAlgebra(associative=S.gens(), names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.bracket(x, y)
(2,3) - (1,3)
>>> L.bracket(x, y-x)
(2,3) - (1,3)
>>> L.bracket(L.bracket(x, y), y)
2*(1,2,3) - 2*(1,3,2)
>>> L.bracket(x, L.bracket(x, y))
(2,3) - 2*(1,2) + (1,3)
>>> L.bracket(x, L.bracket(L.bracket(x, y), y))
0
G = SymmetricGroup(3)
S = GroupAlgebra(G, QQ)
L.<x,y> = LieAlgebra(associative=S.gens())
L.bracket(x, y)
L.bracket(x, y-x)
L.bracket(L.bracket(x, y), y)
L.bracket(x, L.bracket(x, y))
L.bracket(x, L.bracket(L.bracket(x, y), y))

Here is an example using matrices:

sage: MS = MatrixSpace(QQ,2)
sage: m1 = MS([[0, -1], [1, 0]])
sage: m2 = MS([[-1, 4], [3, 2]])
sage: L.<x,y> = LieAlgebra(associative=[m1, m2])
sage: x
[ 0 -1]
[ 1  0]
sage: y
[-1  4]
[ 3  2]
sage: L.bracket(x,y)
[-7 -3]
[-3  7]
sage: L.bracket(y,y)
[0 0]
[0 0]
sage: L.bracket(y,x)
[ 7  3]
[ 3 -7]
sage: L.bracket(x, L.bracket(y,x))
[-6 14]
[14  6]
>>> from sage.all import *
>>> MS = MatrixSpace(QQ,Integer(2))
>>> m1 = MS([[Integer(0), -Integer(1)], [Integer(1), Integer(0)]])
>>> m2 = MS([[-Integer(1), Integer(4)], [Integer(3), Integer(2)]])
>>> L = LieAlgebra(associative=[m1, m2], names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> x
[ 0 -1]
[ 1  0]
>>> y
[-1  4]
[ 3  2]
>>> L.bracket(x,y)
[-7 -3]
[-3  7]
>>> L.bracket(y,y)
[0 0]
[0 0]
>>> L.bracket(y,x)
[ 7  3]
[ 3 -7]
>>> L.bracket(x, L.bracket(y,x))
[-6 14]
[14  6]
MS = MatrixSpace(QQ,2)
m1 = MS([[0, -1], [1, 0]])
m2 = MS([[-1, 4], [3, 2]])
L.<x,y> = LieAlgebra(associative=[m1, m2])
x
y
L.bracket(x,y)
L.bracket(y,y)
L.bracket(y,x)
L.bracket(x, L.bracket(y,x))

(See LieAlgebraFromAssociative for other examples.)

3. We can also creating a Lie algebra by inputting a set of structure coefficients. For example, we can create the Lie algebra of \(\QQ^3\) under the Lie bracket \(\times\) (cross-product):

sage: d = {('x','y'): {'z':1}, ('y','z'): {'x':1}, ('z','x'): {'y':1}}
sage: L.<x,y,z> = LieAlgebra(QQ, d)
sage: L
Lie algebra on 3 generators (x, y, z) over Rational Field
>>> from sage.all import *
>>> d = {('x','y'): {'z':Integer(1)}, ('y','z'): {'x':Integer(1)}, ('z','x'): {'y':Integer(1)}}
>>> L = LieAlgebra(QQ, d, names=('x', 'y', 'z',)); (x, y, z,) = L._first_ngens(3)
>>> L
Lie algebra on 3 generators (x, y, z) over Rational Field
d = {('x','y'): {'z':1}, ('y','z'): {'x':1}, ('z','x'): {'y':1}}
L.<x,y,z> = LieAlgebra(QQ, d)
L

To compute the Lie bracket of two elements, you cannot use the * operator. Indeed, this automatically lifts up to the universal enveloping algebra and takes the (associative) product there. To get elements in the Lie algebra, you must use bracket():

sage: L = LieAlgebra(QQ, {('e','h'): {'e':-2}, ('f','h'): {'f':2},
....:                     ('e','f'): {'h':1}}, names='e,f,h')
sage: e,f,h = L.lie_algebra_generators()
sage: L.bracket(h, e)
2*e
sage: elt = h*e; elt
e*h + 2*e
sage: P = elt.parent(); P
Noncommutative Multivariate Polynomial Ring in e, f, h over Rational Field,
 nc-relations: {...}
sage: R = P.relations()
sage: for rhs in sorted(R, key=str): print("{} = {}".format(rhs, R[rhs]))
f*e = e*f - h
h*e = e*h + 2*e
h*f = f*h - 2*f
>>> from sage.all import *
>>> L = LieAlgebra(QQ, {('e','h'): {'e':-Integer(2)}, ('f','h'): {'f':Integer(2)},
...                     ('e','f'): {'h':Integer(1)}}, names='e,f,h')
>>> e,f,h = L.lie_algebra_generators()
>>> L.bracket(h, e)
2*e
>>> elt = h*e; elt
e*h + 2*e
>>> P = elt.parent(); P
Noncommutative Multivariate Polynomial Ring in e, f, h over Rational Field,
 nc-relations: {...}
>>> R = P.relations()
>>> for rhs in sorted(R, key=str): print("{} = {}".format(rhs, R[rhs]))
f*e = e*f - h
h*e = e*h + 2*e
h*f = f*h - 2*f
L = LieAlgebra(QQ, {('e','h'): {'e':-2}, ('f','h'): {'f':2},
                    ('e','f'): {'h':1}}, names='e,f,h')
e,f,h = L.lie_algebra_generators()
L.bracket(h, e)
elt = h*e; elt
P = elt.parent(); P
R = P.relations()
for rhs in sorted(R, key=str): print("{} = {}".format(rhs, R[rhs]))

For convenience, there are two shorthand notations for computing Lie brackets:

sage: L([h,e])
2*e
sage: L([h,[e,f]])
0
sage: L([[h,e],[e,f]])
-4*e
sage: L[h, e]
2*e
sage: L[h, L[e, f]]
0
>>> from sage.all import *
>>> L([h,e])
2*e
>>> L([h,[e,f]])
0
>>> L([[h,e],[e,f]])
-4*e
>>> L[h, e]
2*e
>>> L[h, L[e, f]]
0
L([h,e])
L([h,[e,f]])
L([[h,e],[e,f]])
L[h, e]
L[h, L[e, f]]

Warning

Because this is a modified (abused) version of python syntax, it does NOT work with addition. For example L([e + [h, f], h]) and L[e + [h, f], h] will both raise errors. Instead you must use L[e + L[h, f], h].

4. We can construct a Lie algebra from a Cartan type by using the cartan_type option:

sage: L = LieAlgebra(ZZ, cartan_type=['C', 3])
sage: L.inject_variables()
Defining e1, e2, e3, f1, f2, f3, h1, h2, h3
sage: e1.bracket(e2)
-E[alpha[1] + alpha[2]]
sage: L([[e1, e2], e2])
0
sage: L([[e2, e3], e3])
0
sage: L([e2, [e2, e3]])
2*E[2*alpha[2] + alpha[3]]

sage: L = LieAlgebra(ZZ, cartan_type=['E', 6])
sage: L
Lie algebra of ['E', 6] in the Chevalley basis
>>> from sage.all import *
>>> L = LieAlgebra(ZZ, cartan_type=['C', Integer(3)])
>>> L.inject_variables()
Defining e1, e2, e3, f1, f2, f3, h1, h2, h3
>>> e1.bracket(e2)
-E[alpha[1] + alpha[2]]
>>> L([[e1, e2], e2])
0
>>> L([[e2, e3], e3])
0
>>> L([e2, [e2, e3]])
2*E[2*alpha[2] + alpha[3]]

>>> L = LieAlgebra(ZZ, cartan_type=['E', Integer(6)])
>>> L
Lie algebra of ['E', 6] in the Chevalley basis
L = LieAlgebra(ZZ, cartan_type=['C', 3])
L.inject_variables()
e1.bracket(e2)
L([[e1, e2], e2])
L([[e2, e3], e3])
L([e2, [e2, e3]])
L = LieAlgebra(ZZ, cartan_type=['E', 6])
L

When the Cartan type is finite type and simply-laced, we can also specify an asymmetry function from [Ka1990] using a Dynkin diagram orientation with the epsilon option:

sage: L = LieAlgebra(QQ, cartan_type=['A', 2], epsilon=[(1, 2)])
sage: e1, e2 = L.e()
sage: L[e1, e2]
-E[alpha[1] + alpha[2]]

sage: L = LieAlgebra(QQ, cartan_type=['A', 2], epsilon=[(2, 1)])
sage: e1, e2 = L.e()
sage: L[e1, e2]
E[alpha[1] + alpha[2]]
>>> from sage.all import *
>>> L = LieAlgebra(QQ, cartan_type=['A', Integer(2)], epsilon=[(Integer(1), Integer(2))])
>>> e1, e2 = L.e()
>>> L[e1, e2]
-E[alpha[1] + alpha[2]]

>>> L = LieAlgebra(QQ, cartan_type=['A', Integer(2)], epsilon=[(Integer(2), Integer(1))])
>>> e1, e2 = L.e()
>>> L[e1, e2]
E[alpha[1] + alpha[2]]
L = LieAlgebra(QQ, cartan_type=['A', 2], epsilon=[(1, 2)])
e1, e2 = L.e()
L[e1, e2]
L = LieAlgebra(QQ, cartan_type=['A', 2], epsilon=[(2, 1)])
e1, e2 = L.e()
L[e1, e2]

We also have matrix versions of the classical Lie algebras:

sage: L = LieAlgebra(ZZ, cartan_type=['A', 2], representation='matrix')
sage: L.gens()
(
[0 1 0]  [0 0 0]  [0 0 0]  [0 0 0]  [ 1  0  0]  [ 0  0  0]
[0 0 0]  [0 0 1]  [1 0 0]  [0 0 0]  [ 0 -1  0]  [ 0  1  0]
[0 0 0], [0 0 0], [0 0 0], [0 1 0], [ 0  0  0], [ 0  0 -1]
)
>>> from sage.all import *
>>> L = LieAlgebra(ZZ, cartan_type=['A', Integer(2)], representation='matrix')
>>> L.gens()
(
[0 1 0]  [0 0 0]  [0 0 0]  [0 0 0]  [ 1  0  0]  [ 0  0  0]
[0 0 0]  [0 0 1]  [1 0 0]  [0 0 0]  [ 0 -1  0]  [ 0  1  0]
[0 0 0], [0 0 0], [0 0 0], [0 1 0], [ 0  0  0], [ 0  0 -1]
)
L = LieAlgebra(ZZ, cartan_type=['A', 2], representation='matrix')
L.gens()

There is also the compact real form of matrix Lie algebras implemented (the base ring must currently be a field):

sage: L = LieAlgebra(QQ, cartan_type=['A', 2], representation="compact real")
sage: list(L.basis())
[
[ 0  1  0]  [ 0  0  1]  [ 0  0  0]  [ i  0  0]  [0 i 0]  [0 0 i]
[-1  0  0]  [ 0  0  0]  [ 0  0  1]  [ 0  0  0]  [i 0 0]  [0 0 0]
[ 0  0  0], [-1  0  0], [ 0 -1  0], [ 0  0 -i], [0 0 0], [i 0 0],

[ 0  0  0]  [0 0 0]
[ 0  i  0]  [0 0 i]
[ 0  0 -i], [0 i 0]
]
>>> from sage.all import *
>>> L = LieAlgebra(QQ, cartan_type=['A', Integer(2)], representation="compact real")
>>> list(L.basis())
[
[ 0  1  0]  [ 0  0  1]  [ 0  0  0]  [ i  0  0]  [0 i 0]  [0 0 i]
[-1  0  0]  [ 0  0  0]  [ 0  0  1]  [ 0  0  0]  [i 0 0]  [0 0 0]
[ 0  0  0], [-1  0  0], [ 0 -1  0], [ 0  0 -i], [0 0 0], [i 0 0],
<BLANKLINE>
[ 0  0  0]  [0 0 0]
[ 0  i  0]  [0 0 i]
[ 0  0 -i], [0 i 0]
]
L = LieAlgebra(QQ, cartan_type=['A', 2], representation="compact real")
list(L.basis())

5. We construct a free Lie algebra in a few different ways. There are two primary representations, as brackets and as polynomials:

sage: L = LieAlgebra(QQ, 'x,y,z'); L
Free Lie algebra generated by (x, y, z) over Rational Field
sage: P.<a,b,c> = LieAlgebra(QQ, representation='polynomial'); P
Lie algebra generated by (a, b, c) in
 Free Algebra on 3 generators (a, b, c) over Rational Field
>>> from sage.all import *
>>> L = LieAlgebra(QQ, 'x,y,z'); L
Free Lie algebra generated by (x, y, z) over Rational Field
>>> P = LieAlgebra(QQ, representation='polynomial', names=('a', 'b', 'c',)); (a, b, c,) = P._first_ngens(3); P
Lie algebra generated by (a, b, c) in
 Free Algebra on 3 generators (a, b, c) over Rational Field
L = LieAlgebra(QQ, 'x,y,z'); L
P.<a,b,c> = LieAlgebra(QQ, representation='polynomial'); P

This has the basis given by Hall and the one indexed by Lyndon words. We do some computations and convert between the bases:

sage: H = L.Hall()
doctest:warning...:
FutureWarning: The Hall basis has not been fully proven correct, but currently no bugs are known
See https://github.com/sagemath/sage/issues/16823 for details.
sage: H
Free Lie algebra generated by (x, y, z) over Rational Field in the Hall basis
sage: Lyn = L.Lyndon()
sage: Lyn
Free Lie algebra generated by (x, y, z) over Rational Field in the Lyndon basis
sage: x,y,z = Lyn.lie_algebra_generators()
sage: a = Lyn([x, [[z, [x, y]], [y, x]]]); a
-[x, [[x, y], [x, [y, z]]]] - [x, [[x, y], [[x, z], y]]]
sage: H(a)
[[x, y], [z, [x, [x, y]]]] - [[x, y], [[x, y], [x, z]]]
 + [[x, [x, y]], [z, [x, y]]]
>>> from sage.all import *
>>> H = L.Hall()
doctest:warning...:
FutureWarning: The Hall basis has not been fully proven correct, but currently no bugs are known
See https://github.com/sagemath/sage/issues/16823 for details.
>>> H
Free Lie algebra generated by (x, y, z) over Rational Field in the Hall basis
>>> Lyn = L.Lyndon()
>>> Lyn
Free Lie algebra generated by (x, y, z) over Rational Field in the Lyndon basis
>>> x,y,z = Lyn.lie_algebra_generators()
>>> a = Lyn([x, [[z, [x, y]], [y, x]]]); a
-[x, [[x, y], [x, [y, z]]]] - [x, [[x, y], [[x, z], y]]]
>>> H(a)
[[x, y], [z, [x, [x, y]]]] - [[x, y], [[x, y], [x, z]]]
 + [[x, [x, y]], [z, [x, y]]]
H = L.Hall()
H
Lyn = L.Lyndon()
Lyn
x,y,z = Lyn.lie_algebra_generators()
a = Lyn([x, [[z, [x, y]], [y, x]]]); a
H(a)

We also have the free Lie algebra given in the polynomial representation, which is the canonical embedding of the free Lie algebra into the free algebra (i.e., the ring of noncommutative polynomials). So the generators of the free Lie algebra are the generators of the free algebra and the Lie bracket is the commutator:

sage: P.<a,b,c> = LieAlgebra(QQ, representation='polynomial'); P
Lie algebra generated by (a, b, c) in
 Free Algebra on 3 generators (a, b, c) over Rational Field
sage: P.bracket(a, b) + P.bracket(a - c, b + 3*c)
2*a*b + 3*a*c - 2*b*a + b*c - 3*c*a - c*b
>>> from sage.all import *
>>> P = LieAlgebra(QQ, representation='polynomial', names=('a', 'b', 'c',)); (a, b, c,) = P._first_ngens(3); P
Lie algebra generated by (a, b, c) in
 Free Algebra on 3 generators (a, b, c) over Rational Field
>>> P.bracket(a, b) + P.bracket(a - c, b + Integer(3)*c)
2*a*b + 3*a*c - 2*b*a + b*c - 3*c*a - c*b
P.<a,b,c> = LieAlgebra(QQ, representation='polynomial'); P
P.bracket(a, b) + P.bracket(a - c, b + 3*c)

6. Nilpotent Lie algebras are Lie algebras such that there exists an integer \(s\) such that all iterated brackets of length longer than \(s\) are zero. They can be constructed from structural coefficients using the nilpotent keyword:

sage: L.<X,Y,Z> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
sage: L
Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
sage: L.category()
Category of finite dimensional nilpotent Lie algebras with basis over Rational Field
>>> from sage.all import *
>>> L = LieAlgebra(QQ, {('X','Y'): {'Z': Integer(1)}}, nilpotent=True, names=('X', 'Y', 'Z',)); (X, Y, Z,) = L._first_ngens(3)
>>> L
Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
>>> L.category()
Category of finite dimensional nilpotent Lie algebras with basis over Rational Field
L.<X,Y,Z> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, nilpotent=True)
L
L.category()

A second example defining the Engel Lie algebra:

sage: sc = {('X','Y'): {'Z': 1}, ('X','Z'): {'W': 1}}
sage: E.<X,Y,Z,W> = LieAlgebra(QQ, sc, nilpotent=True); E
Nilpotent Lie algebra on 4 generators (X, Y, Z, W) over Rational Field
sage: E.step()
3
sage: E[X, Y + Z]
Z + W
sage: E[X, [X, Y + Z]]
W
sage: E[X, [X, [X, Y + Z]]]
0
>>> from sage.all import *
>>> sc = {('X','Y'): {'Z': Integer(1)}, ('X','Z'): {'W': Integer(1)}}
>>> E = LieAlgebra(QQ, sc, nilpotent=True, names=('X', 'Y', 'Z', 'W',)); (X, Y, Z, W,) = E._first_ngens(4); E
Nilpotent Lie algebra on 4 generators (X, Y, Z, W) over Rational Field
>>> E.step()
3
>>> E[X, Y + Z]
Z + W
>>> E[X, [X, Y + Z]]
W
>>> E[X, [X, [X, Y + Z]]]
0
sc = {('X','Y'): {'Z': 1}, ('X','Z'): {'W': 1}}
E.<X,Y,Z,W> = LieAlgebra(QQ, sc, nilpotent=True); E
E.step()
E[X, Y + Z]
E[X, [X, Y + Z]]
E[X, [X, [X, Y + Z]]]

A nilpotent Lie algebra will also be constructed if given a category of a nilpotent Lie algebra:

sage: C = LieAlgebras(QQ).Nilpotent().FiniteDimensional().WithBasis()
sage: L.<X,Y,Z> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, category=C); L
Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
>>> from sage.all import *
>>> C = LieAlgebras(QQ).Nilpotent().FiniteDimensional().WithBasis()
>>> L = LieAlgebra(QQ, {('X','Y'): {'Z': Integer(1)}}, category=C, names=('X', 'Y', 'Z',)); (X, Y, Z,) = L._first_ngens(3); L
Nilpotent Lie algebra on 3 generators (X, Y, Z) over Rational Field
C = LieAlgebras(QQ).Nilpotent().FiniteDimensional().WithBasis()
L.<X,Y,Z> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}, category=C); L

7. Free nilpotent Lie algebras are the truncated versions of the free Lie algebras. That is, the only relations other than anticommutativity and the Jacobi identity among the Lie brackets are that brackets of length higher than the nilpotency step vanish. They can be created by using the step keyword:

sage: L = LieAlgebra(ZZ, 2, step=3); L
Free Nilpotent Lie algebra on 5 generators (X_1, X_2, X_12, X_112, X_122) over Integer Ring
sage: L.step()
3
>>> from sage.all import *
>>> L = LieAlgebra(ZZ, Integer(2), step=Integer(3)); L
Free Nilpotent Lie algebra on 5 generators (X_1, X_2, X_12, X_112, X_122) over Integer Ring
>>> L.step()
3
L = LieAlgebra(ZZ, 2, step=3); L
L.step()

REFERENCES:

get_order()[source]

Return an ordering of the basis indices.

Todo

Remove this method and in CombinatorialFreeModule in favor of a method in the category of (finite dimensional) modules with basis.

EXAMPLES:

sage: L.<x,y> = LieAlgebra(QQ, {})
sage: L.get_order()
('x', 'y')
>>> from sage.all import *
>>> L = LieAlgebra(QQ, {}, names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.get_order()
('x', 'y')
L.<x,y> = LieAlgebra(QQ, {})
L.get_order()
monomial(i)[source]

Return the monomial indexed by i.

EXAMPLES:

sage: L = lie_algebras.Heisenberg(QQ, oo)
sage: L.monomial('p1')
p1
>>> from sage.all import *
>>> L = lie_algebras.Heisenberg(QQ, oo)
>>> L.monomial('p1')
p1
L = lie_algebras.Heisenberg(QQ, oo)
L.monomial('p1')
term(i, c=None)[source]

Return the term indexed by i with coefficient c.

EXAMPLES:

sage: L = lie_algebras.Heisenberg(QQ, oo)
sage: L.term('p1', 4)
4*p1
>>> from sage.all import *
>>> L = lie_algebras.Heisenberg(QQ, oo)
>>> L.term('p1', Integer(4))
4*p1
L = lie_algebras.Heisenberg(QQ, oo)
L.term('p1', 4)
zero()[source]

Return the element \(0\).

EXAMPLES:

sage: L.<x,y> = LieAlgebra(QQ, representation='polynomial')
sage: L.zero()
0
>>> from sage.all import *
>>> L = LieAlgebra(QQ, representation='polynomial', names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.zero()
0
L.<x,y> = LieAlgebra(QQ, representation='polynomial')
L.zero()
class sage.algebras.lie_algebras.lie_algebra.LieAlgebraFromAssociative(A, gens=None, names=None, index_set=None, category=None)[source]

Bases: LieAlgebraWithGenerators

A Lie algebra whose elements are from an associative algebra and whose bracket is the commutator.

Todo

Split this class into 2 classes, the base class for the Lie algebra corresponding to the full associative algebra and a subclass for the Lie subalgebra (of the full algebra) generated by a generating set?

Todo

Return the subalgebra generated by the basis elements of self for the universal enveloping algebra.

EXAMPLES:

For the first example, we start with a commutative algebra. Note that the bracket of everything will be 0:

sage: R = SymmetricGroupAlgebra(QQ, 2)
sage: L = LieAlgebra(associative=R)
sage: x, y = L.basis()
sage: L.bracket(x, y)
0
>>> from sage.all import *
>>> R = SymmetricGroupAlgebra(QQ, Integer(2))
>>> L = LieAlgebra(associative=R)
>>> x, y = L.basis()
>>> L.bracket(x, y)
0
R = SymmetricGroupAlgebra(QQ, 2)
L = LieAlgebra(associative=R)
x, y = L.basis()
L.bracket(x, y)

Next we use a free algebra and do some simple computations:

sage: R.<a,b> = FreeAlgebra(QQ, 2)
sage: L = LieAlgebra(associative=R)
sage: x,y = L(a), L(b)
sage: x-y
a - b
sage: L.bracket(x-y, x)
a*b - b*a
sage: L.bracket(x-y, L.bracket(x,y))
a^2*b - 2*a*b*a + a*b^2 + b*a^2 - 2*b*a*b + b^2*a
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(2), names=('a', 'b',)); (a, b,) = R._first_ngens(2)
>>> L = LieAlgebra(associative=R)
>>> x,y = L(a), L(b)
>>> x-y
a - b
>>> L.bracket(x-y, x)
a*b - b*a
>>> L.bracket(x-y, L.bracket(x,y))
a^2*b - 2*a*b*a + a*b^2 + b*a^2 - 2*b*a*b + b^2*a
R.<a,b> = FreeAlgebra(QQ, 2)
L = LieAlgebra(associative=R)
x,y = L(a), L(b)
x-y
L.bracket(x-y, x)
L.bracket(x-y, L.bracket(x,y))

We can also use a subset of the generators as a generating set of the Lie algebra:

sage: R.<a,b,c> = FreeAlgebra(QQ, 3)
sage: L.<x,y> = LieAlgebra(associative=[a,b])
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(3), names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3)
>>> L = LieAlgebra(associative=[a,b], names=('x', 'y',)); (x, y,) = L._first_ngens(2)
R.<a,b,c> = FreeAlgebra(QQ, 3)
L.<x,y> = LieAlgebra(associative=[a,b])

Now for a more complicated example using the group ring of \(S_3\) as our base algebra:

sage: G = SymmetricGroup(3)
sage: S = GroupAlgebra(G, QQ)
sage: L.<x,y> = LieAlgebra(associative=S.gens())
sage: L.bracket(x, y)
(2,3) - (1,3)
sage: L.bracket(x, y-x)
(2,3) - (1,3)
sage: L.bracket(L.bracket(x, y), y)
2*(1,2,3) - 2*(1,3,2)
sage: L.bracket(x, L.bracket(x, y))
(2,3) - 2*(1,2) + (1,3)
sage: L.bracket(x, L.bracket(L.bracket(x, y), y))
0
>>> from sage.all import *
>>> G = SymmetricGroup(Integer(3))
>>> S = GroupAlgebra(G, QQ)
>>> L = LieAlgebra(associative=S.gens(), names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.bracket(x, y)
(2,3) - (1,3)
>>> L.bracket(x, y-x)
(2,3) - (1,3)
>>> L.bracket(L.bracket(x, y), y)
2*(1,2,3) - 2*(1,3,2)
>>> L.bracket(x, L.bracket(x, y))
(2,3) - 2*(1,2) + (1,3)
>>> L.bracket(x, L.bracket(L.bracket(x, y), y))
0
G = SymmetricGroup(3)
S = GroupAlgebra(G, QQ)
L.<x,y> = LieAlgebra(associative=S.gens())
L.bracket(x, y)
L.bracket(x, y-x)
L.bracket(L.bracket(x, y), y)
L.bracket(x, L.bracket(x, y))
L.bracket(x, L.bracket(L.bracket(x, y), y))

Here is an example using matrices:

sage: MS = MatrixSpace(QQ,2)
sage: m1 = MS([[0, -1], [1, 0]])
sage: m2 = MS([[-1, 4], [3, 2]])
sage: L.<x,y> = LieAlgebra(associative=[m1, m2])
sage: x
[ 0 -1]
[ 1  0]
sage: y
[-1  4]
[ 3  2]
sage: L.bracket(x,y)
[-7 -3]
[-3  7]
sage: L.bracket(y,y)
[0 0]
[0 0]
sage: L.bracket(y,x)
[ 7  3]
[ 3 -7]
sage: L.bracket(x, L.bracket(y,x))
[-6 14]
[14  6]
>>> from sage.all import *
>>> MS = MatrixSpace(QQ,Integer(2))
>>> m1 = MS([[Integer(0), -Integer(1)], [Integer(1), Integer(0)]])
>>> m2 = MS([[-Integer(1), Integer(4)], [Integer(3), Integer(2)]])
>>> L = LieAlgebra(associative=[m1, m2], names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> x
[ 0 -1]
[ 1  0]
>>> y
[-1  4]
[ 3  2]
>>> L.bracket(x,y)
[-7 -3]
[-3  7]
>>> L.bracket(y,y)
[0 0]
[0 0]
>>> L.bracket(y,x)
[ 7  3]
[ 3 -7]
>>> L.bracket(x, L.bracket(y,x))
[-6 14]
[14  6]
MS = MatrixSpace(QQ,2)
m1 = MS([[0, -1], [1, 0]])
m2 = MS([[-1, 4], [3, 2]])
L.<x,y> = LieAlgebra(associative=[m1, m2])
x
y
L.bracket(x,y)
L.bracket(y,y)
L.bracket(y,x)
L.bracket(x, L.bracket(y,x))
class Element[source]

Bases: LieAlgebraElementWrapper

lift_associative()[source]

Lift self to the ambient associative algebra (which might be smaller than the universal enveloping algebra).

EXAMPLES:

sage: R = FreeAlgebra(QQ, 3, 'x,y,z')
sage: L.<x,y,z> = LieAlgebra(associative=R.gens())
sage: x.lift_associative()
x
sage: x.lift_associative().parent()
Free Algebra on 3 generators (x, y, z) over Rational Field
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(3), 'x,y,z')
>>> L = LieAlgebra(associative=R.gens(), names=('x', 'y', 'z',)); (x, y, z,) = L._first_ngens(3)
>>> x.lift_associative()
x
>>> x.lift_associative().parent()
Free Algebra on 3 generators (x, y, z) over Rational Field
R = FreeAlgebra(QQ, 3, 'x,y,z')
L.<x,y,z> = LieAlgebra(associative=R.gens())
x.lift_associative()
x.lift_associative().parent()
monomial_coefficients(copy=True)[source]

Return the monomial coefficients of self (if this notion makes sense for self.parent()).

EXAMPLES:

sage: R.<x,y,z> = FreeAlgebra(QQ)
sage: L = LieAlgebra(associative=R)
sage: elt = L(x) + 2*L(y) - L(z)
sage: sorted(elt.monomial_coefficients().items())
[(x, 1), (y, 2), (z, -1)]

sage: L = LieAlgebra(associative=[x,y])
sage: elt = L(x) + 2*L(y)
sage: elt.monomial_coefficients()
Traceback (most recent call last):
...
NotImplementedError: the basis is not defined
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, names=('x', 'y', 'z',)); (x, y, z,) = R._first_ngens(3)
>>> L = LieAlgebra(associative=R)
>>> elt = L(x) + Integer(2)*L(y) - L(z)
>>> sorted(elt.monomial_coefficients().items())
[(x, 1), (y, 2), (z, -1)]

>>> L = LieAlgebra(associative=[x,y])
>>> elt = L(x) + Integer(2)*L(y)
>>> elt.monomial_coefficients()
Traceback (most recent call last):
...
NotImplementedError: the basis is not defined
R.<x,y,z> = FreeAlgebra(QQ)
L = LieAlgebra(associative=R)
elt = L(x) + 2*L(y) - L(z)
sorted(elt.monomial_coefficients().items())
L = LieAlgebra(associative=[x,y])
elt = L(x) + 2*L(y)
elt.monomial_coefficients()
associative_algebra()[source]

Return the associative algebra used to construct self.

EXAMPLES:

sage: G = SymmetricGroup(3)
sage: S = GroupAlgebra(G, QQ)
sage: L = LieAlgebra(associative=S)
sage: L.associative_algebra() is S
True
>>> from sage.all import *
>>> G = SymmetricGroup(Integer(3))
>>> S = GroupAlgebra(G, QQ)
>>> L = LieAlgebra(associative=S)
>>> L.associative_algebra() is S
True
G = SymmetricGroup(3)
S = GroupAlgebra(G, QQ)
L = LieAlgebra(associative=S)
L.associative_algebra() is S
is_abelian()[source]

Return True if self is abelian.

EXAMPLES:

sage: R = FreeAlgebra(QQ, 2, 'x,y')
sage: L = LieAlgebra(associative=R.gens())
sage: L.is_abelian()
False

sage: R = PolynomialRing(QQ, 'x,y')
sage: L = LieAlgebra(associative=R.gens())
sage: L.is_abelian()
True
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(2), 'x,y')
>>> L = LieAlgebra(associative=R.gens())
>>> L.is_abelian()
False

>>> R = PolynomialRing(QQ, 'x,y')
>>> L = LieAlgebra(associative=R.gens())
>>> L.is_abelian()
True
R = FreeAlgebra(QQ, 2, 'x,y')
L = LieAlgebra(associative=R.gens())
L.is_abelian()
R = PolynomialRing(QQ, 'x,y')
L = LieAlgebra(associative=R.gens())
L.is_abelian()

An example with a Lie algebra from the group algebra:

sage: G = SymmetricGroup(3)
sage: S = GroupAlgebra(G, QQ)
sage: L = LieAlgebra(associative=S)
sage: L.is_abelian()
False
>>> from sage.all import *
>>> G = SymmetricGroup(Integer(3))
>>> S = GroupAlgebra(G, QQ)
>>> L = LieAlgebra(associative=S)
>>> L.is_abelian()
False
G = SymmetricGroup(3)
S = GroupAlgebra(G, QQ)
L = LieAlgebra(associative=S)
L.is_abelian()

Now we construct a Lie algebra from commuting elements in the group algebra:

sage: G = SymmetricGroup(5)
sage: S = GroupAlgebra(G, QQ)
sage: gens = map(S, [G((1, 2)), G((3, 4))])
sage: L.<x,y> = LieAlgebra(associative=gens)
sage: L.is_abelian()
True
>>> from sage.all import *
>>> G = SymmetricGroup(Integer(5))
>>> S = GroupAlgebra(G, QQ)
>>> gens = map(S, [G((Integer(1), Integer(2))), G((Integer(3), Integer(4)))])
>>> L = LieAlgebra(associative=gens, names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.is_abelian()
True
G = SymmetricGroup(5)
S = GroupAlgebra(G, QQ)
gens = map(S, [G((1, 2)), G((3, 4))])
L.<x,y> = LieAlgebra(associative=gens)
L.is_abelian()
lie_algebra_generators()[source]

Return the Lie algebra generators of self.

EXAMPLES:

sage: G = SymmetricGroup(3)
sage: S = GroupAlgebra(G, QQ)
sage: L = LieAlgebra(associative=S)
sage: L.lie_algebra_generators()
Finite family {(): (), (1,3,2): (1,3,2), (1,2,3): (1,2,3),
               (2,3): (2,3), (1,3): (1,3), (1,2): (1,2)}
>>> from sage.all import *
>>> G = SymmetricGroup(Integer(3))
>>> S = GroupAlgebra(G, QQ)
>>> L = LieAlgebra(associative=S)
>>> L.lie_algebra_generators()
Finite family {(): (), (1,3,2): (1,3,2), (1,2,3): (1,2,3),
               (2,3): (2,3), (1,3): (1,3), (1,2): (1,2)}
G = SymmetricGroup(3)
S = GroupAlgebra(G, QQ)
L = LieAlgebra(associative=S)
L.lie_algebra_generators()
monomial(i)[source]

Return the monomial indexed by i.

EXAMPLES:

sage: F.<x,y> = FreeAlgebra(QQ)
sage: L = LieAlgebra(associative=F)
sage: L.monomial(x.leading_support())
x
>>> from sage.all import *
>>> F = FreeAlgebra(QQ, names=('x', 'y',)); (x, y,) = F._first_ngens(2)
>>> L = LieAlgebra(associative=F)
>>> L.monomial(x.leading_support())
x
F.<x,y> = FreeAlgebra(QQ)
L = LieAlgebra(associative=F)
L.monomial(x.leading_support())
term(i, c=None)[source]

Return the term indexed by i with coefficient c.

EXAMPLES:

sage: F.<x,y> = FreeAlgebra(QQ)
sage: L = LieAlgebra(associative=F)
sage: L.term(x.leading_support(), 4)
4*x
>>> from sage.all import *
>>> F = FreeAlgebra(QQ, names=('x', 'y',)); (x, y,) = F._first_ngens(2)
>>> L = LieAlgebra(associative=F)
>>> L.term(x.leading_support(), Integer(4))
4*x
F.<x,y> = FreeAlgebra(QQ)
L = LieAlgebra(associative=F)
L.term(x.leading_support(), 4)
zero()[source]

Return the element \(0\) in self.

EXAMPLES:

sage: G = SymmetricGroup(3)
sage: S = GroupAlgebra(G, QQ)
sage: L = LieAlgebra(associative=S)
sage: L.zero()
0
>>> from sage.all import *
>>> G = SymmetricGroup(Integer(3))
>>> S = GroupAlgebra(G, QQ)
>>> L = LieAlgebra(associative=S)
>>> L.zero()
0
G = SymmetricGroup(3)
S = GroupAlgebra(G, QQ)
L = LieAlgebra(associative=S)
L.zero()
class sage.algebras.lie_algebras.lie_algebra.LieAlgebraWithGenerators(R, names=None, index_set=None, category=None, prefix='L', **kwds)[source]

Bases: LieAlgebra

A Lie algebra with distinguished generators.

gen(i)[source]

Return the i-th generator of self.

EXAMPLES:

sage: L.<x,y> = LieAlgebra(QQ, abelian=True)
sage: L.gen(0)
x
>>> from sage.all import *
>>> L = LieAlgebra(QQ, abelian=True, names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.gen(Integer(0))
x
L.<x,y> = LieAlgebra(QQ, abelian=True)
L.gen(0)
gens()[source]

Return a tuple whose entries are the generators for this object, in some order.

EXAMPLES:

sage: L.<x,y> = LieAlgebra(QQ, abelian=True)
sage: L.gens()
(x, y)
>>> from sage.all import *
>>> L = LieAlgebra(QQ, abelian=True, names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.gens()
(x, y)
L.<x,y> = LieAlgebra(QQ, abelian=True)
L.gens()
indices()[source]

Return the indices of self.

EXAMPLES:

sage: L.<x,y> = LieAlgebra(QQ, representation='polynomial')
sage: L.indices()
{'x', 'y'}
>>> from sage.all import *
>>> L = LieAlgebra(QQ, representation='polynomial', names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.indices()
{'x', 'y'}
L.<x,y> = LieAlgebra(QQ, representation='polynomial')
L.indices()
lie_algebra_generators()[source]

Return the generators of self as a Lie algebra.

EXAMPLES:

sage: L.<x,y> = LieAlgebra(QQ, representation='polynomial')
sage: L.lie_algebra_generators()
Finite family {'x': x, 'y': y}
>>> from sage.all import *
>>> L = LieAlgebra(QQ, representation='polynomial', names=('x', 'y',)); (x, y,) = L._first_ngens(2)
>>> L.lie_algebra_generators()
Finite family {'x': x, 'y': y}
L.<x,y> = LieAlgebra(QQ, representation='polynomial')
L.lie_algebra_generators()
class sage.algebras.lie_algebras.lie_algebra.LiftMorphismToAssociative(domain, codomain)[source]

Bases: LiftMorphism

The natural lifting morphism from a Lie algebra constructed from an associative algebra \(A\) to \(A\).

preimage(x)[source]

Return the preimage of x under self.

EXAMPLES:

sage: R = FreeAlgebra(QQ, 3, 'a,b,c')
sage: L = LieAlgebra(associative=R)
sage: x,y,z = R.gens()
sage: f = R.coerce_map_from(L)
sage: p = f.preimage(x*y - z); p
-c + a*b
sage: p.parent() is L
True
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(3), 'a,b,c')
>>> L = LieAlgebra(associative=R)
>>> x,y,z = R.gens()
>>> f = R.coerce_map_from(L)
>>> p = f.preimage(x*y - z); p
-c + a*b
>>> p.parent() is L
True
R = FreeAlgebra(QQ, 3, 'a,b,c')
L = LieAlgebra(associative=R)
x,y,z = R.gens()
f = R.coerce_map_from(L)
p = f.preimage(x*y - z); p
p.parent() is L
section()[source]

Return the section map of self.

EXAMPLES:

sage: R = FreeAlgebra(QQ, 3, 'x,y,z')
sage: L.<x,y,z> = LieAlgebra(associative=R.gens())
sage: f = R.coerce_map_from(L)
sage: f.section()
Generic morphism:
  From: Free Algebra on 3 generators (x, y, z) over Rational Field
  To:   Lie algebra generated by (x, y, z) in Free Algebra on 3 generators (x, y, z) over Rational Field
>>> from sage.all import *
>>> R = FreeAlgebra(QQ, Integer(3), 'x,y,z')
>>> L = LieAlgebra(associative=R.gens(), names=('x', 'y', 'z',)); (x, y, z,) = L._first_ngens(3)
>>> f = R.coerce_map_from(L)
>>> f.section()
Generic morphism:
  From: Free Algebra on 3 generators (x, y, z) over Rational Field
  To:   Lie algebra generated by (x, y, z) in Free Algebra on 3 generators (x, y, z) over Rational Field
R = FreeAlgebra(QQ, 3, 'x,y,z')
L.<x,y,z> = LieAlgebra(associative=R.gens())
f = R.coerce_map_from(L)
f.section()
class sage.algebras.lie_algebras.lie_algebra.MatrixLieAlgebraFromAssociative(A, gens=None, names=None, index_set=None, category=None)[source]

Bases: LieAlgebraFromAssociative

A Lie algebra constructed from a matrix algebra.

This means a Lie algebra consisting of matrices, with commutator as Lie bracket.

class Element[source]

Bases: LieAlgebraMatrixWrapper, Element

matrix()[source]

Return self as element of the underlying matrix algebra.

OUTPUT: an instance of the element class of MatrixSpace

EXAMPLES:

sage: sl3m = lie_algebras.sl(ZZ, 3, representation='matrix')
sage: e1,e2, f1, f2, h1, h2 = sl3m.gens()
sage: h1m = h1.matrix(); h1m
[ 1  0  0]
[ 0 -1  0]
[ 0  0  0]
sage: h1m.parent()
Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring
sage: matrix(h2)
[ 0  0  0]
[ 0  1  0]
[ 0  0 -1]
sage: L = lie_algebras.so(QQ['z'], 5, representation='matrix')
sage: matrix(L.an_element())
[ 1  1  0  0  0]
[ 1  1  0  0  2]
[ 0  0 -1 -1  0]
[ 0  0 -1 -1 -1]
[ 0  1  0 -2  0]

sage: gl2 = lie_algebras.gl(QQ, 2)
sage: matrix(gl2.an_element())
[1 1]
[1 1]
>>> from sage.all import *
>>> sl3m = lie_algebras.sl(ZZ, Integer(3), representation='matrix')
>>> e1,e2, f1, f2, h1, h2 = sl3m.gens()
>>> h1m = h1.matrix(); h1m
[ 1  0  0]
[ 0 -1  0]
[ 0  0  0]
>>> h1m.parent()
Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring
>>> matrix(h2)
[ 0  0  0]
[ 0  1  0]
[ 0  0 -1]
>>> L = lie_algebras.so(QQ['z'], Integer(5), representation='matrix')
>>> matrix(L.an_element())
[ 1  1  0  0  0]
[ 1  1  0  0  2]
[ 0  0 -1 -1  0]
[ 0  0 -1 -1 -1]
[ 0  1  0 -2  0]

>>> gl2 = lie_algebras.gl(QQ, Integer(2))
>>> matrix(gl2.an_element())
[1 1]
[1 1]
sl3m = lie_algebras.sl(ZZ, 3, representation='matrix')
e1,e2, f1, f2, h1, h2 = sl3m.gens()
h1m = h1.matrix(); h1m
h1m.parent()
matrix(h2)
L = lie_algebras.so(QQ['z'], 5, representation='matrix')
matrix(L.an_element())
gl2 = lie_algebras.gl(QQ, 2)
matrix(gl2.an_element())