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
"""
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
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
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)
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,
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
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
where there are non-nilpotent elements, or that we get the dumb
solution in the trivial algebra::
- sage: J = random_eja()
+ sage: J = random_eja(field=QQ, orthonormalize=False)
sage: x = J.random_element()
sage: while x.is_nilpotent() and not J.is_trivial():
....: x = J.random_element()