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?
f[x_?NumericQ] := htest[x][[1]][[1]]? See http://mathematica.stackexchange.com/questions/18393/what-are-the-most-common-pitfalls-awaiting-new-users/26037#26037 – Michael E2 Mar 17 '15 at 00:53