# Evaluation order of NIntegrate

F[y_?NumericQ] := Eigenvectors@( {
{1, y},
{y, 1}
} );
G[x_?NumericQ] := NIntegrate[F[y][].F[y][], {y, 0, 2}];
G


The program simply doesn't work in this way. Changing y_?NumericQ to y_ doesn't help since then the Eigenvectors would be evaluated in symbolic method (which I don't want). How can it be solved?

• Your function for G[x] does not have x on the right hand side. I doubt this was intended. Oct 17 '16 at 4:35
• The point is the following: Sometimes, F is a complicated function that ends with a list of, say, 3 numbers (and that ?NumericQ is a must for some function (say function involving ordering)). Then G evaluate the integral of that function. But the mathematica simply doesn't work for ?NumericQ trick when your function ends with several numbers, so you must do it separately and ends with multiple evaluation times :P Oct 25 '16 at 4:44

F[y_?NumericQ] := Eigenvectors@({{1, y}, {y, 1}});
H[y_?NumericQ] := F[y][].F[y][];
G[x_?NumericQ] := NIntegrate[H[y], {y, 0, 2}];
G
(*2*)


The problem with your previous code was that NIntegrate tried to evaluate its argument symbolically first. So it tried evaluating:

F[y][].F[y][]
(*y.y*)


This returns y.y because F[y] had no definitions when y is a symbol. So F[y][] evaluates to y (which is the first part of the expression F[y])

(By the way, you should avoid starting your function names with capital letters)

• Just a side note, now ?NumericQ is no longer needed in F :) Oct 17 '16 at 6:49
• That function isn't really needed :) H[y_?NumericQ] := #.# &@Eigenvectors[{{1, y}, {y, 1}}][] Oct 17 '16 at 17:08
• ic, thanks for the answer~ Oct 25 '16 at 9:49