1 from sage
.matrix
.constructor
import matrix
2 from sage
.modules
.free_module
import VectorSpace
3 from sage
.modules
.with_basis
.indexed_element
import IndexedFreeModuleElement
5 # TODO: make this unnecessary somehow.
6 from sage
.misc
.lazy_import
import lazy_import
7 lazy_import('mjo.eja.eja_algebra', 'FiniteDimensionalEuclideanJordanAlgebra')
8 lazy_import('mjo.eja.eja_subalgebra',
9 'FiniteDimensionalEuclideanJordanElementSubalgebra')
10 from mjo
.eja
.eja_operator
import FiniteDimensionalEuclideanJordanAlgebraOperator
11 from mjo
.eja
.eja_utils
import _mat2vec
13 class FiniteDimensionalEuclideanJordanAlgebraElement(IndexedFreeModuleElement
):
15 An element of a Euclidean Jordan algebra.
20 Oh man, I should not be doing this. This hides the "disabled"
21 methods ``left_matrix`` and ``matrix`` from introspection;
22 in particular it removes them from tab-completion.
24 return filter(lambda s
: s
not in ['left_matrix', 'matrix'],
28 def __init__(self
, A
, elt
):
33 sage: from mjo.eja.eja_algebra import (RealSymmetricEJA,
38 The identity in `S^n` is converted to the identity in the EJA::
40 sage: J = RealSymmetricEJA(3)
41 sage: I = matrix.identity(QQ,3)
45 This skew-symmetric matrix can't be represented in the EJA::
47 sage: J = RealSymmetricEJA(3)
48 sage: A = matrix(QQ,3, lambda i,j: i-j)
50 Traceback (most recent call last):
52 ArithmeticError: vector is not in free module
56 Ensure that we can convert any element of the parent's
57 underlying vector space back into an algebra element whose
58 vector representation is what we started with::
60 sage: set_random_seed()
61 sage: J = random_eja()
62 sage: v = J.vector_space().random_element()
63 sage: J(v).to_vector() == v
67 # Goal: if we're given a matrix, and if it lives in our
68 # parent algebra's "natural ambient space," convert it
69 # into an algebra element.
71 # The catch is, we make a recursive call after converting
72 # the given matrix into a vector that lives in the algebra.
73 # This we need to try the parent class initializer first,
74 # to avoid recursing forever if we're given something that
75 # already fits into the algebra, but also happens to live
76 # in the parent's "natural ambient space" (this happens with
78 ifme
= super(FiniteDimensionalEuclideanJordanAlgebraElement
, self
)
82 natural_basis
= A
.natural_basis()
83 if elt
in natural_basis
[0].matrix_space():
84 # Thanks for nothing! Matrix spaces aren't vector
85 # spaces in Sage, so we have to figure out its
86 # natural-basis coordinates ourselves.
87 V
= VectorSpace(elt
.base_ring(), elt
.nrows()**2)
88 W
= V
.span( _mat2vec(s
) for s
in natural_basis
)
89 coords
= W
.coordinate_vector(_mat2vec(elt
))
90 ifme
.__init
__(A
, coords
)
95 Return ``self`` raised to the power ``n``.
97 Jordan algebras are always power-associative; see for
98 example Faraut and Koranyi, Proposition II.1.2 (ii).
100 We have to override this because our superclass uses row
101 vectors instead of column vectors! We, on the other hand,
102 assume column vectors everywhere.
106 sage: from mjo.eja.eja_algebra import random_eja
110 The definition of `x^2` is the unambiguous `x*x`::
112 sage: set_random_seed()
113 sage: x = random_eja().random_element()
117 A few examples of power-associativity::
119 sage: set_random_seed()
120 sage: x = random_eja().random_element()
121 sage: x*(x*x)*(x*x) == x^5
123 sage: (x*x)*(x*x*x) == x^5
126 We also know that powers operator-commute (Koecher, Chapter
129 sage: set_random_seed()
130 sage: x = random_eja().random_element()
131 sage: m = ZZ.random_element(0,10)
132 sage: n = ZZ.random_element(0,10)
133 sage: Lxm = (x^m).operator()
134 sage: Lxn = (x^n).operator()
135 sage: Lxm*Lxn == Lxn*Lxm
140 return self
.parent().one()
144 return (self
.operator()**(n
-1))(self
)
147 def apply_univariate_polynomial(self
, p
):
149 Apply the univariate polynomial ``p`` to this element.
151 A priori, SageMath won't allow us to apply a univariate
152 polynomial to an element of an EJA, because we don't know
153 that EJAs are rings (they are usually not associative). Of
154 course, we know that EJAs are power-associative, so the
155 operation is ultimately kosher. This function sidesteps
156 the CAS to get the answer we want and expect.
160 sage: from mjo.eja.eja_algebra import (RealCartesianProductEJA,
165 sage: R = PolynomialRing(QQ, 't')
167 sage: p = t^4 - t^3 + 5*t - 2
168 sage: J = RealCartesianProductEJA(5)
169 sage: J.one().apply_univariate_polynomial(p) == 3*J.one()
174 We should always get back an element of the algebra::
176 sage: set_random_seed()
177 sage: p = PolynomialRing(QQ, 't').random_element()
178 sage: J = random_eja()
179 sage: x = J.random_element()
180 sage: x.apply_univariate_polynomial(p) in J
184 if len(p
.variables()) > 1:
185 raise ValueError("not a univariate polynomial")
188 # Convert the coeficcients to the parent's base ring,
189 # because a priori they might live in an (unnecessarily)
190 # larger ring for which P.sum() would fail below.
191 cs
= [ R(c
) for c
in p
.coefficients(sparse
=False) ]
192 return P
.sum( cs
[k
]*(self
**k
) for k
in range(len(cs
)) )
195 def characteristic_polynomial(self
):
197 Return the characteristic polynomial of this element.
201 sage: from mjo.eja.eja_algebra import RealCartesianProductEJA
205 The rank of `R^3` is three, and the minimal polynomial of
206 the identity element is `(t-1)` from which it follows that
207 the characteristic polynomial should be `(t-1)^3`::
209 sage: J = RealCartesianProductEJA(3)
210 sage: J.one().characteristic_polynomial()
211 t^3 - 3*t^2 + 3*t - 1
213 Likewise, the characteristic of the zero element in the
214 rank-three algebra `R^{n}` should be `t^{3}`::
216 sage: J = RealCartesianProductEJA(3)
217 sage: J.zero().characteristic_polynomial()
222 The characteristic polynomial of an element should evaluate
223 to zero on that element::
225 sage: set_random_seed()
226 sage: x = RealCartesianProductEJA(3).random_element()
227 sage: p = x.characteristic_polynomial()
228 sage: x.apply_univariate_polynomial(p)
232 p
= self
.parent().characteristic_polynomial()
233 return p(*self
.to_vector())
236 def inner_product(self
, other
):
238 Return the parent algebra's inner product of myself and ``other``.
242 sage: from mjo.eja.eja_algebra import (
243 ....: ComplexHermitianEJA,
245 ....: QuaternionHermitianEJA,
246 ....: RealSymmetricEJA,
251 The inner product in the Jordan spin algebra is the usual
252 inner product on `R^n` (this example only works because the
253 basis for the Jordan algebra is the standard basis in `R^n`)::
255 sage: J = JordanSpinEJA(3)
256 sage: x = vector(QQ,[1,2,3])
257 sage: y = vector(QQ,[4,5,6])
258 sage: x.inner_product(y)
260 sage: J(x).inner_product(J(y))
263 The inner product on `S^n` is `<X,Y> = trace(X*Y)`, where
264 multiplication is the usual matrix multiplication in `S^n`,
265 so the inner product of the identity matrix with itself
268 sage: J = RealSymmetricEJA(3)
269 sage: J.one().inner_product(J.one())
272 Likewise, the inner product on `C^n` is `<X,Y> =
273 Re(trace(X*Y))`, where we must necessarily take the real
274 part because the product of Hermitian matrices may not be
277 sage: J = ComplexHermitianEJA(3)
278 sage: J.one().inner_product(J.one())
281 Ditto for the quaternions::
283 sage: J = QuaternionHermitianEJA(3)
284 sage: J.one().inner_product(J.one())
289 Ensure that we can always compute an inner product, and that
290 it gives us back a real number::
292 sage: set_random_seed()
293 sage: J = random_eja()
294 sage: x = J.random_element()
295 sage: y = J.random_element()
296 sage: x.inner_product(y) in RR
302 raise TypeError("'other' must live in the same algebra")
304 return P
.inner_product(self
, other
)
307 def operator_commutes_with(self
, other
):
309 Return whether or not this element operator-commutes
314 sage: from mjo.eja.eja_algebra import random_eja
318 The definition of a Jordan algebra says that any element
319 operator-commutes with its square::
321 sage: set_random_seed()
322 sage: x = random_eja().random_element()
323 sage: x.operator_commutes_with(x^2)
328 Test Lemma 1 from Chapter III of Koecher::
330 sage: set_random_seed()
331 sage: J = random_eja()
332 sage: u = J.random_element()
333 sage: v = J.random_element()
334 sage: lhs = u.operator_commutes_with(u*v)
335 sage: rhs = v.operator_commutes_with(u^2)
339 Test the first polarization identity from my notes, Koecher
340 Chapter III, or from Baes (2.3)::
342 sage: set_random_seed()
343 sage: J = random_eja()
344 sage: x = J.random_element()
345 sage: y = J.random_element()
346 sage: Lx = x.operator()
347 sage: Ly = y.operator()
348 sage: Lxx = (x*x).operator()
349 sage: Lxy = (x*y).operator()
350 sage: bool(2*Lx*Lxy + Ly*Lxx == 2*Lxy*Lx + Lxx*Ly)
353 Test the second polarization identity from my notes or from
356 sage: set_random_seed()
357 sage: J = random_eja()
358 sage: x = J.random_element()
359 sage: y = J.random_element()
360 sage: z = J.random_element()
361 sage: Lx = x.operator()
362 sage: Ly = y.operator()
363 sage: Lz = z.operator()
364 sage: Lzy = (z*y).operator()
365 sage: Lxy = (x*y).operator()
366 sage: Lxz = (x*z).operator()
367 sage: bool(Lx*Lzy + Lz*Lxy + Ly*Lxz == Lzy*Lx + Lxy*Lz + Lxz*Ly)
370 Test the third polarization identity from my notes or from
373 sage: set_random_seed()
374 sage: J = random_eja()
375 sage: u = J.random_element()
376 sage: y = J.random_element()
377 sage: z = J.random_element()
378 sage: Lu = u.operator()
379 sage: Ly = y.operator()
380 sage: Lz = z.operator()
381 sage: Lzy = (z*y).operator()
382 sage: Luy = (u*y).operator()
383 sage: Luz = (u*z).operator()
384 sage: Luyz = (u*(y*z)).operator()
385 sage: lhs = Lu*Lzy + Lz*Luy + Ly*Luz
386 sage: rhs = Luyz + Ly*Lu*Lz + Lz*Lu*Ly
387 sage: bool(lhs == rhs)
391 if not other
in self
.parent():
392 raise TypeError("'other' must live in the same algebra")
401 Return my determinant, the product of my eigenvalues.
405 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
410 sage: J = JordanSpinEJA(2)
411 sage: e0,e1 = J.gens()
412 sage: x = sum( J.gens() )
418 sage: J = JordanSpinEJA(3)
419 sage: e0,e1,e2 = J.gens()
420 sage: x = sum( J.gens() )
426 An element is invertible if and only if its determinant is
429 sage: set_random_seed()
430 sage: x = random_eja().random_element()
431 sage: x.is_invertible() == (x.det() != 0)
437 p
= P
._charpoly
_coeff
(0)
438 # The _charpoly_coeff function already adds the factor of
439 # -1 to ensure that _charpoly_coeff(0) is really what
440 # appears in front of t^{0} in the charpoly. However,
441 # we want (-1)^r times THAT for the determinant.
442 return ((-1)**r
)*p(*self
.to_vector())
447 Return the Jordan-multiplicative inverse of this element.
451 We appeal to the quadratic representation as in Koecher's
452 Theorem 12 in Chapter III, Section 5.
456 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
461 The inverse in the spin factor algebra is given in Alizadeh's
464 sage: set_random_seed()
465 sage: n = ZZ.random_element(1,10)
466 sage: J = JordanSpinEJA(n)
467 sage: x = J.random_element()
468 sage: while not x.is_invertible():
469 ....: x = J.random_element()
470 sage: x_vec = x.to_vector()
472 sage: x_bar = x_vec[1:]
473 sage: coeff = ~(x0^2 - x_bar.inner_product(x_bar))
474 sage: inv_vec = x_vec.parent()([x0] + (-x_bar).list())
475 sage: x_inverse = coeff*inv_vec
476 sage: x.inverse() == J(x_inverse)
481 The identity element is its own inverse::
483 sage: set_random_seed()
484 sage: J = random_eja()
485 sage: J.one().inverse() == J.one()
488 If an element has an inverse, it acts like one::
490 sage: set_random_seed()
491 sage: J = random_eja()
492 sage: x = J.random_element()
493 sage: (not x.is_invertible()) or (x.inverse()*x == J.one())
496 The inverse of the inverse is what we started with::
498 sage: set_random_seed()
499 sage: J = random_eja()
500 sage: x = J.random_element()
501 sage: (not x.is_invertible()) or (x.inverse().inverse() == x)
504 The zero element is never invertible::
506 sage: set_random_seed()
507 sage: J = random_eja().zero().inverse()
508 Traceback (most recent call last):
510 ValueError: element is not invertible
513 if not self
.is_invertible():
514 raise ValueError("element is not invertible")
516 return (~self
.quadratic_representation())(self
)
519 def is_invertible(self
):
521 Return whether or not this element is invertible.
525 The usual way to do this is to check if the determinant is
526 zero, but we need the characteristic polynomial for the
527 determinant. The minimal polynomial is a lot easier to get,
528 so we use Corollary 2 in Chapter V of Koecher to check
529 whether or not the paren't algebra's zero element is a root
530 of this element's minimal polynomial.
532 Beware that we can't use the superclass method, because it
533 relies on the algebra being associative.
537 sage: from mjo.eja.eja_algebra import random_eja
541 The identity element is always invertible::
543 sage: set_random_seed()
544 sage: J = random_eja()
545 sage: J.one().is_invertible()
548 The zero element is never invertible::
550 sage: set_random_seed()
551 sage: J = random_eja()
552 sage: J.zero().is_invertible()
556 zero
= self
.parent().zero()
557 p
= self
.minimal_polynomial()
558 return not (p(zero
) == zero
)
561 def is_nilpotent(self
):
563 Return whether or not some power of this element is zero.
567 We use Theorem 5 in Chapter III of Koecher, which says that
568 an element ``x`` is nilpotent if and only if ``x.operator()``
569 is nilpotent. And it is a basic fact of linear algebra that
570 an operator on an `n`-dimensional space is nilpotent if and
571 only if, when raised to the `n`th power, it equals the zero
572 operator (for example, see Axler Corollary 8.8).
576 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
581 sage: J = JordanSpinEJA(3)
582 sage: x = sum(J.gens())
583 sage: x.is_nilpotent()
588 The identity element is never nilpotent::
590 sage: set_random_seed()
591 sage: random_eja().one().is_nilpotent()
594 The additive identity is always nilpotent::
596 sage: set_random_seed()
597 sage: random_eja().zero().is_nilpotent()
602 zero_operator
= P
.zero().operator()
603 return self
.operator()**P
.dimension() == zero_operator
606 def is_regular(self
):
608 Return whether or not this is a regular element.
612 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
617 The identity element always has degree one, but any element
618 linearly-independent from it is regular::
620 sage: J = JordanSpinEJA(5)
621 sage: J.one().is_regular()
623 sage: e0, e1, e2, e3, e4 = J.gens() # e0 is the identity
624 sage: for x in J.gens():
625 ....: (J.one() + x).is_regular()
634 The zero element should never be regular, unless the parent
635 algebra has dimension one::
637 sage: set_random_seed()
638 sage: J = random_eja()
639 sage: J.dimension() == 1 or not J.zero().is_regular()
642 The unit element isn't regular unless the algebra happens to
643 consist of only its scalar multiples::
645 sage: set_random_seed()
646 sage: J = random_eja()
647 sage: J.dimension() == 1 or not J.one().is_regular()
651 return self
.degree() == self
.parent().rank()
656 Return the degree of this element, which is defined to be
657 the degree of its minimal polynomial.
661 For now, we skip the messy minimal polynomial computation
662 and instead return the dimension of the vector space spanned
663 by the powers of this element. The latter is a bit more
664 straightforward to compute.
668 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
673 sage: J = JordanSpinEJA(4)
674 sage: J.one().degree()
676 sage: e0,e1,e2,e3 = J.gens()
677 sage: (e0 - e1).degree()
680 In the spin factor algebra (of rank two), all elements that
681 aren't multiples of the identity are regular::
683 sage: set_random_seed()
684 sage: n = ZZ.random_element(1,10)
685 sage: J = JordanSpinEJA(n)
686 sage: x = J.random_element()
687 sage: x == x.coefficient(0)*J.one() or x.degree() == 2
692 The zero and unit elements are both of degree one::
694 sage: set_random_seed()
695 sage: J = random_eja()
696 sage: J.zero().degree()
698 sage: J.one().degree()
701 Our implementation agrees with the definition::
703 sage: set_random_seed()
704 sage: x = random_eja().random_element()
705 sage: x.degree() == x.minimal_polynomial().degree()
709 return self
.subalgebra_generated_by().dimension()
712 def left_matrix(self
):
714 Our parent class defines ``left_matrix`` and ``matrix``
715 methods whose names are misleading. We don't want them.
717 raise NotImplementedError("use operator().matrix() instead")
722 def minimal_polynomial(self
):
724 Return the minimal polynomial of this element,
725 as a function of the variable `t`.
729 We restrict ourselves to the associative subalgebra
730 generated by this element, and then return the minimal
731 polynomial of this element's operator matrix (in that
732 subalgebra). This works by Baes Proposition 2.3.16.
736 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
741 The minimal polynomial of the identity and zero elements are
744 sage: set_random_seed()
745 sage: J = random_eja()
746 sage: J.one().minimal_polynomial()
748 sage: J.zero().minimal_polynomial()
751 The degree of an element is (by one definition) the degree
752 of its minimal polynomial::
754 sage: set_random_seed()
755 sage: x = random_eja().random_element()
756 sage: x.degree() == x.minimal_polynomial().degree()
759 The minimal polynomial and the characteristic polynomial coincide
760 and are known (see Alizadeh, Example 11.11) for all elements of
761 the spin factor algebra that aren't scalar multiples of the
764 sage: set_random_seed()
765 sage: n = ZZ.random_element(2,10)
766 sage: J = JordanSpinEJA(n)
767 sage: y = J.random_element()
768 sage: while y == y.coefficient(0)*J.one():
769 ....: y = J.random_element()
770 sage: y0 = y.to_vector()[0]
771 sage: y_bar = y.to_vector()[1:]
772 sage: actual = y.minimal_polynomial()
773 sage: t = PolynomialRing(J.base_ring(),'t').gen(0)
774 sage: expected = t^2 - 2*y0*t + (y0^2 - norm(y_bar)^2)
775 sage: bool(actual == expected)
778 The minimal polynomial should always kill its element::
780 sage: set_random_seed()
781 sage: x = random_eja().random_element()
782 sage: p = x.minimal_polynomial()
783 sage: x.apply_univariate_polynomial(p)
787 A
= self
.subalgebra_generated_by()
788 return A
.element_class(A
,self
).operator().minimal_polynomial()
792 def natural_representation(self
):
794 Return a more-natural representation of this element.
796 Every finite-dimensional Euclidean Jordan Algebra is a
797 direct sum of five simple algebras, four of which comprise
798 Hermitian matrices. This method returns the original
799 "natural" representation of this element as a Hermitian
800 matrix, if it has one. If not, you get the usual representation.
804 sage: from mjo.eja.eja_algebra import (ComplexHermitianEJA,
805 ....: QuaternionHermitianEJA)
809 sage: J = ComplexHermitianEJA(3)
812 sage: J.one().natural_representation()
822 sage: J = QuaternionHermitianEJA(3)
825 sage: J.one().natural_representation()
826 [1 0 0 0 0 0 0 0 0 0 0 0]
827 [0 1 0 0 0 0 0 0 0 0 0 0]
828 [0 0 1 0 0 0 0 0 0 0 0 0]
829 [0 0 0 1 0 0 0 0 0 0 0 0]
830 [0 0 0 0 1 0 0 0 0 0 0 0]
831 [0 0 0 0 0 1 0 0 0 0 0 0]
832 [0 0 0 0 0 0 1 0 0 0 0 0]
833 [0 0 0 0 0 0 0 1 0 0 0 0]
834 [0 0 0 0 0 0 0 0 1 0 0 0]
835 [0 0 0 0 0 0 0 0 0 1 0 0]
836 [0 0 0 0 0 0 0 0 0 0 1 0]
837 [0 0 0 0 0 0 0 0 0 0 0 1]
840 B
= self
.parent().natural_basis()
841 W
= B
[0].matrix_space()
842 return W
.linear_combination(zip(B
,self
.to_vector()))
847 Return the left-multiplication-by-this-element
848 operator on the ambient algebra.
852 sage: from mjo.eja.eja_algebra import random_eja
856 sage: set_random_seed()
857 sage: J = random_eja()
858 sage: x = J.random_element()
859 sage: y = J.random_element()
860 sage: x.operator()(y) == x*y
862 sage: y.operator()(x) == x*y
867 return FiniteDimensionalEuclideanJordanAlgebraOperator(
873 def quadratic_representation(self
, other
=None):
875 Return the quadratic representation of this element.
879 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
884 The explicit form in the spin factor algebra is given by
885 Alizadeh's Example 11.12::
887 sage: set_random_seed()
888 sage: n = ZZ.random_element(1,10)
889 sage: J = JordanSpinEJA(n)
890 sage: x = J.random_element()
891 sage: x_vec = x.to_vector()
893 sage: x_bar = x_vec[1:]
894 sage: A = matrix(QQ, 1, [x_vec.inner_product(x_vec)])
895 sage: B = 2*x0*x_bar.row()
896 sage: C = 2*x0*x_bar.column()
897 sage: D = matrix.identity(QQ, n-1)
898 sage: D = (x0^2 - x_bar.inner_product(x_bar))*D
899 sage: D = D + 2*x_bar.tensor_product(x_bar)
900 sage: Q = matrix.block(2,2,[A,B,C,D])
901 sage: Q == x.quadratic_representation().matrix()
904 Test all of the properties from Theorem 11.2 in Alizadeh::
906 sage: set_random_seed()
907 sage: J = random_eja()
908 sage: x = J.random_element()
909 sage: y = J.random_element()
910 sage: Lx = x.operator()
911 sage: Lxx = (x*x).operator()
912 sage: Qx = x.quadratic_representation()
913 sage: Qy = y.quadratic_representation()
914 sage: Qxy = x.quadratic_representation(y)
915 sage: Qex = J.one().quadratic_representation(x)
916 sage: n = ZZ.random_element(10)
917 sage: Qxn = (x^n).quadratic_representation()
921 sage: 2*Qxy == (x+y).quadratic_representation() - Qx - Qy
924 Property 2 (multiply on the right for :trac:`28272`):
926 sage: alpha = QQ.random_element()
927 sage: (alpha*x).quadratic_representation() == Qx*(alpha^2)
932 sage: not x.is_invertible() or ( Qx(x.inverse()) == x )
935 sage: not x.is_invertible() or (
938 ....: x.inverse().quadratic_representation() )
941 sage: Qxy(J.one()) == x*y
946 sage: not x.is_invertible() or (
947 ....: x.quadratic_representation(x.inverse())*Qx
948 ....: == Qx*x.quadratic_representation(x.inverse()) )
951 sage: not x.is_invertible() or (
952 ....: x.quadratic_representation(x.inverse())*Qx
954 ....: 2*x.operator()*Qex - Qx )
957 sage: 2*x.operator()*Qex - Qx == Lxx
962 sage: Qy(x).quadratic_representation() == Qy*Qx*Qy
972 sage: not x.is_invertible() or (
973 ....: Qx*x.inverse().operator() == Lx )
978 sage: not x.operator_commutes_with(y) or (
979 ....: Qx(y)^n == Qxn(y^n) )
985 elif not other
in self
.parent():
986 raise TypeError("'other' must live in the same algebra")
990 return ( L
*M
+ M
*L
- (self
*other
).operator() )
995 def subalgebra_generated_by(self
):
997 Return the associative subalgebra of the parent EJA generated
1002 sage: from mjo.eja.eja_algebra import random_eja
1006 sage: set_random_seed()
1007 sage: x = random_eja().random_element()
1008 sage: x.subalgebra_generated_by().is_associative()
1011 Squaring in the subalgebra should work the same as in
1014 sage: set_random_seed()
1015 sage: x = random_eja().random_element()
1016 sage: A = x.subalgebra_generated_by()
1017 sage: A(x^2) == A(x)*A(x)
1021 return FiniteDimensionalEuclideanJordanElementSubalgebra(self
)
1024 def subalgebra_idempotent(self
):
1026 Find an idempotent in the associative subalgebra I generate
1027 using Proposition 2.3.5 in Baes.
1031 sage: from mjo.eja.eja_algebra import random_eja
1035 sage: set_random_seed()
1036 sage: J = random_eja()
1037 sage: x = J.random_element()
1038 sage: while x.is_nilpotent():
1039 ....: x = J.random_element()
1040 sage: c = x.subalgebra_idempotent()
1045 if self
.is_nilpotent():
1046 raise ValueError("this only works with non-nilpotent elements!")
1048 J
= self
.subalgebra_generated_by()
1051 # The image of the matrix of left-u^m-multiplication
1052 # will be minimal for some natural number s...
1054 minimal_dim
= J
.dimension()
1055 for i
in xrange(1, minimal_dim
):
1056 this_dim
= (u
**i
).operator().matrix().image().dimension()
1057 if this_dim
< minimal_dim
:
1058 minimal_dim
= this_dim
1061 # Now minimal_matrix should correspond to the smallest
1062 # non-zero subspace in Baes's (or really, Koecher's)
1065 # However, we need to restrict the matrix to work on the
1066 # subspace... or do we? Can't we just solve, knowing that
1067 # A(c) = u^(s+1) should have a solution in the big space,
1070 # Beware, solve_right() means that we're using COLUMN vectors.
1071 # Our FiniteDimensionalAlgebraElement superclass uses rows.
1073 A
= u_next
.operator().matrix()
1074 c
= J(A
.solve_right(u_next
.to_vector()))
1076 # Now c is the idempotent we want, but it still lives in the subalgebra.
1077 return c
.superalgebra_element()
1082 Return my trace, the sum of my eigenvalues.
1086 sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
1087 ....: RealCartesianProductEJA,
1092 sage: J = JordanSpinEJA(3)
1093 sage: x = sum(J.gens())
1099 sage: J = RealCartesianProductEJA(5)
1100 sage: J.one().trace()
1105 The trace of an element is a real number::
1107 sage: set_random_seed()
1108 sage: J = random_eja()
1109 sage: J.random_element().trace() in J.base_ring()
1115 p
= P
._charpoly
_coeff
(r
-1)
1116 # The _charpoly_coeff function already adds the factor of
1117 # -1 to ensure that _charpoly_coeff(r-1) is really what
1118 # appears in front of t^{r-1} in the charpoly. However,
1119 # we want the negative of THAT for the trace.
1120 return -p(*self
.to_vector())
1123 def trace_inner_product(self
, other
):
1125 Return the trace inner product of myself and ``other``.
1129 sage: from mjo.eja.eja_algebra import random_eja
1133 The trace inner product is commutative::
1135 sage: set_random_seed()
1136 sage: J = random_eja()
1137 sage: x = J.random_element(); y = J.random_element()
1138 sage: x.trace_inner_product(y) == y.trace_inner_product(x)
1141 The trace inner product is bilinear::
1143 sage: set_random_seed()
1144 sage: J = random_eja()
1145 sage: x = J.random_element()
1146 sage: y = J.random_element()
1147 sage: z = J.random_element()
1148 sage: a = QQ.random_element();
1149 sage: actual = (a*(x+z)).trace_inner_product(y)
1150 sage: expected = ( a*x.trace_inner_product(y) +
1151 ....: a*z.trace_inner_product(y) )
1152 sage: actual == expected
1154 sage: actual = x.trace_inner_product(a*(y+z))
1155 sage: expected = ( a*x.trace_inner_product(y) +
1156 ....: a*x.trace_inner_product(z) )
1157 sage: actual == expected
1160 The trace inner product satisfies the compatibility
1161 condition in the definition of a Euclidean Jordan algebra::
1163 sage: set_random_seed()
1164 sage: J = random_eja()
1165 sage: x = J.random_element()
1166 sage: y = J.random_element()
1167 sage: z = J.random_element()
1168 sage: (x*y).trace_inner_product(z) == y.trace_inner_product(x*z)
1172 if not other
in self
.parent():
1173 raise TypeError("'other' must live in the same algebra")
1175 return (self
*other
).trace()