eigenvalues of a derivative vs derivative of eigenvalues

Hi! I have this little problem. If anyone would be so kind to share his knowledge and shed some lite on it, I'd be very grateful. Big thanks in advance (and sorry for my english)!

I have a matrix M=M(x) depending on a variable x. I want sage to compute trace of a product of a derivative of M, M' and some function of it, f(M), at a fixed value of x=x_0; that is:

(tr[M'*f(M)])|_(x=x_0).

It just so happens that tr[M'*f(M)] = sum( ev_i' *f(ev_i) ), where {ev_i(x)} are eigenvalues of M. Lucky me. Diagonalisation of M commutes with differentiating or taking the function of it, one could say.

But my M and its derivative are somewhat complicated, yet simplify greatly after substituting x=x_0. So I would very much prefer first to compute M', substitute x_0 M0:=M|_(x=x_0) and M'0:=M'|_(x=x_0), and only after that ask sage for eigenvalues:

ev1=M0.eigenvalues()

ev2=M'0.eigenvalues()

So here's the question: do i have any reason for hoping that:

(tr[M'*f(M)])|_(x=x_0) = sum( ev2[i] *f(ev1[i]) for i in range(dim of M) )?

(That is, wether the order of eigenvalues changes if I exchange diagonalisation with differentiation?)

edit retag close merge delete

Sort by » oldest newest most voted

You can take the derivative of a matrix and substitute x=x0 using apply_map

ev1=M0.eigenvalues()

ev2=(M0.apply_map(lambda y:y.diff(x).subs(x==x0))).eigenvalues()


This takes the derivatives of all the components of M0, substitutes x=x0 and then calculates the eigenvalues of the resulting matrix.

more

Well, ok; thank you for that comment. In order to differentiate, I was planning on typing something much-less-fancy, like to loops with dM[i,j]=diff(M[i,j], x). But what about my question? Again, sorry for my lack of narrative competence. I came up with an example:

( 2012-11-17 13:21:42 -0500 )edit

var('x'); M=Matrix(SR, 2,2, [0, cos(x), cos(x), 0]); dM=Matrix(SR, 2,2); for i in range(2): for j in range(2): dM[i,j]=diff(M[i,j], x); dM.eigenvalues() == [diff(M.eigenvalues()[1], x), diff(M.eigenvalues()[0], x)] (dM*M).trace() == dM.eigenvalues()[0]*M.eigenvalues()[1] + dM.eigenvalues()[1]*M.eigenvalues()[0] #and not: (dM *M).trace() =/= dM.eigenvalues()[0]*M.eigenvalues()[0] + dM.eigenvalues()[1]*M.eigenvalues()[1] #as I was hoping for

( 2012-11-17 13:26:43 -0500 )edit

Is there any way of knowing in what order put the eigenvalues of derivative to get correct trace?

( 2012-11-17 13:31:19 -0500 )edit