X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo%2Feja%2Feja_element.py;h=bc253d48653c40bddb3180e083daf6b61e9f3dac;hb=0994b65cf76ca376d07d5c3e4c80fc378a3aead7;hp=0fd1c5f2032151de7d752494b4117825af3109a3;hpb=928b7d49fda98ff105c92293b5797bb7a2b9873a;p=sage.d.git diff --git a/mjo/eja/eja_element.py b/mjo/eja/eja_element.py index 0fd1c5f..bc253d4 100644 --- a/mjo/eja/eja_element.py +++ b/mjo/eja/eja_element.py @@ -289,30 +289,32 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): Test the second polarization identity from my notes or from Baes (2.4):: - sage: x,y,z = random_eja().random_elements(3) - sage: Lx = x.operator() - sage: Ly = y.operator() - sage: Lz = z.operator() - sage: Lzy = (z*y).operator() - sage: Lxy = (x*y).operator() - sage: Lxz = (x*z).operator() - sage: bool(Lx*Lzy + Lz*Lxy + Ly*Lxz == Lzy*Lx + Lxy*Lz + Lxz*Ly) + sage: x,y,z = random_eja().random_elements(3) # long time + sage: Lx = x.operator() # long time + sage: Ly = y.operator() # long time + sage: Lz = z.operator() # long time + sage: Lzy = (z*y).operator() # long time + sage: Lxy = (x*y).operator() # long time + sage: Lxz = (x*z).operator() # long time + sage: lhs = Lx*Lzy + Lz*Lxy + Ly*Lxz # long time + sage: rhs = Lzy*Lx + Lxy*Lz + Lxz*Ly # long time + sage: bool(lhs == rhs) # long time True Test the third polarization identity from my notes or from Baes (2.5):: - sage: u,y,z = random_eja().random_elements(3) - sage: Lu = u.operator() - sage: Ly = y.operator() - sage: Lz = z.operator() - sage: Lzy = (z*y).operator() - sage: Luy = (u*y).operator() - sage: Luz = (u*z).operator() - sage: Luyz = (u*(y*z)).operator() - sage: lhs = Lu*Lzy + Lz*Luy + Ly*Luz - sage: rhs = Luyz + Ly*Lu*Lz + Lz*Lu*Ly - sage: bool(lhs == rhs) + sage: u,y,z = random_eja().random_elements(3) # long time + sage: Lu = u.operator() # long time + sage: Ly = y.operator() # long time + sage: Lz = z.operator() # long time + sage: Lzy = (z*y).operator() # long time + sage: Luy = (u*y).operator() # long time + sage: Luz = (u*z).operator() # long time + sage: Luyz = (u*(y*z)).operator() # long time + sage: lhs = Lu*Lzy + Lz*Luy + Ly*Luz # long time + sage: rhs = Luyz + Ly*Lu*Lz + Lz*Lu*Ly # long time + sage: bool(lhs == rhs) # long time True """ @@ -373,7 +375,8 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): Ensure that the determinant is multiplicative on an associative subalgebra as in Faraut and Korányi's Proposition II.2.2:: - sage: J = random_eja().random_element().subalgebra_generated_by() + sage: x0 = random_eja().random_element() + sage: J = x0.subalgebra_generated_by(orthonormalize=False) sage: x,y = J.random_elements(2) sage: (x*y).det() == x.det()*y.det() True @@ -482,10 +485,12 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): of an element is the inverse of its left-multiplication operator applied to the algebra's identity, when that inverse exists:: - sage: J = random_eja() - sage: x = J.random_element() - sage: (not x.operator().is_invertible()) or ( - ....: x.operator().inverse()(J.one()) == x.inverse() ) + sage: J = random_eja() # long time + sage: x = J.random_element() # long time + sage: (not x.operator().is_invertible()) or ( # long time + ....: x.operator().inverse()(J.one()) # long time + ....: == # long time + ....: x.inverse() ) # long time True Check that the fast (cached) and slow algorithms give the same @@ -502,15 +507,18 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): True """ not_invertible_msg = "element is not invertible" - if self.parent()._charpoly_coefficients.is_in_cache(): + + algebra = self.parent() + if algebra._charpoly_coefficients.is_in_cache(): # We can invert using our charpoly if it will be fast to # compute. If the coefficients are cached, our rank had # better be too! if self.det().is_zero(): raise ZeroDivisionError(not_invertible_msg) - r = self.parent().rank() + r = algebra.rank() a = self.characteristic_polynomial().coefficients(sparse=False) - return (-1)**(r+1)*sum(a[i+1]*self**i for i in range(r))/self.det() + return (-1)**(r+1)*algebra.sum(a[i+1]*self**i + for i in range(r))/self.det() try: inv = (~self.quadratic_representation())(self) @@ -974,9 +982,9 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): The minimal polynomial should always kill its element:: - sage: x = random_eja().random_element() - sage: p = x.minimal_polynomial() - sage: x.apply_univariate_polynomial(p) + sage: x = random_eja().random_element() # long time + sage: p = x.minimal_polynomial() # long time + sage: x.apply_univariate_polynomial(p) # long time 0 The minimal polynomial is invariant under a change of basis, @@ -1369,7 +1377,7 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): This subalgebra, being composed of only powers, is associative:: sage: x0 = random_eja().random_element() - sage: A = x0.subalgebra_generated_by() + sage: A = x0.subalgebra_generated_by(orthonormalize=False) sage: x,y,z = A.random_elements(3) sage: (x*y)*z == x*(y*z) True @@ -1378,7 +1386,7 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): the superalgebra:: sage: x = random_eja().random_element() - sage: A = x.subalgebra_generated_by() + sage: A = x.subalgebra_generated_by(orthonormalize=False) sage: A(x^2) == A(x)*A(x) True @@ -1512,6 +1520,12 @@ class FiniteDimensionalEJAElement(IndexedFreeModuleElement): sage: (alpha*x + y).trace() == alpha*x.trace() + y.trace() True + The trace of a square is nonnegative:: + + sage: x = random_eja().random_element() + sage: (x*x).trace() >= 0 + True + """ P = self.parent() r = P.rank()