thanks Bob, but I still have the "same" problem in my full code example - so it is looking like a rewrite is the answer(?)
A better description of the function I am trying to integrate is:
f1[x_?NumericQ, anOtherObject_]:=Module[{res},
res=Position[{1,3,5,7,9,Infinity},y_/;y>=x,Infinity,1][1,1]];
{res,Length[anOtherObject]}
]
i.e. it is a function with 2 useful outputs in list form
Now, when I try to integrate the first output using:
NIntegrate[f1[i, m][[1]], {i, 0, 7}, MaxRecursion ->
15, WorkingPrecision -> 25]
I get a numerical answer, but it is wrong: 24.5 not 19!
What I think is happening is:
f1[4,{a,b,c}][[1]] gives 3 as expected
BUT
f1[i,{a,b,c}][[1]] gives "i" because Mathematica does not have a definition for this function with the "i" as input. It returns the first element of "f1[i,{a,b,c}]" , which is "i".
This "i" can then be resolved by the NIntegrate function to give me the answer I was not expecting - ouch!
So I still have the original problem I think, in that NIntegrate is not resolving the "i" to a number at an early enough stage. You fixed my problem for functions that return a single variable, (although I'm not sure really why this works), but I still have the problem when my function returns a list.
Can anyone have another go?