Consider the following function with a numerical integration:
BDMAF[n_, \[Gamma]_, x_, c_] :=
Module[{K1 = EllipticK[1/Sqrt[1 + \[Gamma]^2]],
E1 = EllipticE[1/Sqrt[1 + \[Gamma]^2]], y0},
y0 = ((\[Pi]^2 (IntegerPart[x + 1] - x + n))/(2 K1 E1))^(1/2);
Exp[-y0^2] NIntegrate[
Exp[y^2] Sin[(n + IntegerPart[x + 1])/2 \[Pi] + c y]^2, {y, 0, y0}]
]
that works perfectly if all parameters are explicitly defined:
BDMAF[1, 1, 1, 1]
0.0391914
I need to calculate the infinite sum over n. Naive approach gives
NSum[BDMAF[n, 1, 1, 1], {n, 0, \[Infinity]}]
NIntegrate::nlim: y = 1.38268 Sqrt[1. +n] is not a valid limit of integration. >>
Following the answer to the question about nested NIntegrate, I tried to redefine BDMAF as follows:
BDMAF[n_?NumericQ, \[Gamma]_, x_, c_] := BDMAF[n, \[Gamma], x, c] =
Module[{K1 = EllipticK[1/Sqrt[1 + \[Gamma]^2]],
E1 = EllipticE[1/Sqrt[1 + \[Gamma]^2]], y0},
y0 = ((\[Pi]^2 (IntegerPart[x + 1] - x + n))/(2 K1 E1))^(1/2);
Exp[-y0^2] NIntegrate[
Exp[y^2] Sin[(n + IntegerPart[x + 1])/2 \[Pi] + c y]^2, {y, 0, y0}]
]
The problem remains, but I receive another error message:
NSum[BDMAF[n, 1, 1, 1], {n, 0, \[Infinity]}]
NIntegrate::inumr: The integrand BDMAF(n,1,1,1) has evaluated to non-numerical values for all sampling points in the region with boundaries (15. 4.64782*10^14). >>
How BDMAF function should be defined?

BDMAF[4.64782*10^14, 1, 1, 1]and see, why it results in a non-numerical value. – halirutan Nov 4 '12 at 13:56NSum[]andNIntegrate[]are yielding somewhat conflicting results on my end... – J. M.♦ Nov 4 '12 at 14:20Read the FAQs! 3) When you see good Q&A, vote them up byclicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem,by clicking the checkmark sign` – chris Nov 4 '12 at 14:29Table[BDMAF[n, 1, 1, 1], {n, 0, 120}] // ListLinePlotproduces this i.stack.imgur.com/P0sRg.png which as @J.M. points out suggests slow convergence if any. – chris Nov 4 '12 at 15:32