From 90738291f084c62d009a51bba56346a83f88f950 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 22 Jul 2019 16:38:37 -0400 Subject: [PATCH] eja: add apply_univariate_polynomial() for elements and use it in a test. --- mjo/eja/euclidean_jordan_algebra.py | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/mjo/eja/euclidean_jordan_algebra.py b/mjo/eja/euclidean_jordan_algebra.py index c4b0850..da1145d 100644 --- a/mjo/eja/euclidean_jordan_algebra.py +++ b/mjo/eja/euclidean_jordan_algebra.py @@ -315,6 +315,49 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): return A( (self.operator_matrix()**(n-1))*self.vector() ) + def apply_univariate_polynomial(self, p): + """ + Apply the univariate polynomial ``p`` to this element. + + A priori, SageMath won't allow us to apply a univariate + polynomial to an element of an EJA, because we don't know + that EJAs are rings (they are usually not associative). Of + course, we know that EJAs are power-associative, so the + operation is ultimately kosher. This function sidesteps + the CAS to get the answer we want and expect. + + EXAMPLES:: + + sage: R = PolynomialRing(QQ, 't') + sage: t = R.gen(0) + sage: p = t^4 - t^3 + 5*t - 2 + sage: J = RealCartesianProductEJA(5) + sage: J.one().apply_univariate_polynomial(p) == 3*J.one() + True + + TESTS: + + We should always get back an element of the algebra:: + + sage: set_random_seed() + sage: p = PolynomialRing(QQ, 't').random_element() + sage: J = random_eja() + sage: x = J.random_element() + sage: x.apply_univariate_polynomial(p) in J + True + + """ + if len(p.variables()) > 1: + raise ValueError("not a univariate polynomial") + P = self.parent() + R = P.base_ring() + # Convert the coeficcients to the parent's base ring, + # because a priori they might live in an (unnecessarily) + # larger ring for which P.sum() would fail below. + cs = [ R(c) for c in p.coefficients(sparse=False) ] + return P.sum( cs[k]*(self**k) for k in range(len(cs)) ) + + def characteristic_polynomial(self): """ Return my characteristic polynomial (if I'm a regular @@ -724,6 +767,14 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: bool(actual == expected) True + The minimal polynomial should always kill its element:: + + sage: set_random_seed() + sage: x = random_eja().random_element() + sage: p = x.minimal_polynomial() + sage: x.apply_univariate_polynomial(p) + 0 + """ V = self.span_of_powers() assoc_subalg = self.subalgebra_generated_by() -- 2.44.2