]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
eja: add more quadratic representation tests.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 6 Jul 2019 17:41:42 +0000 (13:41 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 29 Jul 2019 03:19:01 +0000 (23:19 -0400)
mjo/eja/euclidean_jordan_algebra.py

index d6235d33ee2edd77f24d1b304e8d4d80b4342d9f..87a0ca0592b8103ec3410fef57a1134f26a0bf9b 100644 (file)
@@ -323,7 +323,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             return elt.minimal_polynomial()
 
 
-        def quadratic_representation(self):
+        def quadratic_representation(self, other=None):
             """
             Return the quadratic representation of this element.
 
@@ -332,6 +332,7 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
             The explicit form in the spin factor algebra is given by
             Alizadeh's Example 11.12::
 
+                sage: set_random_seed()
                 sage: n = ZZ.random_element(1,10).abs()
                 sage: J = JordanSpinSimpleEJA(n)
                 sage: x = J.random_element()
@@ -348,8 +349,55 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra):
                 sage: Q == x.quadratic_representation()
                 True
 
+            Test all of the properties from Theorem 11.2 in Alizadeh::
+
+                sage: set_random_seed()
+                sage: J = random_eja()
+                sage: x = J.random_element()
+                sage: y = J.random_element()
+
+            Property 1:
+
+                sage: actual = x.quadratic_representation(y)
+                sage: expected = ( (x+y).quadratic_representation()
+                ....:              -x.quadratic_representation()
+                ....:              -y.quadratic_representation() ) / 2
+                sage: actual == expected
+                True
+
+            Property 2:
+
+                sage: alpha = QQ.random_element()
+                sage: actual = (alpha*x).quadratic_representation()
+                sage: expected = (alpha^2)*x.quadratic_representation()
+                sage: actual == expected
+                True
+
+            Property 5:
+
+                sage: Qy = y.quadratic_representation()
+                sage: actual = J(Qy*x.vector()).quadratic_representation()
+                sage: expected = Qy*x.quadratic_representation()*Qy
+                sage: actual == expected
+                True
+
+            Property 6:
+
+                sage: k = ZZ.random_element(1,10).abs()
+                sage: actual = (x^k).quadratic_representation()
+                sage: expected = (x.quadratic_representation())^k
+                sage: actual == expected
+                True
+
             """
-            return 2*(self.matrix()**2) - (self**2).matrix()
+            if other is None:
+                other=self
+            elif not other in self.parent():
+                raise ArgumentError("'other' must live in the same algebra")
+
+            return ( self.matrix()*other.matrix()
+                       + other.matrix()*self.matrix()
+                       - (self*other).matrix() )
 
 
         def span_of_powers(self):