2 Euclidean Jordan Algebras. These are formally-real Jordan Algebras;
3 specifically those where u^2 + v^2 = 0 implies that u = v = 0. They
4 are used in optimization, and have some additional nice methods beyond
5 what can be supported in a general Jordan Algebra.
8 from sage
.categories
.magmatic_algebras
import MagmaticAlgebras
9 from sage
.structure
.element
import is_Matrix
10 from sage
.structure
.category_object
import normalize_names
12 from sage
.algebras
.finite_dimensional_algebras
.finite_dimensional_algebra
import FiniteDimensionalAlgebra
13 from sage
.algebras
.finite_dimensional_algebras
.finite_dimensional_algebra_element
import FiniteDimensionalAlgebraElement
15 class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra
):
17 def __classcall_private__(cls
,
21 assume_associative
=False,
27 mult_table
= [b
.base_extend(field
) for b
in mult_table
]
30 if not (is_Matrix(b
) and b
.dimensions() == (n
, n
)):
31 raise ValueError("input is not a multiplication table")
32 mult_table
= tuple(mult_table
)
34 cat
= MagmaticAlgebras(field
).FiniteDimensional().WithBasis()
35 cat
.or_subcategory(category
)
36 if assume_associative
:
37 cat
= cat
.Associative()
39 names
= normalize_names(n
, names
)
41 fda
= super(FiniteDimensionalEuclideanJordanAlgebra
, cls
)
42 return fda
.__classcall
__(cls
,
45 assume_associative
=assume_associative
,
49 natural_basis
=natural_basis
,
50 inner_product
=inner_product
)
53 def __init__(self
, field
,
56 assume_associative
=False,
64 By definition, Jordan multiplication commutes::
66 sage: set_random_seed()
67 sage: J = random_eja()
68 sage: x = J.random_element()
69 sage: y = J.random_element()
75 self
._natural
_basis
= natural_basis
76 self
._inner
_product
= inner_product
77 fda
= super(FiniteDimensionalEuclideanJordanAlgebra
, self
)
86 Return a string representation of ``self``.
88 fmt
= "Euclidean Jordan algebra of degree {} over {}"
89 return fmt
.format(self
.degree(), self
.base_ring())
92 def inner_product(self
, x
, y
):
94 The inner product associated with this Euclidean Jordan algebra.
96 Will default to the trace inner product if nothing else.
100 The inner product must satisfy its axiom for this algebra to truly
101 be a Euclidean Jordan Algebra::
103 sage: set_random_seed()
104 sage: J = random_eja()
105 sage: x = J.random_element()
106 sage: y = J.random_element()
107 sage: z = J.random_element()
108 sage: (x*y).inner_product(z) == y.inner_product(x*z)
112 if (not x
in self
) or (not y
in self
):
113 raise TypeError("arguments must live in this algebra")
114 if self
._inner
_product
is None:
115 return x
.trace_inner_product(y
)
117 return self
._inner
_product
(x
,y
)
120 def natural_basis(self
):
122 Return a more-natural representation of this algebra's basis.
124 Every finite-dimensional Euclidean Jordan Algebra is a direct
125 sum of five simple algebras, four of which comprise Hermitian
126 matrices. This method returns the original "natural" basis
127 for our underlying vector space. (Typically, the natural basis
128 is used to construct the multiplication table in the first place.)
130 Note that this will always return a matrix. The standard basis
131 in `R^n` will be returned as `n`-by-`1` column matrices.
135 sage: J = RealSymmetricSimpleEJA(2)
138 sage: J.natural_basis()
146 sage: J = JordanSpinSimpleEJA(2)
149 sage: J.natural_basis()
156 if self
._natural
_basis
is None:
157 return tuple( b
.vector().column() for b
in self
.basis() )
159 return self
._natural
_basis
164 Return the rank of this EJA.
166 if self
._rank
is None:
167 raise ValueError("no rank specified at genesis")
172 class Element(FiniteDimensionalAlgebraElement
):
174 An element of a Euclidean Jordan algebra.
177 def __init__(self
, A
, elt
=None):
181 The identity in `S^n` is converted to the identity in the EJA::
183 sage: J = RealSymmetricSimpleEJA(3)
184 sage: I = identity_matrix(QQ,3)
185 sage: J(I) == J.one()
188 This skew-symmetric matrix can't be represented in the EJA::
190 sage: J = RealSymmetricSimpleEJA(3)
191 sage: A = matrix(QQ,3, lambda i,j: i-j)
193 Traceback (most recent call last):
195 ArithmeticError: vector is not in free module
198 # Goal: if we're given a matrix, and if it lives in our
199 # parent algebra's "natural ambient space," convert it
200 # into an algebra element.
202 # The catch is, we make a recursive call after converting
203 # the given matrix into a vector that lives in the algebra.
204 # This we need to try the parent class initializer first,
205 # to avoid recursing forever if we're given something that
206 # already fits into the algebra, but also happens to live
207 # in the parent's "natural ambient space" (this happens with
210 FiniteDimensionalAlgebraElement
.__init
__(self
, A
, elt
)
212 natural_basis
= A
.natural_basis()
213 if elt
in natural_basis
[0].matrix_space():
214 # Thanks for nothing! Matrix spaces aren't vector
215 # spaces in Sage, so we have to figure out its
216 # natural-basis coordinates ourselves.
217 V
= VectorSpace(elt
.base_ring(), elt
.nrows()**2)
218 W
= V
.span( _mat2vec(s
) for s
in natural_basis
)
219 coords
= W
.coordinates(_mat2vec(elt
))
220 FiniteDimensionalAlgebraElement
.__init
__(self
, A
, coords
)
222 def __pow__(self
, n
):
224 Return ``self`` raised to the power ``n``.
226 Jordan algebras are always power-associative; see for
227 example Faraut and Koranyi, Proposition II.1.2 (ii).
231 We have to override this because our superclass uses row vectors
232 instead of column vectors! We, on the other hand, assume column
237 sage: set_random_seed()
238 sage: x = random_eja().random_element()
239 sage: x.operator_matrix()*x.vector() == (x^2).vector()
242 A few examples of power-associativity::
244 sage: set_random_seed()
245 sage: x = random_eja().random_element()
246 sage: x*(x*x)*(x*x) == x^5
248 sage: (x*x)*(x*x*x) == x^5
251 We also know that powers operator-commute (Koecher, Chapter
254 sage: set_random_seed()
255 sage: x = random_eja().random_element()
256 sage: m = ZZ.random_element(0,10)
257 sage: n = ZZ.random_element(0,10)
258 sage: Lxm = (x^m).operator_matrix()
259 sage: Lxn = (x^n).operator_matrix()
260 sage: Lxm*Lxn == Lxn*Lxm
270 return A( (self
.operator_matrix()**(n
-1))*self
.vector() )
273 def characteristic_polynomial(self
):
275 Return my characteristic polynomial (if I'm a regular
278 Eventually this should be implemented in terms of the parent
279 algebra's characteristic polynomial that works for ALL
282 if self
.is_regular():
283 return self
.minimal_polynomial()
285 raise NotImplementedError('irregular element')
288 def inner_product(self
, other
):
290 Return the parent algebra's inner product of myself and ``other``.
294 The inner product in the Jordan spin algebra is the usual
295 inner product on `R^n` (this example only works because the
296 basis for the Jordan algebra is the standard basis in `R^n`)::
298 sage: J = JordanSpinSimpleEJA(3)
299 sage: x = vector(QQ,[1,2,3])
300 sage: y = vector(QQ,[4,5,6])
301 sage: x.inner_product(y)
303 sage: J(x).inner_product(J(y))
306 The inner product on `S^n` is `<X,Y> = trace(X*Y)`, where
307 multiplication is the usual matrix multiplication in `S^n`,
308 so the inner product of the identity matrix with itself
311 sage: J = RealSymmetricSimpleEJA(3)
312 sage: J.one().inner_product(J.one())
315 Likewise, the inner product on `C^n` is `<X,Y> =
316 Re(trace(X*Y))`, where we must necessarily take the real
317 part because the product of Hermitian matrices may not be
320 sage: J = ComplexHermitianSimpleEJA(3)
321 sage: J.one().inner_product(J.one())
324 Ditto for the quaternions::
326 sage: J = QuaternionHermitianSimpleEJA(3)
327 sage: J.one().inner_product(J.one())
332 Ensure that we can always compute an inner product, and that
333 it gives us back a real number::
335 sage: set_random_seed()
336 sage: J = random_eja()
337 sage: x = J.random_element()
338 sage: y = J.random_element()
339 sage: x.inner_product(y) in RR
345 raise TypeError("'other' must live in the same algebra")
347 return P
.inner_product(self
, other
)
350 def operator_commutes_with(self
, other
):
352 Return whether or not this element operator-commutes
357 The definition of a Jordan algebra says that any element
358 operator-commutes with its square::
360 sage: set_random_seed()
361 sage: x = random_eja().random_element()
362 sage: x.operator_commutes_with(x^2)
367 Test Lemma 1 from Chapter III of Koecher::
369 sage: set_random_seed()
370 sage: J = random_eja()
371 sage: u = J.random_element()
372 sage: v = J.random_element()
373 sage: lhs = u.operator_commutes_with(u*v)
374 sage: rhs = v.operator_commutes_with(u^2)
379 if not other
in self
.parent():
380 raise TypeError("'other' must live in the same algebra")
382 A
= self
.operator_matrix()
383 B
= other
.operator_matrix()
389 Return my determinant, the product of my eigenvalues.
393 sage: J = JordanSpinSimpleEJA(2)
394 sage: e0,e1 = J.gens()
398 sage: J = JordanSpinSimpleEJA(3)
399 sage: e0,e1,e2 = J.gens()
400 sage: x = e0 + e1 + e2
405 cs
= self
.characteristic_polynomial().coefficients(sparse
=False)
408 return cs
[0] * (-1)**r
410 raise ValueError('charpoly had no coefficients')
415 Return the Jordan-multiplicative inverse of this element.
417 We can't use the superclass method because it relies on the
418 algebra being associative.
422 The inverse in the spin factor algebra is given in Alizadeh's
425 sage: set_random_seed()
426 sage: n = ZZ.random_element(1,10)
427 sage: J = JordanSpinSimpleEJA(n)
428 sage: x = J.random_element()
429 sage: while x.is_zero():
430 ....: x = J.random_element()
431 sage: x_vec = x.vector()
433 sage: x_bar = x_vec[1:]
434 sage: coeff = 1/(x0^2 - x_bar.inner_product(x_bar))
435 sage: inv_vec = x_vec.parent()([x0] + (-x_bar).list())
436 sage: x_inverse = coeff*inv_vec
437 sage: x.inverse() == J(x_inverse)
442 The identity element is its own inverse::
444 sage: set_random_seed()
445 sage: J = random_eja()
446 sage: J.one().inverse() == J.one()
449 If an element has an inverse, it acts like one. TODO: this
450 can be a lot less ugly once ``is_invertible`` doesn't crash
451 on irregular elements::
453 sage: set_random_seed()
454 sage: J = random_eja()
455 sage: x = J.random_element()
457 ....: x.inverse()*x == J.one()
463 if self
.parent().is_associative():
464 elt
= FiniteDimensionalAlgebraElement(self
.parent(), self
)
467 # TODO: we can do better once the call to is_invertible()
468 # doesn't crash on irregular elements.
469 #if not self.is_invertible():
470 # raise ValueError('element is not invertible')
472 # We do this a little different than the usual recursive
473 # call to a finite-dimensional algebra element, because we
474 # wind up with an inverse that lives in the subalgebra and
475 # we need information about the parent to convert it back.
476 V
= self
.span_of_powers()
477 assoc_subalg
= self
.subalgebra_generated_by()
478 # Mis-design warning: the basis used for span_of_powers()
479 # and subalgebra_generated_by() must be the same, and in
481 elt
= assoc_subalg(V
.coordinates(self
.vector()))
483 # This will be in the subalgebra's coordinates...
484 fda_elt
= FiniteDimensionalAlgebraElement(assoc_subalg
, elt
)
485 subalg_inverse
= fda_elt
.inverse()
487 # So we have to convert back...
488 basis
= [ self
.parent(v
) for v
in V
.basis() ]
489 pairs
= zip(subalg_inverse
.vector(), basis
)
490 return self
.parent().linear_combination(pairs
)
493 def is_invertible(self
):
495 Return whether or not this element is invertible.
497 We can't use the superclass method because it relies on
498 the algebra being associative.
500 return not self
.det().is_zero()
503 def is_nilpotent(self
):
505 Return whether or not some power of this element is zero.
507 The superclass method won't work unless we're in an
508 associative algebra, and we aren't. However, we generate
509 an assocoative subalgebra and we're nilpotent there if and
510 only if we're nilpotent here (probably).
514 The identity element is never nilpotent::
516 sage: set_random_seed()
517 sage: random_eja().one().is_nilpotent()
520 The additive identity is always nilpotent::
522 sage: set_random_seed()
523 sage: random_eja().zero().is_nilpotent()
527 # The element we're going to call "is_nilpotent()" on.
528 # Either myself, interpreted as an element of a finite-
529 # dimensional algebra, or an element of an associative
533 if self
.parent().is_associative():
534 elt
= FiniteDimensionalAlgebraElement(self
.parent(), self
)
536 V
= self
.span_of_powers()
537 assoc_subalg
= self
.subalgebra_generated_by()
538 # Mis-design warning: the basis used for span_of_powers()
539 # and subalgebra_generated_by() must be the same, and in
541 elt
= assoc_subalg(V
.coordinates(self
.vector()))
543 # Recursive call, but should work since elt lives in an
544 # associative algebra.
545 return elt
.is_nilpotent()
548 def is_regular(self
):
550 Return whether or not this is a regular element.
554 The identity element always has degree one, but any element
555 linearly-independent from it is regular::
557 sage: J = JordanSpinSimpleEJA(5)
558 sage: J.one().is_regular()
560 sage: e0, e1, e2, e3, e4 = J.gens() # e0 is the identity
561 sage: for x in J.gens():
562 ....: (J.one() + x).is_regular()
570 return self
.degree() == self
.parent().rank()
575 Compute the degree of this element the straightforward way
576 according to the definition; by appending powers to a list
577 and figuring out its dimension (that is, whether or not
578 they're linearly dependent).
582 sage: J = JordanSpinSimpleEJA(4)
583 sage: J.one().degree()
585 sage: e0,e1,e2,e3 = J.gens()
586 sage: (e0 - e1).degree()
589 In the spin factor algebra (of rank two), all elements that
590 aren't multiples of the identity are regular::
592 sage: set_random_seed()
593 sage: n = ZZ.random_element(1,10)
594 sage: J = JordanSpinSimpleEJA(n)
595 sage: x = J.random_element()
596 sage: x == x.coefficient(0)*J.one() or x.degree() == 2
600 return self
.span_of_powers().dimension()
603 def minimal_polynomial(self
):
607 sage: set_random_seed()
608 sage: x = random_eja().random_element()
609 sage: x.degree() == x.minimal_polynomial().degree()
614 sage: set_random_seed()
615 sage: x = random_eja().random_element()
616 sage: x.degree() == x.minimal_polynomial().degree()
619 The minimal polynomial and the characteristic polynomial coincide
620 and are known (see Alizadeh, Example 11.11) for all elements of
621 the spin factor algebra that aren't scalar multiples of the
624 sage: set_random_seed()
625 sage: n = ZZ.random_element(2,10)
626 sage: J = JordanSpinSimpleEJA(n)
627 sage: y = J.random_element()
628 sage: while y == y.coefficient(0)*J.one():
629 ....: y = J.random_element()
630 sage: y0 = y.vector()[0]
631 sage: y_bar = y.vector()[1:]
632 sage: actual = y.minimal_polynomial()
633 sage: x = SR.symbol('x', domain='real')
634 sage: expected = x^2 - 2*y0*x + (y0^2 - norm(y_bar)^2)
635 sage: bool(actual == expected)
639 # The element we're going to call "minimal_polynomial()" on.
640 # Either myself, interpreted as an element of a finite-
641 # dimensional algebra, or an element of an associative
645 if self
.parent().is_associative():
646 elt
= FiniteDimensionalAlgebraElement(self
.parent(), self
)
648 V
= self
.span_of_powers()
649 assoc_subalg
= self
.subalgebra_generated_by()
650 # Mis-design warning: the basis used for span_of_powers()
651 # and subalgebra_generated_by() must be the same, and in
653 elt
= assoc_subalg(V
.coordinates(self
.vector()))
655 # Recursive call, but should work since elt lives in an
656 # associative algebra.
657 return elt
.minimal_polynomial()
660 def natural_representation(self
):
662 Return a more-natural representation of this element.
664 Every finite-dimensional Euclidean Jordan Algebra is a
665 direct sum of five simple algebras, four of which comprise
666 Hermitian matrices. This method returns the original
667 "natural" representation of this element as a Hermitian
668 matrix, if it has one. If not, you get the usual representation.
672 sage: J = ComplexHermitianSimpleEJA(3)
675 sage: J.one().natural_representation()
685 sage: J = QuaternionHermitianSimpleEJA(3)
688 sage: J.one().natural_representation()
689 [1 0 0 0 0 0 0 0 0 0 0 0]
690 [0 1 0 0 0 0 0 0 0 0 0 0]
691 [0 0 1 0 0 0 0 0 0 0 0 0]
692 [0 0 0 1 0 0 0 0 0 0 0 0]
693 [0 0 0 0 1 0 0 0 0 0 0 0]
694 [0 0 0 0 0 1 0 0 0 0 0 0]
695 [0 0 0 0 0 0 1 0 0 0 0 0]
696 [0 0 0 0 0 0 0 1 0 0 0 0]
697 [0 0 0 0 0 0 0 0 1 0 0 0]
698 [0 0 0 0 0 0 0 0 0 1 0 0]
699 [0 0 0 0 0 0 0 0 0 0 1 0]
700 [0 0 0 0 0 0 0 0 0 0 0 1]
703 B
= self
.parent().natural_basis()
704 W
= B
[0].matrix_space()
705 return W
.linear_combination(zip(self
.vector(), B
))
708 def operator_matrix(self
):
710 Return the matrix that represents left- (or right-)
711 multiplication by this element in the parent algebra.
713 We have to override this because the superclass method
714 returns a matrix that acts on row vectors (that is, on
719 Test the first polarization identity from my notes, Koecher Chapter
720 III, or from Baes (2.3)::
722 sage: set_random_seed()
723 sage: J = random_eja()
724 sage: x = J.random_element()
725 sage: y = J.random_element()
726 sage: Lx = x.operator_matrix()
727 sage: Ly = y.operator_matrix()
728 sage: Lxx = (x*x).operator_matrix()
729 sage: Lxy = (x*y).operator_matrix()
730 sage: bool(2*Lx*Lxy + Ly*Lxx == 2*Lxy*Lx + Lxx*Ly)
733 Test the second polarization identity from my notes or from
736 sage: set_random_seed()
737 sage: J = random_eja()
738 sage: x = J.random_element()
739 sage: y = J.random_element()
740 sage: z = J.random_element()
741 sage: Lx = x.operator_matrix()
742 sage: Ly = y.operator_matrix()
743 sage: Lz = z.operator_matrix()
744 sage: Lzy = (z*y).operator_matrix()
745 sage: Lxy = (x*y).operator_matrix()
746 sage: Lxz = (x*z).operator_matrix()
747 sage: bool(Lx*Lzy + Lz*Lxy + Ly*Lxz == Lzy*Lx + Lxy*Lz + Lxz*Ly)
750 Test the third polarization identity from my notes or from
753 sage: set_random_seed()
754 sage: J = random_eja()
755 sage: u = J.random_element()
756 sage: y = J.random_element()
757 sage: z = J.random_element()
758 sage: Lu = u.operator_matrix()
759 sage: Ly = y.operator_matrix()
760 sage: Lz = z.operator_matrix()
761 sage: Lzy = (z*y).operator_matrix()
762 sage: Luy = (u*y).operator_matrix()
763 sage: Luz = (u*z).operator_matrix()
764 sage: Luyz = (u*(y*z)).operator_matrix()
765 sage: lhs = Lu*Lzy + Lz*Luy + Ly*Luz
766 sage: rhs = Luyz + Ly*Lu*Lz + Lz*Lu*Ly
767 sage: bool(lhs == rhs)
771 fda_elt
= FiniteDimensionalAlgebraElement(self
.parent(), self
)
772 return fda_elt
.matrix().transpose()
775 def quadratic_representation(self
, other
=None):
777 Return the quadratic representation of this element.
781 The explicit form in the spin factor algebra is given by
782 Alizadeh's Example 11.12::
784 sage: set_random_seed()
785 sage: n = ZZ.random_element(1,10)
786 sage: J = JordanSpinSimpleEJA(n)
787 sage: x = J.random_element()
788 sage: x_vec = x.vector()
790 sage: x_bar = x_vec[1:]
791 sage: A = matrix(QQ, 1, [x_vec.inner_product(x_vec)])
792 sage: B = 2*x0*x_bar.row()
793 sage: C = 2*x0*x_bar.column()
794 sage: D = identity_matrix(QQ, n-1)
795 sage: D = (x0^2 - x_bar.inner_product(x_bar))*D
796 sage: D = D + 2*x_bar.tensor_product(x_bar)
797 sage: Q = block_matrix(2,2,[A,B,C,D])
798 sage: Q == x.quadratic_representation()
801 Test all of the properties from Theorem 11.2 in Alizadeh::
803 sage: set_random_seed()
804 sage: J = random_eja()
805 sage: x = J.random_element()
806 sage: y = J.random_element()
810 sage: actual = x.quadratic_representation(y)
811 sage: expected = ( (x+y).quadratic_representation()
812 ....: -x.quadratic_representation()
813 ....: -y.quadratic_representation() ) / 2
814 sage: actual == expected
819 sage: alpha = QQ.random_element()
820 sage: actual = (alpha*x).quadratic_representation()
821 sage: expected = (alpha^2)*x.quadratic_representation()
822 sage: actual == expected
827 sage: Qy = y.quadratic_representation()
828 sage: actual = J(Qy*x.vector()).quadratic_representation()
829 sage: expected = Qy*x.quadratic_representation()*Qy
830 sage: actual == expected
835 sage: k = ZZ.random_element(1,10)
836 sage: actual = (x^k).quadratic_representation()
837 sage: expected = (x.quadratic_representation())^k
838 sage: actual == expected
844 elif not other
in self
.parent():
845 raise TypeError("'other' must live in the same algebra")
847 L
= self
.operator_matrix()
848 M
= other
.operator_matrix()
849 return ( L
*M
+ M
*L
- (self
*other
).operator_matrix() )
852 def span_of_powers(self
):
854 Return the vector space spanned by successive powers of
857 # The dimension of the subalgebra can't be greater than
858 # the big algebra, so just put everything into a list
859 # and let span() get rid of the excess.
860 V
= self
.vector().parent()
861 return V
.span( (self
**d
).vector() for d
in xrange(V
.dimension()) )
864 def subalgebra_generated_by(self
):
866 Return the associative subalgebra of the parent EJA generated
871 sage: set_random_seed()
872 sage: x = random_eja().random_element()
873 sage: x.subalgebra_generated_by().is_associative()
876 Squaring in the subalgebra should be the same thing as
877 squaring in the superalgebra::
879 sage: set_random_seed()
880 sage: x = random_eja().random_element()
881 sage: u = x.subalgebra_generated_by().random_element()
882 sage: u.operator_matrix()*u.vector() == (u**2).vector()
886 # First get the subspace spanned by the powers of myself...
887 V
= self
.span_of_powers()
890 # Now figure out the entries of the right-multiplication
891 # matrix for the successive basis elements b0, b1,... of
894 for b_right
in V
.basis():
895 eja_b_right
= self
.parent()(b_right
)
897 # The first row of the right-multiplication matrix by
898 # b1 is what we get if we apply that matrix to b1. The
899 # second row of the right multiplication matrix by b1
900 # is what we get when we apply that matrix to b2...
902 # IMPORTANT: this assumes that all vectors are COLUMN
903 # vectors, unlike our superclass (which uses row vectors).
904 for b_left
in V
.basis():
905 eja_b_left
= self
.parent()(b_left
)
906 # Multiply in the original EJA, but then get the
907 # coordinates from the subalgebra in terms of its
909 this_row
= V
.coordinates((eja_b_left
*eja_b_right
).vector())
910 b_right_rows
.append(this_row
)
911 b_right_matrix
= matrix(F
, b_right_rows
)
912 mats
.append(b_right_matrix
)
914 # It's an algebra of polynomials in one element, and EJAs
915 # are power-associative.
917 # TODO: choose generator names intelligently.
918 return FiniteDimensionalEuclideanJordanAlgebra(F
, mats
, assume_associative
=True, names
='f')
921 def subalgebra_idempotent(self
):
923 Find an idempotent in the associative subalgebra I generate
924 using Proposition 2.3.5 in Baes.
928 sage: set_random_seed()
930 sage: c = J.random_element().subalgebra_idempotent()
933 sage: J = JordanSpinSimpleEJA(5)
934 sage: c = J.random_element().subalgebra_idempotent()
939 if self
.is_nilpotent():
940 raise ValueError("this only works with non-nilpotent elements!")
942 V
= self
.span_of_powers()
943 J
= self
.subalgebra_generated_by()
944 # Mis-design warning: the basis used for span_of_powers()
945 # and subalgebra_generated_by() must be the same, and in
947 u
= J(V
.coordinates(self
.vector()))
949 # The image of the matrix of left-u^m-multiplication
950 # will be minimal for some natural number s...
952 minimal_dim
= V
.dimension()
953 for i
in xrange(1, V
.dimension()):
954 this_dim
= (u
**i
).operator_matrix().image().dimension()
955 if this_dim
< minimal_dim
:
956 minimal_dim
= this_dim
959 # Now minimal_matrix should correspond to the smallest
960 # non-zero subspace in Baes's (or really, Koecher's)
963 # However, we need to restrict the matrix to work on the
964 # subspace... or do we? Can't we just solve, knowing that
965 # A(c) = u^(s+1) should have a solution in the big space,
968 # Beware, solve_right() means that we're using COLUMN vectors.
969 # Our FiniteDimensionalAlgebraElement superclass uses rows.
971 A
= u_next
.operator_matrix()
972 c_coordinates
= A
.solve_right(u_next
.vector())
974 # Now c_coordinates is the idempotent we want, but it's in
975 # the coordinate system of the subalgebra.
977 # We need the basis for J, but as elements of the parent algebra.
979 basis
= [self
.parent(v
) for v
in V
.basis()]
980 return self
.parent().linear_combination(zip(c_coordinates
, basis
))
985 Return my trace, the sum of my eigenvalues.
989 sage: J = JordanSpinSimpleEJA(3)
990 sage: e0,e1,e2 = J.gens()
991 sage: x = e0 + e1 + e2
996 cs
= self
.characteristic_polynomial().coefficients(sparse
=False)
1000 raise ValueError('charpoly had fewer than 2 coefficients')
1003 def trace_inner_product(self
, other
):
1005 Return the trace inner product of myself and ``other``.
1007 if not other
in self
.parent():
1008 raise TypeError("'other' must live in the same algebra")
1010 return (self
*other
).trace()
1013 def eja_rn(dimension
, field
=QQ
):
1015 Return the Euclidean Jordan Algebra corresponding to the set
1016 `R^n` under the Hadamard product.
1020 This multiplication table can be verified by hand::
1023 sage: e0,e1,e2 = J.gens()
1038 # The FiniteDimensionalAlgebra constructor takes a list of
1039 # matrices, the ith representing right multiplication by the ith
1040 # basis element in the vector space. So if e_1 = (1,0,0), then
1041 # right (Hadamard) multiplication of x by e_1 picks out the first
1042 # component of x; and likewise for the ith basis element e_i.
1043 Qs
= [ matrix(field
, dimension
, dimension
, lambda k
,j
: 1*(k
== j
== i
))
1044 for i
in xrange(dimension
) ]
1046 return FiniteDimensionalEuclideanJordanAlgebra(field
,
1049 inner_product
=_usual_ip
)
1055 Return a "random" finite-dimensional Euclidean Jordan Algebra.
1059 For now, we choose a random natural number ``n`` (greater than zero)
1060 and then give you back one of the following:
1062 * The cartesian product of the rational numbers ``n`` times; this is
1063 ``QQ^n`` with the Hadamard product.
1065 * The Jordan spin algebra on ``QQ^n``.
1067 * The ``n``-by-``n`` rational symmetric matrices with the symmetric
1070 * The ``n``-by-``n`` complex-rational Hermitian matrices embedded
1071 in the space of ``2n``-by-``2n`` real symmetric matrices.
1073 * The ``n``-by-``n`` quaternion-rational Hermitian matrices embedded
1074 in the space of ``4n``-by-``4n`` real symmetric matrices.
1076 Later this might be extended to return Cartesian products of the
1082 Euclidean Jordan algebra of degree...
1085 n
= ZZ
.random_element(1,5)
1086 constructor
= choice([eja_rn
,
1087 JordanSpinSimpleEJA
,
1088 RealSymmetricSimpleEJA
,
1089 ComplexHermitianSimpleEJA
,
1090 QuaternionHermitianSimpleEJA
])
1091 return constructor(n
, field
=QQ
)
1095 def _real_symmetric_basis(n
, field
=QQ
):
1097 Return a basis for the space of real symmetric n-by-n matrices.
1099 # The basis of symmetric matrices, as matrices, in their R^(n-by-n)
1103 for j
in xrange(i
+1):
1104 Eij
= matrix(field
, n
, lambda k
,l
: k
==i
and l
==j
)
1108 # Beware, orthogonal but not normalized!
1109 Sij
= Eij
+ Eij
.transpose()
1114 def _complex_hermitian_basis(n
, field
=QQ
):
1116 Returns a basis for the space of complex Hermitian n-by-n matrices.
1120 sage: set_random_seed()
1121 sage: n = ZZ.random_element(1,5)
1122 sage: all( M.is_symmetric() for M in _complex_hermitian_basis(n) )
1126 F
= QuadraticField(-1, 'I')
1129 # This is like the symmetric case, but we need to be careful:
1131 # * We want conjugate-symmetry, not just symmetry.
1132 # * The diagonal will (as a result) be real.
1136 for j
in xrange(i
+1):
1137 Eij
= matrix(field
, n
, lambda k
,l
: k
==i
and l
==j
)
1139 Sij
= _embed_complex_matrix(Eij
)
1142 # Beware, orthogonal but not normalized! The second one
1143 # has a minus because it's conjugated.
1144 Sij_real
= _embed_complex_matrix(Eij
+ Eij
.transpose())
1146 Sij_imag
= _embed_complex_matrix(I
*Eij
- I
*Eij
.transpose())
1151 def _quaternion_hermitian_basis(n
, field
=QQ
):
1153 Returns a basis for the space of quaternion Hermitian n-by-n matrices.
1157 sage: set_random_seed()
1158 sage: n = ZZ.random_element(1,5)
1159 sage: all( M.is_symmetric() for M in _quaternion_hermitian_basis(n) )
1163 Q
= QuaternionAlgebra(QQ
,-1,-1)
1166 # This is like the symmetric case, but we need to be careful:
1168 # * We want conjugate-symmetry, not just symmetry.
1169 # * The diagonal will (as a result) be real.
1173 for j
in xrange(i
+1):
1174 Eij
= matrix(Q
, n
, lambda k
,l
: k
==i
and l
==j
)
1176 Sij
= _embed_quaternion_matrix(Eij
)
1179 # Beware, orthogonal but not normalized! The second,
1180 # third, and fourth ones have a minus because they're
1182 Sij_real
= _embed_quaternion_matrix(Eij
+ Eij
.transpose())
1184 Sij_I
= _embed_quaternion_matrix(I
*Eij
- I
*Eij
.transpose())
1186 Sij_J
= _embed_quaternion_matrix(J
*Eij
- J
*Eij
.transpose())
1188 Sij_K
= _embed_quaternion_matrix(K
*Eij
- K
*Eij
.transpose())
1194 return vector(m
.base_ring(), m
.list())
1197 return matrix(v
.base_ring(), sqrt(v
.degree()), v
.list())
1199 def _multiplication_table_from_matrix_basis(basis
):
1201 At least three of the five simple Euclidean Jordan algebras have the
1202 symmetric multiplication (A,B) |-> (AB + BA)/2, where the
1203 multiplication on the right is matrix multiplication. Given a basis
1204 for the underlying matrix space, this function returns a
1205 multiplication table (obtained by looping through the basis
1206 elements) for an algebra of those matrices. A reordered copy
1207 of the basis is also returned to work around the fact that
1208 the ``span()`` in this function will change the order of the basis
1209 from what we think it is, to... something else.
1211 # In S^2, for example, we nominally have four coordinates even
1212 # though the space is of dimension three only. The vector space V
1213 # is supposed to hold the entire long vector, and the subspace W
1214 # of V will be spanned by the vectors that arise from symmetric
1215 # matrices. Thus for S^2, dim(V) == 4 and dim(W) == 3.
1216 field
= basis
[0].base_ring()
1217 dimension
= basis
[0].nrows()
1219 V
= VectorSpace(field
, dimension
**2)
1220 W
= V
.span( _mat2vec(s
) for s
in basis
)
1222 # Taking the span above reorders our basis (thanks, jerk!) so we
1223 # need to put our "matrix basis" in the same order as the
1224 # (reordered) vector basis.
1225 S
= tuple( _vec2mat(b
) for b
in W
.basis() )
1229 # Brute force the multiplication-by-s matrix by looping
1230 # through all elements of the basis and doing the computation
1231 # to find out what the corresponding row should be. BEWARE:
1232 # these multiplication tables won't be symmetric! It therefore
1233 # becomes REALLY IMPORTANT that the underlying algebra
1234 # constructor uses ROW vectors and not COLUMN vectors. That's
1235 # why we're computing rows here and not columns.
1238 this_row
= _mat2vec((s
*t
+ t
*s
)/2)
1239 Q_rows
.append(W
.coordinates(this_row
))
1240 Q
= matrix(field
, W
.dimension(), Q_rows
)
1246 def _embed_complex_matrix(M
):
1248 Embed the n-by-n complex matrix ``M`` into the space of real
1249 matrices of size 2n-by-2n via the map the sends each entry `z = a +
1250 bi` to the block matrix ``[[a,b],[-b,a]]``.
1254 sage: F = QuadraticField(-1,'i')
1255 sage: x1 = F(4 - 2*i)
1256 sage: x2 = F(1 + 2*i)
1259 sage: M = matrix(F,2,[[x1,x2],[x3,x4]])
1260 sage: _embed_complex_matrix(M)
1270 raise ValueError("the matrix 'M' must be square")
1271 field
= M
.base_ring()
1276 blocks
.append(matrix(field
, 2, [[a
,b
],[-b
,a
]]))
1278 # We can drop the imaginaries here.
1279 return block_matrix(field
.base_ring(), n
, blocks
)
1282 def _unembed_complex_matrix(M
):
1284 The inverse of _embed_complex_matrix().
1288 sage: A = matrix(QQ,[ [ 1, 2, 3, 4],
1289 ....: [-2, 1, -4, 3],
1290 ....: [ 9, 10, 11, 12],
1291 ....: [-10, 9, -12, 11] ])
1292 sage: _unembed_complex_matrix(A)
1294 [ 10*i + 9 12*i + 11]
1298 sage: set_random_seed()
1299 sage: F = QuadraticField(-1, 'i')
1300 sage: M = random_matrix(F, 3)
1301 sage: _unembed_complex_matrix(_embed_complex_matrix(M)) == M
1307 raise ValueError("the matrix 'M' must be square")
1308 if not n
.mod(2).is_zero():
1309 raise ValueError("the matrix 'M' must be a complex embedding")
1311 F
= QuadraticField(-1, 'i')
1314 # Go top-left to bottom-right (reading order), converting every
1315 # 2-by-2 block we see to a single complex element.
1317 for k
in xrange(n
/2):
1318 for j
in xrange(n
/2):
1319 submat
= M
[2*k
:2*k
+2,2*j
:2*j
+2]
1320 if submat
[0,0] != submat
[1,1]:
1321 raise ValueError('bad on-diagonal submatrix')
1322 if submat
[0,1] != -submat
[1,0]:
1323 raise ValueError('bad off-diagonal submatrix')
1324 z
= submat
[0,0] + submat
[0,1]*i
1327 return matrix(F
, n
/2, elements
)
1330 def _embed_quaternion_matrix(M
):
1332 Embed the n-by-n quaternion matrix ``M`` into the space of real
1333 matrices of size 4n-by-4n by first sending each quaternion entry
1334 `z = a + bi + cj + dk` to the block-complex matrix
1335 ``[[a + bi, c+di],[-c + di, a-bi]]`, and then embedding those into
1340 sage: Q = QuaternionAlgebra(QQ,-1,-1)
1341 sage: i,j,k = Q.gens()
1342 sage: x = 1 + 2*i + 3*j + 4*k
1343 sage: M = matrix(Q, 1, [[x]])
1344 sage: _embed_quaternion_matrix(M)
1351 quaternions
= M
.base_ring()
1354 raise ValueError("the matrix 'M' must be square")
1356 F
= QuadraticField(-1, 'i')
1361 t
= z
.coefficient_tuple()
1366 cplx_matrix
= matrix(F
, 2, [[ a
+ b
*i
, c
+ d
*i
],
1367 [-c
+ d
*i
, a
- b
*i
]])
1368 blocks
.append(_embed_complex_matrix(cplx_matrix
))
1370 # We should have real entries by now, so use the realest field
1371 # we've got for the return value.
1372 return block_matrix(quaternions
.base_ring(), n
, blocks
)
1375 def _unembed_quaternion_matrix(M
):
1377 The inverse of _embed_quaternion_matrix().
1381 sage: M = matrix(QQ, [[ 1, 2, 3, 4],
1382 ....: [-2, 1, -4, 3],
1383 ....: [-3, 4, 1, -2],
1384 ....: [-4, -3, 2, 1]])
1385 sage: _unembed_quaternion_matrix(M)
1386 [1 + 2*i + 3*j + 4*k]
1390 sage: set_random_seed()
1391 sage: Q = QuaternionAlgebra(QQ, -1, -1)
1392 sage: M = random_matrix(Q, 3)
1393 sage: _unembed_quaternion_matrix(_embed_quaternion_matrix(M)) == M
1399 raise ValueError("the matrix 'M' must be square")
1400 if not n
.mod(4).is_zero():
1401 raise ValueError("the matrix 'M' must be a complex embedding")
1403 Q
= QuaternionAlgebra(QQ
,-1,-1)
1406 # Go top-left to bottom-right (reading order), converting every
1407 # 4-by-4 block we see to a 2-by-2 complex block, to a 1-by-1
1410 for l
in xrange(n
/4):
1411 for m
in xrange(n
/4):
1412 submat
= _unembed_complex_matrix(M
[4*l
:4*l
+4,4*m
:4*m
+4])
1413 if submat
[0,0] != submat
[1,1].conjugate():
1414 raise ValueError('bad on-diagonal submatrix')
1415 if submat
[0,1] != -submat
[1,0].conjugate():
1416 raise ValueError('bad off-diagonal submatrix')
1417 z
= submat
[0,0].real() + submat
[0,0].imag()*i
1418 z
+= submat
[0,1].real()*j
+ submat
[0,1].imag()*k
1421 return matrix(Q
, n
/4, elements
)
1424 # The usual inner product on R^n.
1426 return x
.vector().inner_product(y
.vector())
1428 # The inner product used for the real symmetric simple EJA.
1429 # We keep it as a separate function because e.g. the complex
1430 # algebra uses the same inner product, except divided by 2.
1431 def _matrix_ip(X
,Y
):
1432 X_mat
= X
.natural_representation()
1433 Y_mat
= Y
.natural_representation()
1434 return (X_mat
*Y_mat
).trace()
1437 def RealSymmetricSimpleEJA(n
, field
=QQ
):
1439 The rank-n simple EJA consisting of real symmetric n-by-n
1440 matrices, the usual symmetric Jordan product, and the trace inner
1441 product. It has dimension `(n^2 + n)/2` over the reals.
1445 sage: J = RealSymmetricSimpleEJA(2)
1446 sage: e0, e1, e2 = J.gens()
1456 The degree of this algebra is `(n^2 + n) / 2`::
1458 sage: set_random_seed()
1459 sage: n = ZZ.random_element(1,5)
1460 sage: J = RealSymmetricSimpleEJA(n)
1461 sage: J.degree() == (n^2 + n)/2
1464 The Jordan multiplication is what we think it is::
1466 sage: set_random_seed()
1467 sage: n = ZZ.random_element(1,5)
1468 sage: J = RealSymmetricSimpleEJA(n)
1469 sage: x = J.random_element()
1470 sage: y = J.random_element()
1471 sage: actual = (x*y).natural_representation()
1472 sage: X = x.natural_representation()
1473 sage: Y = y.natural_representation()
1474 sage: expected = (X*Y + Y*X)/2
1475 sage: actual == expected
1477 sage: J(expected) == x*y
1481 S
= _real_symmetric_basis(n
, field
=field
)
1482 (Qs
, T
) = _multiplication_table_from_matrix_basis(S
)
1484 return FiniteDimensionalEuclideanJordanAlgebra(field
,
1488 inner_product
=_matrix_ip
)
1491 def ComplexHermitianSimpleEJA(n
, field
=QQ
):
1493 The rank-n simple EJA consisting of complex Hermitian n-by-n
1494 matrices over the real numbers, the usual symmetric Jordan product,
1495 and the real-part-of-trace inner product. It has dimension `n^2` over
1500 The degree of this algebra is `n^2`::
1502 sage: set_random_seed()
1503 sage: n = ZZ.random_element(1,5)
1504 sage: J = ComplexHermitianSimpleEJA(n)
1505 sage: J.degree() == n^2
1508 The Jordan multiplication is what we think it is::
1510 sage: set_random_seed()
1511 sage: n = ZZ.random_element(1,5)
1512 sage: J = ComplexHermitianSimpleEJA(n)
1513 sage: x = J.random_element()
1514 sage: y = J.random_element()
1515 sage: actual = (x*y).natural_representation()
1516 sage: X = x.natural_representation()
1517 sage: Y = y.natural_representation()
1518 sage: expected = (X*Y + Y*X)/2
1519 sage: actual == expected
1521 sage: J(expected) == x*y
1525 S
= _complex_hermitian_basis(n
)
1526 (Qs
, T
) = _multiplication_table_from_matrix_basis(S
)
1528 # Since a+bi on the diagonal is represented as
1533 # we'll double-count the "a" entries if we take the trace of
1535 ip
= lambda X
,Y
: _matrix_ip(X
,Y
)/2
1537 return FiniteDimensionalEuclideanJordanAlgebra(field
,
1544 def QuaternionHermitianSimpleEJA(n
, field
=QQ
):
1546 The rank-n simple EJA consisting of self-adjoint n-by-n quaternion
1547 matrices, the usual symmetric Jordan product, and the
1548 real-part-of-trace inner product. It has dimension `2n^2 - n` over
1553 The degree of this algebra is `n^2`::
1555 sage: set_random_seed()
1556 sage: n = ZZ.random_element(1,5)
1557 sage: J = QuaternionHermitianSimpleEJA(n)
1558 sage: J.degree() == 2*(n^2) - n
1561 The Jordan multiplication is what we think it is::
1563 sage: set_random_seed()
1564 sage: n = ZZ.random_element(1,5)
1565 sage: J = QuaternionHermitianSimpleEJA(n)
1566 sage: x = J.random_element()
1567 sage: y = J.random_element()
1568 sage: actual = (x*y).natural_representation()
1569 sage: X = x.natural_representation()
1570 sage: Y = y.natural_representation()
1571 sage: expected = (X*Y + Y*X)/2
1572 sage: actual == expected
1574 sage: J(expected) == x*y
1578 S
= _quaternion_hermitian_basis(n
)
1579 (Qs
, T
) = _multiplication_table_from_matrix_basis(S
)
1581 # Since a+bi+cj+dk on the diagonal is represented as
1583 # a + bi +cj + dk = [ a b c d]
1588 # we'll quadruple-count the "a" entries if we take the trace of
1590 ip
= lambda X
,Y
: _matrix_ip(X
,Y
)/4
1592 return FiniteDimensionalEuclideanJordanAlgebra(field
,
1599 def OctonionHermitianSimpleEJA(n
):
1601 This shit be crazy. It has dimension 27 over the reals.
1606 def JordanSpinSimpleEJA(n
, field
=QQ
):
1608 The rank-2 simple EJA consisting of real vectors ``x=(x0, x_bar)``
1609 with the usual inner product and jordan product ``x*y =
1610 (<x_bar,y_bar>, x0*y_bar + y0*x_bar)``. It has dimension `n` over
1615 This multiplication table can be verified by hand::
1617 sage: J = JordanSpinSimpleEJA(4)
1618 sage: e0,e1,e2,e3 = J.gens()
1634 In one dimension, this is the reals under multiplication::
1636 sage: J1 = JordanSpinSimpleEJA(1)
1637 sage: J2 = eja_rn(1)
1643 id_matrix
= identity_matrix(field
, n
)
1645 ei
= id_matrix
.column(i
)
1646 Qi
= zero_matrix(field
, n
)
1648 Qi
.set_column(0, ei
)
1649 Qi
+= diagonal_matrix(n
, [ei
[0]]*n
)
1650 # The addition of the diagonal matrix adds an extra ei[0] in the
1651 # upper-left corner of the matrix.
1652 Qi
[0,0] = Qi
[0,0] * ~
field(2)
1655 # The rank of the spin factor algebra is two, UNLESS we're in a
1656 # one-dimensional ambient space (the rank is bounded by the
1657 # ambient dimension).
1658 return FiniteDimensionalEuclideanJordanAlgebra(field
,
1661 inner_product
=_usual_ip
)