0
$\begingroup$

Define a matrix and a function as

h[y_] := {{101, 2 (1 + E^(-I) + E^(-I* y) + E^(-I* (1 + y)))}, {2 (1 + E^I + E^(I *y) +E^(I* (1 + y))), 1}};

htest[y_] := N[Block[{e, f}, {e, f} = Eigensystem[h[y]]; {e, f} = {e[[#]], f[[#]]} &@Ordering[N[Re[e]]];Return[{Re[e], f}]]] 

So, by htest[y], we should get an ordered eigensystems for matrix h[y]. For instance, h[1][[1]] gives you {0.621825, 101.378}, but h[x][[1]]/.x->1 gives you {101.378, 0.621825}, whose first element isn't the smaller one.

When I try to calculate some integrals, say the integral of the smaller eigenvalue:

NIntegrate[htest[x][[1]][[1]], {x, 0, 2}]

you will get 145.07. It's not th result from smaller eigenvalue but from h[y][[1]][[1]]/.y->x. Actually, you can

Plot[htest[x][[1]][[1]], {x, 0, 2}]
Plot[htest[x][[1]][[1]] /. x -> y, {y, 0, 2}]

to see the difference. So, my problem is how can I integrate the smaller eigenvalues by using NIntegrate?

$\endgroup$
  • $\begingroup$ When editing, use the little question mark icon for help - readability can make the difference between getting answers and not... $\endgroup$ – ciao Mar 16 '15 at 7:33
  • $\begingroup$ Perhaps define your integrand as f[x_?NumericQ] := htest[x][[1]][[1]]? See mathematica.stackexchange.com/questions/18393/… $\endgroup$ – Michael E2 Mar 17 '15 at 0:53
  • $\begingroup$ Excellent. Thanks for your help. I think that's the right approach to solve this problem. $\endgroup$ – Simon Mar 17 '15 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.