I need help overcoming a peculiarity in Mathematica (7 and 9) in which a function containing a numerical integral inside a sum does not access a function variable. If I define
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
sumnint[T] /. T -> 1
yields an unevaluated result
NIntegrate[ Exp[-an[n] x] /. {an[1] -> 1., an[2] -> 2.}, {x, 0, [Infinity]}]
although
sumnint[1]
properly yields
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.)*
But if I reverse the order of summation and integration I get the evaluated answer. For
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]}]
nintsum[T] /. T -> 1
gives
2.
This is a simple example of a much more complicated 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 the function variable list. Can you see a workaround?