def characteristic_polynomial(self):
"""
- Return my characteristic polynomial (if I'm a regular
- element).
+ Return the characteristic polynomial of this element.
+
+ EXAMPLES:
+
+ The rank of `R^3` is three, and the minimal polynomial of
+ the identity element is `(t-1)` from which it follows that
+ the characteristic polynomial should be `(t-1)^3`::
+
+ sage: J = RealCartesianProductEJA(3)
+ sage: J.one().characteristic_polynomial()
+ t^3 - 3*t^2 + 3*t - 1
+
+ Likewise, the characteristic of the zero element in the
+ rank-three algebra `R^{n}` should be `t^{3}`::
+
+ sage: J = RealCartesianProductEJA(3)
+ sage: J.zero().characteristic_polynomial()
+ t^3
+
+ The characteristic polynomial of an element should evaluate
+ to zero on that element::
+
+ sage: set_random_seed()
+ sage: x = RealCartesianProductEJA(3).random_element()
+ sage: p = x.characteristic_polynomial()
+ sage: x.apply_univariate_polynomial(p)
+ 0
- Eventually this should be implemented in terms of the parent
- algebra's characteristic polynomial that works for ALL
- elements.
"""
- if self.is_regular():
- return self.minimal_polynomial()
- else:
- raise NotImplementedError('irregular element')
+ p = self.parent().characteristic_polynomial()
+ return p(*self.vector())
def inner_product(self, other):