- sage: Qxy(J.one()) == x*y
- True
-
- Property 4:
-
- sage: not x.is_invertible() or (
- ....: x.quadratic_representation(x.inverse())*Qx
- ....: == Qx*x.quadratic_representation(x.inverse()) )
- True
-
- sage: not x.is_invertible() or (
- ....: x.quadratic_representation(x.inverse())*Qx
- ....: ==
- ....: 2*x.operator()*Qex - Qx )
- True
-
- sage: 2*x.operator()*Qex - Qx == Lxx
- True
-
- Property 5:
-
- sage: Qy(x).quadratic_representation() == Qy*Qx*Qy
- True
-
- Property 6:
-
- sage: Qxn == (Qx)^n
- True
-
- Property 7:
-
- sage: not x.is_invertible() or (
- ....: Qx*x.inverse().operator() == Lx )
- True
-
- Property 8:
-
- sage: not x.operator_commutes_with(y) or (
- ....: Qx(y)^n == Qxn(y^n) )
- True
-
- """
- if other is None:
- other=self
- elif not other in self.parent():
- raise TypeError("'other' must live in the same algebra")
-
- L = self.operator()
- M = other.operator()
- return ( L*M + M*L - (self*other).operator() )
-
-
- def span_of_powers(self):
- """
- Return the vector space spanned by successive powers of
- this element.
- """
- # The dimension of the subalgebra can't be greater than
- # the big algebra, so just put everything into a list
- # and let span() get rid of the excess.
- #
- # We do the extra ambient_vector_space() in case we're messing
- # with polynomials and the direct parent is a module.
- V = self.parent().vector_space()
- return V.span( (self**d).vector() for d in xrange(V.dimension()) )
-
-
- def subalgebra_generated_by(self):
- """
- Return the associative subalgebra of the parent EJA generated
- by this element.
-
- SETUP::
-
- sage: from mjo.eja.eja_algebra import random_eja
-
- TESTS::
-
- sage: set_random_seed()
- sage: x = random_eja().random_element()
- sage: x.subalgebra_generated_by().is_associative()
- True
-
- Squaring in the subalgebra should work the same as in
- the superalgebra::
-
- sage: set_random_seed()
- sage: x = random_eja().random_element()
- sage: u = x.subalgebra_generated_by().random_element()
- sage: u.operator()(u) == u^2
- True
-
- """
- # First get the subspace spanned by the powers of myself...
- V = self.span_of_powers()
- F = self.base_ring()
-
- # Now figure out the entries of the right-multiplication
- # matrix for the successive basis elements b0, b1,... of
- # that subspace.
- mats = []
- for b_right in V.basis():
- eja_b_right = self.parent()(b_right)
- b_right_rows = []
- # The first row of the right-multiplication matrix by
- # b1 is what we get if we apply that matrix to b1. The
- # second row of the right multiplication matrix by b1
- # is what we get when we apply that matrix to b2...
- #
- # IMPORTANT: this assumes that all vectors are COLUMN
- # vectors, unlike our superclass (which uses row vectors).
- for b_left in V.basis():
- eja_b_left = self.parent()(b_left)
- # Multiply in the original EJA, but then get the
- # coordinates from the subalgebra in terms of its
- # basis.
- this_row = V.coordinates((eja_b_left*eja_b_right).vector())
- b_right_rows.append(this_row)
- b_right_matrix = matrix(F, b_right_rows)
- mats.append(b_right_matrix)
-
- # It's an algebra of polynomials in one element, and EJAs
- # are power-associative.
- #
- # TODO: choose generator names intelligently.
- #
- # The rank is the highest possible degree of a minimal polynomial,
- # and is bounded above by the dimension. We know in this case that
- # there's an element whose minimal polynomial has the same degree
- # as the space's dimension, so that must be its rank too.
- return FiniteDimensionalEuclideanJordanAlgebra(
- F,
- mats,
- V.dimension(),
- assume_associative=True,
- names='f')
-
-
- def subalgebra_idempotent(self):
- """
- Find an idempotent in the associative subalgebra I generate
- using Proposition 2.3.5 in Baes.
-
- SETUP::
-
- sage: from mjo.eja.eja_algebra import random_eja
-
- TESTS::
-
- sage: set_random_seed()
- sage: J = random_eja()
- sage: x = J.random_element()
- sage: while x.is_nilpotent():
- ....: x = J.random_element()
- sage: c = x.subalgebra_idempotent()
- sage: c^2 == c
- True
-
- """
- if self.is_nilpotent():
- raise ValueError("this only works with non-nilpotent elements!")
-
- V = self.span_of_powers()
- J = self.subalgebra_generated_by()
- # Mis-design warning: the basis used for span_of_powers()
- # and subalgebra_generated_by() must be the same, and in
- # the same order!
- u = J(V.coordinates(self.vector()))
-
- # The image of the matrix of left-u^m-multiplication
- # will be minimal for some natural number s...
- s = 0
- minimal_dim = V.dimension()
- for i in xrange(1, V.dimension()):
- this_dim = (u**i).operator().matrix().image().dimension()
- if this_dim < minimal_dim:
- minimal_dim = this_dim
- s = i
-
- # Now minimal_matrix should correspond to the smallest
- # non-zero subspace in Baes's (or really, Koecher's)
- # proposition.
- #
- # However, we need to restrict the matrix to work on the
- # subspace... or do we? Can't we just solve, knowing that
- # A(c) = u^(s+1) should have a solution in the big space,
- # too?
- #
- # Beware, solve_right() means that we're using COLUMN vectors.
- # Our FiniteDimensionalAlgebraElement superclass uses rows.
- u_next = u**(s+1)
- A = u_next.operator().matrix()
- c_coordinates = A.solve_right(u_next.vector())
-
- # Now c_coordinates is the idempotent we want, but it's in
- # the coordinate system of the subalgebra.
- #
- # We need the basis for J, but as elements of the parent algebra.
- #
- basis = [self.parent(v) for v in V.basis()]
- return self.parent().linear_combination(zip(c_coordinates, basis))
-
-
- def trace(self):
- """
- Return my trace, the sum of my eigenvalues.
-
- SETUP::
-
- sage: from mjo.eja.eja_algebra import (JordanSpinEJA,
- ....: RealCartesianProductEJA,
- ....: random_eja)
-
- EXAMPLES::
-
- sage: J = JordanSpinEJA(3)
- sage: x = sum(J.gens())
- sage: x.trace()
- 2
-
- ::
-
- sage: J = RealCartesianProductEJA(5)
- sage: J.one().trace()
- 5
-
- TESTS:
-
- The trace of an element is a real number::
-
- sage: set_random_seed()
- sage: J = random_eja()
- sage: J.random_element().trace() in J.base_ring()
- True
-
- """
- P = self.parent()
- r = P.rank()
- p = P._charpoly_coeff(r-1)
- # The _charpoly_coeff function already adds the factor of
- # -1 to ensure that _charpoly_coeff(r-1) is really what
- # appears in front of t^{r-1} in the charpoly. However,
- # we want the negative of THAT for the trace.
- return -p(*self.vector())
-
-
- def trace_inner_product(self, other):
- """
- Return the trace inner product of myself and ``other``.
-
- SETUP::
-
- sage: from mjo.eja.eja_algebra import random_eja
-
- TESTS:
-
- The trace inner product is commutative::
-
- sage: set_random_seed()
- sage: J = random_eja()
- sage: x = J.random_element(); y = J.random_element()
- sage: x.trace_inner_product(y) == y.trace_inner_product(x)
- True
-
- The trace inner product is bilinear::
-
- sage: set_random_seed()
- sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
- sage: z = J.random_element()
- sage: a = QQ.random_element();
- sage: actual = (a*(x+z)).trace_inner_product(y)
- sage: expected = ( a*x.trace_inner_product(y) +
- ....: a*z.trace_inner_product(y) )
- sage: actual == expected
- True
- sage: actual = x.trace_inner_product(a*(y+z))
- sage: expected = ( a*x.trace_inner_product(y) +
- ....: a*x.trace_inner_product(z) )
- sage: actual == expected
- True
-
- The trace inner product satisfies the compatibility
- condition in the definition of a Euclidean Jordan algebra::
-
- sage: set_random_seed()
- sage: J = random_eja()
- sage: x = J.random_element()
- sage: y = J.random_element()
- sage: z = J.random_element()
- sage: (x*y).trace_inner_product(z) == y.trace_inner_product(x*z)
- True