Hi Rene,
Here is what I meant by restricting the argument of the integrand to a numerical value. Now when NIntegrate evaluates it symbolically, it just gets the function back as the result, just like we would if we gave integrand[arg] a non-numerical argument. So then NIntegrate just proceeds to numerical computation with the function we've given it. It's good that NIntegrate behaves this way, because it allows it to adapt its strategy to the function, for example if it is piecewise, it knows to allow for discontinuity in choosing integration segments. But is does generate this issue when the argument it's given cannot be symbolically evaluated.
In[1]:= pe = 25.; \[Epsilon] = 1.0/pe; psitrans = Sqrt[2./3.];
r[y_] := Sqrt[1 + y^2];
psifct[y_] := (y^2/2)*(1 - 3/(2 r[y]) + 1/(2 r[y]^3));
rhoapp[y_] := If[y < psitrans, (16*y/3)^(1/6), Sqrt[2 y]] // N;
\[Psi][y_] := \[Epsilon]*y;
In[6]:= (* integrand[arg] is only defined for numerical arg *)
(* psiv,rhoappv,sol are localized within Module *)
integrand[psiprime_?NumberQ] := Module[{psiv, rhoappv, sol},
psiv = \[Psi][psiprime];
rhoappv = rhoapp[psiv];
sol = FindRoot[psifct[x] - psiv == 0, {x, rhoappv}];
rhoprime = x /. sol;
Exp[-rhoprime]
]
In[7]:= integrand[a]
Out[7]= integrand[a]
In[8]:= integrand[10]
Out[8]= 0.191518
In[9]:= (* So NIntegrate will not attempt to evaluate it symbolically *)
(* edit -- it does attempt it, but gets the unevaluated function back, as stated above *)
\
(* note that my use of psiprime for both the formal argument and the \
argument variable is for readability -- they are not related *)
NIntegrate[integrand[psiprime], {psiprime, 0, 1000}]
Out[9]= 11.6287