Sorted list of symbolic eigenvalues (and corresponding eigenvectors)

asked 2012-12-03 07:08:01 -0500

Dem gravatar image

updated 2012-12-03 07:59:12 -0500

kcrisman gravatar image

Is there a way to obtain a sorted list of eigenvalues when they are computed symbolically (in SR). Particularly knowing that in specific points, they can switch order.

So far, what I have is (assuming $R^3$):

def sorted_eval(m, x, y, z, order=0):
    _ev = m.eigenvalues()
    _ev = numpy.array(ev.subs(x=x, y=y, z=z))
    return _ev[order]

But then if I want to perform a contour plot:

x, y, z = var('x y z')
p = vector([x,y,z])
f = p * p
h = f.hessian()
contour(lambda x, y: sorted_eval(h, x, y, 0, 0), (x, -1.5, 1.5), (y, -1.5, 1.5))

It takes a long time Thanks D

edit retag flag offensive close merge delete



If the eigenvalues were truly symbolic, what ordering would you put on them?

kcrisman gravatar imagekcrisman ( 2012-12-03 07:58:19 -0500 )edit

Also, in this particular case `h` is 2 times the identity matrix... and what is `ev` (maybe from numpy?) and you didn't import numpy... Given the number of other typos, I suspect you had a slightly more complicated setup in mind. Feel free to edit with the *exact* code you used, and we'll give it another shot! :-)

kcrisman gravatar imagekcrisman ( 2012-12-03 08:01:35 -0500 )edit