(Restated using code lines.) If one defines a function containing a numerical integral inside a sum,
sumnint[T_] :=
Sum[cn[n] NIntegrate[
Exp[- an[n] x T] /. {an[1] -> 1.0`, an[2] -> 2.0`}, {x,
0, \[Infinity]}], {n, 1, 2}] /. {cn[1] -> 1.0`, cn[2] -> 2.0`}
then the following attempt to send the function the value for T of 1
sumnint[T] /. T -> 1
yields an unevaluated integral as output,
3. NIntegrate[
Exp[-an[n] x] /. {an[1] -> 1., an[2] -> 2.}, {x, 0, \[Infinity]}]
though the T in the integral is replaced by 1.
On the other hand, simply copying the 1 into the argument
sumnint[1]
gives a fully evaluated result, 2. (Analytic integration gives cn[1]/an[1] + cn[2]/an[2], I.S.Gradshteyn and I.M.Ryzhik,Table of Integrals,Series,and Products \ 5ed (Academic,New York,1994),p.732,No.3.351.3.)
However, if the sum is inside the numerical integral, this problem does not appear:
nintsum[T_] :=
NIntegrate[
Sum[cn[n] Exp[- an[n] x T] /. {an[1] -> 1.0`, an[2] -> 2.0`}, {n, 1,
2}] /. {cn[1] -> 1.0`, cn[2] -> 2.0`}, {x, 0, \[Infinity]}]
followed by
nintsum[T] /. T -> 1
gives a gives a fully evaluated result, 2.
This is a simple example of a much more complicated, deeply nested integral I am doing in which I will want to substitute a whole series of values of variables like T for which the /. evaluation form is much easier for my purposes than copying and pasting values into a function variable list. Can you see a way to get the numerical integral to evaluate even when calling it using
sumnint[T] /. T -> 1
?