]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/eja/euclidean_jordan_algebra.py
eja: add operator_commutes_with() for elements.
[sage.d.git] / mjo / eja / euclidean_jordan_algebra.py
index 3a98324cbb7c9a7f18a86677a53785a81988d28b..4713ff0859876b5832e6e5e9551f632444c6a138 100644 (file)
@@ -124,6 +124,18 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
                 sage: (x*x)*(x*x*x) == x^5
                 True
 
+            We also know that powers operator-commute (Koecher, Chapter
+            III, Corollary 1)::
+
+                sage: set_random_seed()
+                sage: x = random_eja().random_element()
+                sage: m = ZZ.random_element(0,10)
+                sage: n = ZZ.random_element(0,10)
+                sage: Lxm = (x^m).matrix()
+                sage: Lxn = (x^n).matrix()
+                sage: Lxm*Lxn == Lxn*Lxm
+                True
+
             """
             A = self.parent()
             if n == 0:
@@ -149,6 +161,43 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
                 raise NotImplementedError('irregular element')
 
 
+        def operator_commutes_with(self, other):
+            """
+            Return whether or not this element operator-commutes
+            with ``other``.
+
+            EXAMPLES:
+
+            The definition of a Jordan algebra says that any element
+            operator-commutes with its square::
+
+                sage: set_random_seed()
+                sage: x = random_eja().random_element()
+                sage: x.operator_commutes_with(x^2)
+                True
+
+            TESTS:
+
+            Test Lemma 1 from Chapter III of Koecher::
+
+                sage: set_random_seed()
+                sage: J = random_eja()
+                sage: u = J.random_element()
+                sage: v = J.random_element()
+                sage: lhs = u.operator_commutes_with(u*v)
+                sage: rhs = v.operator_commutes_with(u^2)
+                sage: lhs == rhs
+                True
+
+            """
+            if not other in self.parent():
+                raise ArgumentError("'other' must live in the same algebra")
+
+            A = self.matrix()
+            B = other.matrix()
+            return (A*B == B*A)
+
+
         def det(self):
             """
             Return my determinant, the product of my eigenvalues.