From 6d4b7ff3cf1b285953f0f3d3c5797067c0f52587 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 24 Jun 2019 23:08:24 -0400 Subject: [PATCH 01/16] eja: remove symmetry test that don't work. I don't know why, but the multiplication table of a commutative algebra doesn't have to be symmetric. I'll think about this later. In the meantime, don't crash about it. Postscript (a month later): left-multiplication and right-multiplication are the same in the EJA, but not necessarily for the matrices that represent them. It was wrong to conflate the two concepts in the first place. --- mjo/eja/euclidean_jordan_algebra.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index a1b28a2..849243c 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -27,10 +27,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): b.set_immutable() if not (is_Matrix(b) and b.dimensions() == (n, n)): raise ValueError("input is not a multiplication table") - if not (b.is_symmetric()): - # Euclidean jordan algebras are commutative, so left/right - # multiplication is the same. - raise ValueError("multiplication table must be symmetric") mult_table = tuple(mult_table) cat = MagmaticAlgebras(field).FiniteDimensional().WithBasis() -- 2.44.2 From 1b0e0106353a364008d0dc0bdeea7b1a91eeb016 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 24 Jun 2019 23:10:37 -0400 Subject: [PATCH 02/16] eja: fix the rank of the spin factor algebra. --- mjo/eja/euclidean_jordan_algebra.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 849243c..1f03768 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -317,4 +317,8 @@ def eja_ln(dimension, field=QQ): Qi[0,0] = Qi[0,0] * ~field(2) Qs.append(Qi) - return FiniteDimensionalEuclideanJordanAlgebra(field,Qs,rank=2) + # The rank of the spin factor algebra is two, UNLESS we're in a + # one-dimensional ambient space (the rank is bounded by the + # ambient dimension). + rank = min(dimension,2) + return FiniteDimensionalEuclideanJordanAlgebra(field,Qs,rank=rank) -- 2.44.2 From 556690d808d614f2c271dc431dd909e353530594 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 24 Jun 2019 23:11:10 -0400 Subject: [PATCH 03/16] eja: use the associativity of one-generator subalgebras. --- mjo/eja/euclidean_jordan_algebra.py | 32 ++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 1f03768..bb46019 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -85,6 +85,10 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): also the left multiplication matrix and must be symmetric:: sage: set_random_seed() + sage: n = ZZ.random_element(1,10).abs() + sage: J = eja_rn(5) + sage: J.random_element().matrix().is_symmetric() + True sage: J = eja_ln(5) sage: J.random_element().matrix().is_symmetric() True @@ -151,7 +155,22 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): def subalgebra_generated_by(self): """ - Return the subalgebra of the parent EJA generated by this element. + Return the associative subalgebra of the parent EJA generated + by this element. + + TESTS:: + + sage: set_random_seed() + sage: n = ZZ.random_element(1,10).abs() + sage: J = eja_rn(n) + sage: x = J.random_element() + sage: x.subalgebra_generated_by().is_associative() + True + sage: J = eja_ln(n) + sage: x = J.random_element() + sage: x.subalgebra_generated_by().is_associative() + True + """ # First get the subspace spanned by the powers of myself... V = self.span_of_powers() @@ -178,7 +197,9 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): b_right_matrix = matrix(F, b_right_rows) mats.append(b_right_matrix) - return FiniteDimensionalEuclideanJordanAlgebra(F, mats) + # It's an algebra of polynomials in one element, and EJAs + # are power-associative. + return FiniteDimensionalEuclideanJordanAlgebra(F, mats, assume_associative=True) def minimal_polynomial(self): @@ -221,13 +242,18 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): True """ + if self.parent().is_associative(): + return self.matrix().minimal_polynomial() + V = self.span_of_powers() assoc_subalg = self.subalgebra_generated_by() # Mis-design warning: the basis used for span_of_powers() # and subalgebra_generated_by() must be the same, and in # the same order! subalg_self = assoc_subalg(V.coordinates(self.vector())) - return subalg_self.matrix().minimal_polynomial() + # Recursive call, but should work since the subalgebra is + # associative. + return subalg_self.minimal_polynomial() def characteristic_polynomial(self): -- 2.44.2 From 0dc6a110a16f63240e7817fc7529996e885973c8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 25 Jun 2019 17:13:41 -0400 Subject: [PATCH 04/16] eja: recurse more directly in minimal_polynomial(). --- mjo/eja/euclidean_jordan_algebra.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index bb46019..8f623b4 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -242,18 +242,25 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): True """ - if self.parent().is_associative(): - return self.matrix().minimal_polynomial() + # The element we're going to call "minimal_polynomial()" on. + # Either myself, interpreted as an element of a finite- + # dimensional algebra, or an element of an associative + # subalgebra. + elt = None - V = self.span_of_powers() - assoc_subalg = self.subalgebra_generated_by() - # Mis-design warning: the basis used for span_of_powers() - # and subalgebra_generated_by() must be the same, and in - # the same order! - subalg_self = assoc_subalg(V.coordinates(self.vector())) - # Recursive call, but should work since the subalgebra is - # associative. - return subalg_self.minimal_polynomial() + if self.parent().is_associative(): + elt = FiniteDimensionalAlgebraElement(self.parent(), self) + else: + V = self.span_of_powers() + assoc_subalg = self.subalgebra_generated_by() + # Mis-design warning: the basis used for span_of_powers() + # and subalgebra_generated_by() must be the same, and in + # the same order! + elt = assoc_subalg(V.coordinates(self.vector())) + + # Recursive call, but should work since elt lives in an + # associative algebra. + return elt.minimal_polynomial() def characteristic_polynomial(self): -- 2.44.2 From 6b8e20c25e2dcdf4790a53664223fdce9c8416e9 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 25 Jun 2019 17:14:11 -0400 Subject: [PATCH 05/16] eja: add is_nilpotent() for elements. --- mjo/eja/euclidean_jordan_algebra.py | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 8f623b4..603ef29 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -263,6 +263,61 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return elt.minimal_polynomial() + def is_nilpotent(self): + """ + Return whether or not some power of this element is zero. + + The superclass method won't work unless we're in an + associative algebra, and we aren't. However, we generate + an assocoative subalgebra and we're nilpotent there if and + only if we're nilpotent here (probably). + + TESTS: + + The identity element is never nilpotent:: + + sage: set_random_seed() + sage: n = ZZ.random_element(2,10).abs() + sage: J = eja_rn(n) + sage: J.one().is_nilpotent() + False + sage: J = eja_ln(n) + sage: J.one().is_nilpotent() + False + + The additive identity is always nilpotent:: + + sage: set_random_seed() + sage: n = ZZ.random_element(2,10).abs() + sage: J = eja_rn(n) + sage: J.zero().is_nilpotent() + True + sage: J = eja_ln(n) + sage: J.zero().is_nilpotent() + True + + """ + # The element we're going to call "is_nilpotent()" on. + # Either myself, interpreted as an element of a finite- + # dimensional algebra, or an element of an associative + # subalgebra. + elt = None + + if self.parent().is_associative(): + elt = FiniteDimensionalAlgebraElement(self.parent(), self) + else: + V = self.span_of_powers() + assoc_subalg = self.subalgebra_generated_by() + # Mis-design warning: the basis used for span_of_powers() + # and subalgebra_generated_by() must be the same, and in + # the same order! + elt = assoc_subalg(V.coordinates(self.vector())) + + # Recursive call, but should work since elt lives in an + # associative algebra. + return elt.is_nilpotent() + + def characteristic_polynomial(self): return self.matrix().characteristic_polynomial() -- 2.44.2 From 1464a12b77a4dad5b96e91a2ab8168a047ed13cb Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 25 Jun 2019 19:14:51 -0400 Subject: [PATCH 06/16] eja: use different generator names in subalgebras. --- mjo/eja/euclidean_jordan_algebra.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 603ef29..28e2a0b 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -199,7 +199,9 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): # It's an algebra of polynomials in one element, and EJAs # are power-associative. - return FiniteDimensionalEuclideanJordanAlgebra(F, mats, assume_associative=True) + # + # TODO: choose generator names intelligently. + return FiniteDimensionalEuclideanJordanAlgebra(F, mats, assume_associative=True, names='f') def minimal_polynomial(self): -- 2.44.2 From b479f3bb0d3aae8c598a6ec6459688c4be3202af Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 25 Jun 2019 19:17:31 -0400 Subject: [PATCH 07/16] eja: add currently-busted subalgebra_idempotent() method. --- mjo/eja/euclidean_jordan_algebra.py | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 28e2a0b..2ec45cf 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -320,6 +320,57 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return elt.is_nilpotent() + def subalgebra_idempotent(self): + """ + Find an idempotent in the associative subalgebra I generate + using Proposition 2.3.5 in Baes. + """ + if self.is_nilpotent(): + raise ValueError("this only works with non-nilpotent elements!") + + V = self.span_of_powers() + J = self.subalgebra_generated_by() + # Mis-design warning: the basis used for span_of_powers() + # and subalgebra_generated_by() must be the same, and in + # the same order! + u = J(V.coordinates(self.vector())) + + # The image of the matrix of left-u^m-multiplication + # will be minimal for some natural number s... + s = 0 + minimal_dim = V.dimension() + for i in xrange(1, V.dimension()): + this_dim = (u**i).matrix().image().dimension() + if this_dim < minimal_dim: + minimal_dim = this_dim + s = i + + # Now minimal_matrix should correspond to the smallest + # non-zero subspace in Baes's (or really, Koecher's) + # proposition. + # + # However, we need to restrict the matrix to work on the + # subspace... or do we? Can't we just solve, knowing that + # A(c) = u^(s+1) should have a solution in the big space, + # too? + u_next = u**(s+1) + A = u_next.matrix() + c_coordinates = A.solve_right(u_next.vector()) + + # Now c_coordinates is the idempotent we want, but it's in + # the coordinate system of the subalgebra. + # + # We need the basis for J, but as elements of the parent algebra. + # + # + # TODO: this is buggy, but it's probably because the + # multiplication table for the subalgebra is wrong! The + # matrices should be symmetric I bet. + basis = [self.parent(v) for v in V.basis()] + return self.parent().linear_combination(zip(c_coordinates, basis)) + + + def characteristic_polynomial(self): return self.matrix().characteristic_polynomial() -- 2.44.2 From 18fc5a9d41f3e17636502491edf85c1835c33f6b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 25 Jun 2019 21:04:18 -0400 Subject: [PATCH 08/16] eja: add doctest for a bug in subalgebra_generated_by(). --- mjo/eja/euclidean_jordan_algebra.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 2ec45cf..a4e2ad0 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -171,6 +171,16 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: x.subalgebra_generated_by().is_associative() True + This is buggy right now:: + + sage: J = eja_ln(5) + sage: x = J.random_element() + sage: x.matrix()*x.vector() == (x**2).vector() # works + True + sage: u = x.subalgebra_generated_by().random_element() + sage: u.matrix()*u.vector() == (u**2).vector() # busted + True + """ # First get the subspace spanned by the powers of myself... V = self.span_of_powers() -- 2.44.2 From 64ea775e89b485025775bdf11cc01318e2df37a4 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 26 Jun 2019 10:56:03 -0400 Subject: [PATCH 09/16] eja: fix element powers. We were using row-vector multiplication for powers (taken from the superclass), but our vectors are column vectors. Oops. This broke things when we assumed column vectors were being used, like when we constructed a multiplication table. This commit fixes the powers and adds/updates some tests. --- mjo/eja/euclidean_jordan_algebra.py | 34 +++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index a4e2ad0..ef5249b 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -101,6 +101,21 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): Jordan algebras are always power-associative; see for example Faraut and Koranyi, Proposition II.1.2 (ii). + + .. WARNING: + + We have to override this because our superclass uses row vectors + instead of column vectors! We, on the other hand, assume column + vectors everywhere. + + EXAMPLES: + + sage: set_random_seed() + sage: J = eja_ln(5) + sage: x = J.random_element() + sage: x.matrix()*x.vector() == (x**2).vector() + True + """ A = self.parent() if n == 0: @@ -108,7 +123,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): elif n == 1: return self else: - return A.element_class(A, self.vector()*(self.matrix()**(n-1))) + return A.element_class(A, (self.matrix()**(n-1))*self.vector()) def span_of_powers(self): @@ -171,14 +186,13 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: x.subalgebra_generated_by().is_associative() True - This is buggy right now:: + Squaring in the subalgebra should be the same thing as + squaring in the superalgebra:: sage: J = eja_ln(5) sage: x = J.random_element() - sage: x.matrix()*x.vector() == (x**2).vector() # works - True sage: u = x.subalgebra_generated_by().random_element() - sage: u.matrix()*u.vector() == (u**2).vector() # busted + sage: u.matrix()*u.vector() == (u**2).vector() True """ @@ -197,6 +211,9 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): # b1 is what we get if we apply that matrix to b1. The # second row of the right multiplication matrix by b1 # is what we get when we apply that matrix to b2... + # + # IMPORTANT: this assumes that all vectors are COLUMN + # vectors, unlike our superclass (which uses row vectors). for b_left in V.basis(): eja_b_left = self.parent()(b_left) # Multiply in the original EJA, but then get the @@ -363,6 +380,9 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): # subspace... or do we? Can't we just solve, knowing that # A(c) = u^(s+1) should have a solution in the big space, # too? + # + # Beware, solve_right() means that we're using COLUMN vectors. + # Our FiniteDimensionalAlgebraElement superclass uses rows. u_next = u**(s+1) A = u_next.matrix() c_coordinates = A.solve_right(u_next.vector()) @@ -372,10 +392,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): # # We need the basis for J, but as elements of the parent algebra. # - # - # TODO: this is buggy, but it's probably because the - # multiplication table for the subalgebra is wrong! The - # matrices should be symmetric I bet. basis = [self.parent(v) for v in V.basis()] return self.parent().linear_combination(zip(c_coordinates, basis)) -- 2.44.2 From 5fcc3b1bdec67eec2d76cc39c79a25af00830e30 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 26 Jun 2019 11:17:40 -0400 Subject: [PATCH 10/16] eja: fix element matrices. The superclass matrix() method of elements sometimes computes the right-matrix acting on row vectors. Nobody wants that shit. This commit overrides it (to simply return the transpose of the superclass matrix), and thus fixes the subalgebra_idempotent() method. Some tests were added for the latter method, too. --- mjo/eja/euclidean_jordan_algebra.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index ef5249b..835f763 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -168,6 +168,19 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return self.span_of_powers().dimension() + def matrix(self): + """ + Return the matrix that represents left- (or right-) + multiplication by this element in the parent algebra. + + We have to override this because the superclass method + returns a matrix that acts on row vectors (that is, on + the right). + """ + fda_elt = FiniteDimensionalAlgebraElement(self.parent(), self) + return fda_elt.matrix().transpose() + + def subalgebra_generated_by(self): """ Return the associative subalgebra of the parent EJA generated @@ -351,6 +364,19 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): """ Find an idempotent in the associative subalgebra I generate using Proposition 2.3.5 in Baes. + + TESTS:: + + sage: set_random_seed() + sage: J = eja_rn(5) + sage: c = J.random_element().subalgebra_idempotent() + sage: c^2 == c + True + sage: J = eja_ln(5) + sage: c = J.random_element().subalgebra_idempotent() + sage: c^2 == c + True + """ if self.is_nilpotent(): raise ValueError("this only works with non-nilpotent elements!") -- 2.44.2 From 9dfbf47227bdc9a7467e37e04173105fb3b2392b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 29 Jun 2019 10:07:19 -0400 Subject: [PATCH 11/16] eja: add is_regular() method on elements. --- mjo/eja/euclidean_jordan_algebra.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 835f763..60a7ba1 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -126,6 +126,30 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return A.element_class(A, (self.matrix()**(n-1))*self.vector()) + def is_regular(self): + """ + Return whether or not this is a regular element. + + EXAMPLES: + + The identity element always has degree one, but any element + linearly-independent from it is regular:: + + sage: J = eja_ln(5) + sage: J.one().is_regular() + False + sage: e0, e1, e2, e3, e4 = J.gens() # e0 is the identity + sage: for x in J.gens(): + ....: (J.one() + x).is_regular() + False + True + True + True + True + + """ + return self.degree() == self.parent().rank() + def span_of_powers(self): """ Return the vector space spanned by successive powers of -- 2.44.2 From a09a7e14df9b7dcae39fe558d42a6d74fb1c52b0 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 29 Jun 2019 10:08:56 -0400 Subject: [PATCH 12/16] eja: put element methods in alphabetical order. --- mjo/eja/euclidean_jordan_algebra.py | 233 ++++++++++++++-------------- 1 file changed, 117 insertions(+), 116 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 60a7ba1..1281a02 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -126,6 +126,65 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return A.element_class(A, (self.matrix()**(n-1))*self.vector()) + def characteristic_polynomial(self): + return self.matrix().characteristic_polynomial() + + + def is_nilpotent(self): + """ + Return whether or not some power of this element is zero. + + The superclass method won't work unless we're in an + associative algebra, and we aren't. However, we generate + an assocoative subalgebra and we're nilpotent there if and + only if we're nilpotent here (probably). + + TESTS: + + The identity element is never nilpotent:: + + sage: set_random_seed() + sage: n = ZZ.random_element(2,10).abs() + sage: J = eja_rn(n) + sage: J.one().is_nilpotent() + False + sage: J = eja_ln(n) + sage: J.one().is_nilpotent() + False + + The additive identity is always nilpotent:: + + sage: set_random_seed() + sage: n = ZZ.random_element(2,10).abs() + sage: J = eja_rn(n) + sage: J.zero().is_nilpotent() + True + sage: J = eja_ln(n) + sage: J.zero().is_nilpotent() + True + + """ + # The element we're going to call "is_nilpotent()" on. + # Either myself, interpreted as an element of a finite- + # dimensional algebra, or an element of an associative + # subalgebra. + elt = None + + if self.parent().is_associative(): + elt = FiniteDimensionalAlgebraElement(self.parent(), self) + else: + V = self.span_of_powers() + assoc_subalg = self.subalgebra_generated_by() + # Mis-design warning: the basis used for span_of_powers() + # and subalgebra_generated_by() must be the same, and in + # the same order! + elt = assoc_subalg(V.coordinates(self.vector())) + + # Recursive call, but should work since elt lives in an + # associative algebra. + return elt.is_nilpotent() + + def is_regular(self): """ Return whether or not this is a regular element. @@ -150,17 +209,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): """ return self.degree() == self.parent().rank() - def span_of_powers(self): - """ - Return the vector space spanned by successive powers of - this element. - """ - # The dimension of the subalgebra can't be greater than - # the big algebra, so just put everything into a list - # and let span() get rid of the excess. - V = self.vector().parent() - return V.span( (self**d).vector() for d in xrange(V.dimension()) ) - def degree(self): """ @@ -205,69 +253,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return fda_elt.matrix().transpose() - def subalgebra_generated_by(self): - """ - Return the associative subalgebra of the parent EJA generated - by this element. - - TESTS:: - - sage: set_random_seed() - sage: n = ZZ.random_element(1,10).abs() - sage: J = eja_rn(n) - sage: x = J.random_element() - sage: x.subalgebra_generated_by().is_associative() - True - sage: J = eja_ln(n) - sage: x = J.random_element() - sage: x.subalgebra_generated_by().is_associative() - True - - Squaring in the subalgebra should be the same thing as - squaring in the superalgebra:: - - sage: J = eja_ln(5) - sage: x = J.random_element() - sage: u = x.subalgebra_generated_by().random_element() - sage: u.matrix()*u.vector() == (u**2).vector() - True - - """ - # First get the subspace spanned by the powers of myself... - V = self.span_of_powers() - F = self.base_ring() - - # Now figure out the entries of the right-multiplication - # matrix for the successive basis elements b0, b1,... of - # that subspace. - mats = [] - for b_right in V.basis(): - eja_b_right = self.parent()(b_right) - b_right_rows = [] - # The first row of the right-multiplication matrix by - # b1 is what we get if we apply that matrix to b1. The - # second row of the right multiplication matrix by b1 - # is what we get when we apply that matrix to b2... - # - # IMPORTANT: this assumes that all vectors are COLUMN - # vectors, unlike our superclass (which uses row vectors). - for b_left in V.basis(): - eja_b_left = self.parent()(b_left) - # Multiply in the original EJA, but then get the - # coordinates from the subalgebra in terms of its - # basis. - this_row = V.coordinates((eja_b_left*eja_b_right).vector()) - b_right_rows.append(this_row) - b_right_matrix = matrix(F, b_right_rows) - mats.append(b_right_matrix) - - # It's an algebra of polynomials in one element, and EJAs - # are power-associative. - # - # TODO: choose generator names intelligently. - return FiniteDimensionalEuclideanJordanAlgebra(F, mats, assume_associative=True, names='f') - - def minimal_polynomial(self): """ EXAMPLES:: @@ -329,59 +314,79 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return elt.minimal_polynomial() - def is_nilpotent(self): + def span_of_powers(self): """ - Return whether or not some power of this element is zero. + Return the vector space spanned by successive powers of + this element. + """ + # The dimension of the subalgebra can't be greater than + # the big algebra, so just put everything into a list + # and let span() get rid of the excess. + V = self.vector().parent() + return V.span( (self**d).vector() for d in xrange(V.dimension()) ) - The superclass method won't work unless we're in an - associative algebra, and we aren't. However, we generate - an assocoative subalgebra and we're nilpotent there if and - only if we're nilpotent here (probably). - TESTS: + def subalgebra_generated_by(self): + """ + Return the associative subalgebra of the parent EJA generated + by this element. - The identity element is never nilpotent:: + TESTS:: sage: set_random_seed() - sage: n = ZZ.random_element(2,10).abs() + sage: n = ZZ.random_element(1,10).abs() sage: J = eja_rn(n) - sage: J.one().is_nilpotent() - False + sage: x = J.random_element() + sage: x.subalgebra_generated_by().is_associative() + True sage: J = eja_ln(n) - sage: J.one().is_nilpotent() - False + sage: x = J.random_element() + sage: x.subalgebra_generated_by().is_associative() + True - The additive identity is always nilpotent:: + Squaring in the subalgebra should be the same thing as + squaring in the superalgebra:: - sage: set_random_seed() - sage: n = ZZ.random_element(2,10).abs() - sage: J = eja_rn(n) - sage: J.zero().is_nilpotent() - True - sage: J = eja_ln(n) - sage: J.zero().is_nilpotent() + sage: J = eja_ln(5) + sage: x = J.random_element() + sage: u = x.subalgebra_generated_by().random_element() + sage: u.matrix()*u.vector() == (u**2).vector() True """ - # The element we're going to call "is_nilpotent()" on. - # Either myself, interpreted as an element of a finite- - # dimensional algebra, or an element of an associative - # subalgebra. - elt = None + # First get the subspace spanned by the powers of myself... + V = self.span_of_powers() + F = self.base_ring() - if self.parent().is_associative(): - elt = FiniteDimensionalAlgebraElement(self.parent(), self) - else: - V = self.span_of_powers() - assoc_subalg = self.subalgebra_generated_by() - # Mis-design warning: the basis used for span_of_powers() - # and subalgebra_generated_by() must be the same, and in - # the same order! - elt = assoc_subalg(V.coordinates(self.vector())) + # Now figure out the entries of the right-multiplication + # matrix for the successive basis elements b0, b1,... of + # that subspace. + mats = [] + for b_right in V.basis(): + eja_b_right = self.parent()(b_right) + b_right_rows = [] + # The first row of the right-multiplication matrix by + # b1 is what we get if we apply that matrix to b1. The + # second row of the right multiplication matrix by b1 + # is what we get when we apply that matrix to b2... + # + # IMPORTANT: this assumes that all vectors are COLUMN + # vectors, unlike our superclass (which uses row vectors). + for b_left in V.basis(): + eja_b_left = self.parent()(b_left) + # Multiply in the original EJA, but then get the + # coordinates from the subalgebra in terms of its + # basis. + this_row = V.coordinates((eja_b_left*eja_b_right).vector()) + b_right_rows.append(this_row) + b_right_matrix = matrix(F, b_right_rows) + mats.append(b_right_matrix) - # Recursive call, but should work since elt lives in an - # associative algebra. - return elt.is_nilpotent() + # It's an algebra of polynomials in one element, and EJAs + # are power-associative. + # + # TODO: choose generator names intelligently. + return FiniteDimensionalEuclideanJordanAlgebra(F, mats, assume_associative=True, names='f') def subalgebra_idempotent(self): @@ -447,10 +452,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): - def characteristic_polynomial(self): - return self.matrix().characteristic_polynomial() - - def eja_rn(dimension, field=QQ): """ Return the Euclidean Jordan Algebra corresponding to the set -- 2.44.2 From 79dcbc10c34380e5a1404037d0ab5e7aa36a82a1 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 29 Jun 2019 10:18:32 -0400 Subject: [PATCH 13/16] eja: de-implement characteristic_polynomial for irregular elements. --- mjo/eja/euclidean_jordan_algebra.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 1281a02..a55b7e3 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -127,7 +127,18 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): def characteristic_polynomial(self): - return self.matrix().characteristic_polynomial() + """ + Return my characteristic polynomial (if I'm a regular + element). + + Eventually this should be implemented in terms of the parent + algebra's characteristic polynomial that works for ALL + elements. + """ + if self.is_regular(): + return self.minimal_polynomial() + else: + return NotImplementedError('irregular element') def is_nilpotent(self): -- 2.44.2 From 59177e7be6376f64fe24061d576a9fde77588d57 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 29 Jun 2019 13:26:13 -0400 Subject: [PATCH 14/16] eja: add det() and trace() for regular elements. --- mjo/eja/euclidean_jordan_algebra.py | 47 ++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index a55b7e3..2404af0 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -138,7 +138,33 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): if self.is_regular(): return self.minimal_polynomial() else: - return NotImplementedError('irregular element') + raise NotImplementedError('irregular element') + + + def det(self): + """ + Return my determinant, the product of my eigenvalues. + + EXAMPLES:: + + sage: J = eja_ln(2) + sage: e0,e1 = J.gens() + sage: x = e0 + e1 + sage: x.det() + 0 + sage: J = eja_ln(3) + sage: e0,e1,e2 = J.gens() + sage: x = e0 + e1 + e2 + sage: x.det() + -1 + + """ + cs = self.characteristic_polynomial().coefficients(sparse=False) + r = len(cs) - 1 + if r >= 0: + return cs[0] * (-1)**r + else: + raise ValueError('charpoly had no coefficients') def is_nilpotent(self): @@ -462,6 +488,25 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return self.parent().linear_combination(zip(c_coordinates, basis)) + def trace(self): + """ + Return my trace, the sum of my eigenvalues. + + EXAMPLES:: + + sage: J = eja_ln(3) + sage: e0,e1,e2 = J.gens() + sage: x = e0 + e1 + e2 + sage: x.trace() + 2 + + """ + cs = self.characteristic_polynomial().coefficients(sparse=False) + if len(cs) >= 2: + return -1*cs[-2] + else: + raise ValueError('charpoly had fewer than 2 coefficients') + def eja_rn(dimension, field=QQ): """ -- 2.44.2 From 78eb37d0cec0870b70171688cc8a30a433606e71 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 3 Jul 2019 19:36:13 -0400 Subject: [PATCH 15/16] eja: add the simple algebra S^n. --- mjo/eja/euclidean_jordan_algebra.py | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index 2404af0..f71f75d 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -596,3 +596,61 @@ def eja_ln(dimension, field=QQ): # ambient dimension). rank = min(dimension,2) return FiniteDimensionalEuclideanJordanAlgebra(field,Qs,rank=rank) + + +def eja_sn(dimension, field=QQ): + """ + Return the simple Jordan algebra of ``dimension``-by-``dimension`` + symmetric matrices over ``field``. + + EXAMPLES:: + + sage: J = eja_sn(2) + sage: e0, e1, e2 = J.gens() + sage: e0*e0 + e0 + sage: e1*e1 + e0 + e2 + sage: e2*e2 + e2 + + """ + Qs = [] + + # In S^2, for example, we nominally have four coordinates even + # though the space is of dimension three only. The vector space V + # is supposed to hold the entire long vector, and the subspace W + # of V will be spanned by the vectors that arise from symmetric + # matrices. Thus for S^2, dim(V) == 4 and dim(W) == 3. + V = VectorSpace(field, dimension**2) + + # The basis of symmetric matrices, as matrices, in their R^(n-by-n) + # coordinates. + S = [] + + for i in xrange(dimension): + for j in xrange(i+1): + Eij = matrix(field, dimension, lambda k,l: k==i and l==j) + if i == j: + Sij = Eij + else: + Sij = Eij + Eij.transpose() + S.append(Sij) + + def mat2vec(m): + return vector(field, m.list()) + + W = V.span( mat2vec(s) for s in S ) + + for s in S: + # Brute force the right-multiplication-by-s matrix by looping + # through all elements of the basis and doing the computation + # to find out what the corresponding row should be. + Q_rows = [] + for t in S: + this_row = mat2vec((s*t + t*s)/2) + Q_rows.append(W.coordinates(this_row)) + Q = matrix(field,Q_rows) + Qs.append(Q) + + return FiniteDimensionalEuclideanJordanAlgebra(field,Qs,rank=dimension) -- 2.44.2 From eb48c4d6ce3591d116c85b3f4ab9d1ebb1095367 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 3 Jul 2019 19:47:23 -0400 Subject: [PATCH 16/16] eja: add a comment about row/column vectors to eja_sn(). --- mjo/eja/euclidean_jordan_algebra.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index f71f75d..c47f400 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -643,9 +643,13 @@ def eja_sn(dimension, field=QQ): W = V.span( mat2vec(s) for s in S ) for s in S: - # Brute force the right-multiplication-by-s matrix by looping + # Brute force the multiplication-by-s matrix by looping # through all elements of the basis and doing the computation - # to find out what the corresponding row should be. + # to find out what the corresponding row should be. BEWARE: + # these multiplication tables won't be symmetric! It therefore + # becomes REALLY IMPORTANT that the underlying algebra + # constructor uses ROW vectors and not COLUMN vectors. That's + # why we're computing rows here and not columns. Q_rows = [] for t in S: this_row = mat2vec((s*t + t*s)/2) -- 2.44.2