'Computes characteristic polynomial det(x*I - self) where I is
the identity matrix.
A PurePoly is returned, so using different variables for ``x`` does
not affect the comparison or the polynomials:
Examples
>>> from sympy import Matrix
>>> from sympy.abc import x, y
>>> A = Matrix([[1, 3], [2, 0]])
>>> A.charpoly(x) == A.charpoly(y)
True
Specifying ``x`` is optional; a Dummy with name ``lambda`` is used by
default (which looks good when pretty-printed in unicode):
>>> A.charpoly().as_expr()
_lambda**2 - _lambda - 6
No test is done to see that ``x`` doesn\'t clash with an existing
symbol, so using the default (``lambda``) or your own Dummy symbol is
the safest option:
>>> A = Matrix([[1, 2], [x, 0]])
>>> A.charpoly().as_expr()
_lambda**2 - _lambda - 2*x
>>> A.charpoly(x).as_expr()
x**2 - 3*x
Notes
The Samuelson-Berkowitz algorithm is used to compute
the characteristic polynomial efficiently and without any
division operations.  Thus the characteristic polynomial over any
commutative ring without zero divisors can be computed.
See Also
det'

def charpoly(self, x=Dummy('lambda'), simplify=_simplify):

    if (self.rows != self.cols):
        raise NonSquareMatrixError()
    berk_vector = self._eval_berkowitz_vector()
    return PurePoly([simplify(a) for a in berk_vector], x)
