# simplify flag doesn't work for eigenvals/eigenvects #15118

Open
opened this issue Aug 21, 2018 · 0 comments
Labels

 Reported on Gitter: https://gitter.im/sympy/sympy?at=5b7c3e8ee5b40332abdb206c ```>>> q = symbols("q", positive=True) >>> m = Matrix([[-2, exp(-q), 1], [exp(q), -2, 1], [1, 1, -2]]) >>> m.eigenvals() {(-1/2 + sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + 1/((-1/2 + sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3)): 1, (sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + (sqrt(cosh(q)**2 - 1) + cosh(q))**(-1/3): 1, (-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + 1/((-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3)): 1} >>> m.eigenvals(simplify=True) {(-1/2 + sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + 1/((-1/2 + sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3)): 1, (sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + (sqrt(cosh(q)**2 - 1) + cosh(q))**(-1/3): 1, (-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + 1/((-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3)): 1} >>> simplify(list(m.eigenvals())[0]) (sqrt(3)*I*(exp(q/3) + 2) + exp(q/3) - 2 - 2*exp(-q/3))/(1 - sqrt(3)*I)``` I think it might be the cause of being unable to compute eigenvectors ```>>> m.eigenvects() Traceback (most recent call last): File "", line 1, in File "./sympy/matrices/matrices.py", line 1207, in eigenvects sorted(eigenvals.items(), key=default_sort_key)] File "./sympy/matrices/matrices.py", line 1206, in ret = [(val, mult, eigenspace(val)) for val, mult in File "./sympy/matrices/matrices.py", line 1200, in eigenspace "Can't evaluate eigenvector for eigenvalue %s" % eigenval) NotImplementedError: Can't evaluate eigenvector for eigenvalue (-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + 1/((-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3)) >>> m.eigenvects(simplify=True) Traceback (most recent call last): File "", line 1, in File "./sympy/matrices/matrices.py", line 1207, in eigenvects sorted(eigenvals.items(), key=default_sort_key)] File "./sympy/matrices/matrices.py", line 1206, in ret = [(val, mult, eigenspace(val)) for val, mult in File "./sympy/matrices/matrices.py", line 1200, in eigenspace "Can't evaluate eigenvector for eigenvalue %s" % eigenval) NotImplementedError: Can't evaluate eigenvector for eigenvalue (-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3) - 2 + 1/((-1/2 - sqrt(3)*I/2)*(sqrt(cosh(q)**2 - 1) + cosh(q))**(1/3))``` You can see from the error message that it isn't being simplified (on a related note, it's bad practice to put `str(expr)` in error messages, as they can often be large and slow to compute).