if self.is_regular():
return self.minimal_polynomial()
else:
- return NotImplementedError('irregular element')
+ raise NotImplementedError('irregular element')
+
+
+ def det(self):
+ """
+ Return my determinant, the product of my eigenvalues.
+
+ EXAMPLES::
+
+ sage: J = eja_ln(2)
+ sage: e0,e1 = J.gens()
+ sage: x = e0 + e1
+ sage: x.det()
+ 0
+ sage: J = eja_ln(3)
+ sage: e0,e1,e2 = J.gens()
+ sage: x = e0 + e1 + e2
+ sage: x.det()
+ -1
+
+ """
+ cs = self.characteristic_polynomial().coefficients(sparse=False)
+ r = len(cs) - 1
+ if r >= 0:
+ return cs[0] * (-1)**r
+ else:
+ raise ValueError('charpoly had no coefficients')
def is_nilpotent(self):
return self.parent().linear_combination(zip(c_coordinates, basis))
+ def trace(self):
+ """
+ Return my trace, the sum of my eigenvalues.
+
+ EXAMPLES::
+
+ sage: J = eja_ln(3)
+ sage: e0,e1,e2 = J.gens()
+ sage: x = e0 + e1 + e2
+ sage: x.trace()
+ 2
+
+ """
+ cs = self.characteristic_polynomial().coefficients(sparse=False)
+ if len(cs) >= 2:
+ return -1*cs[-2]
+ else:
+ raise ValueError('charpoly had fewer than 2 coefficients')
+
def eja_rn(dimension, field=QQ):
"""