Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

@asmeurer
Copy link
Member

@asmeurer asmeurer commented Aug 21, 2018

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 "<stdin>", line 1, in <module>
  File "./sympy/matrices/matrices.py", line 1207, in eigenvects
    sorted(eigenvals.items(), key=default_sort_key)]
  File "./sympy/matrices/matrices.py", line 1206, in <listcomp>
    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 "<stdin>", line 1, in <module>
  File "./sympy/matrices/matrices.py", line 1207, in eigenvects
    sorted(eigenvals.items(), key=default_sort_key)]
  File "./sympy/matrices/matrices.py", line 1206, in <listcomp>
    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.