# Nintegtrate evaluated to non-numerical values [closed]

I am currently having problem on part of my program with Nintegrate

n = 2;
vars = Array[c, n];
g[m_, a_, b_, r_] := 1/(m r) ((-CosIntegral[(a + m) r] + CosIntegral[(b + m)r]) Sin[m r] - SinIntegral[a r] + SinIntegral[b r] +Cos[m r] (SinIntegral[(a + m) r] - SinIntegral[(b + m) r]));
FG[var_, r_] := g[var[[1]]/1, 0, var[[1]], r] + Sum[g[(var[[i + 1]] - var[[i]]), var[[i]], var[[i + 1]], r], {i, 1, n - 1}] - CosIntegral[n r] + Sin[n r]/(n r)
B[var_, k_] := NIntegrate[r SphericalBesselJ[0, k*r] FG[var, r]^2, {r, 0, Infinity}];
FB[var_, r_] := NIntegrate[k SphericalBesselJ[0, k*r]/(1/B[var, k] + 2), {k, 0, Infinity}];
f[var_, k_, fk_] := NIntegrate[r (SphericalBesselJ[0, k*r] - 1) FG[var, r] FB[var, r], {r, 0,
Infinity}] + fk;


when I am running it B[var,k] is correct, e.g.,

In[17]:= B[{1, 2}, 0.001]

Out[17]= 16.9034


there is some problem with FB[var,r]

FB[{1, 2}, 1]

NIntegrate::inumr: The integrand r (-CosIntegral[2 r]+Sin[2 r]/(2 r)+((<<1>>) Sin[r]+<<1>>+Cos[r] (<<1>>+<<1>>))/r+((Times[<<2>>]+CosIntegral[<<1>>]) Sin[r]-<<1>>+<<1>>+Cos[r] (SinIntegral[<<1>>]+Times[<<2>>]))/r)^2 SphericalBesselJ[0,r \[Infinity]] has evaluated to non-numerical values for all sampling points in the region with boundaries {{\[Infinity],0.}}.

NIntegrate::inumr: The integrand r (-CosIntegral[2 r]+Sin[2 r]/(2 r)+((<<1>>) Sin[r]+<<1>>+Cos[r] (<<1>>+<<1>>))/r+((Times[<<2>>]+CosIntegral[<<1>>]) Sin[r]-<<1>>+<<1>>+Cos[r] (SinIntegral[<<1>>]+Times[<<2>>]))/r)^2 SphericalBesselJ[0,r \[Infinity]] has evaluated to non-numerical values for all sampling points in the region with boundaries {{\[Infinity],0.}}.

NIntegrate::inumr: The integrand r (-CosIntegral[2 r]+Sin[2 r]/(2 r)+((<<1>>) Sin[r]+<<1>>+Cos[r] (<<1>>+<<1>>))/r+((Times[<<2>>]+CosIntegral[<<1>>]) Sin[r]-<<1>>+<<1>>+Cos[r] (SinIntegral[<<1>>]+Times[<<2>>]))/r)^2 SphericalBesselJ[0,r \[Infinity]] has evaluated to non-numerical values for all sampling points in the region with boundaries {{\[Infinity],0.}}.

General::stop: Further output of NIntegrate::inumr will be suppressed during this calculation.


I understand ?NumericQ should be used from other post, how should it be done in my case. var is a array. Adding ?NumericQ seems do not help.

• It's the definition of B that is probably at fault, rather than that of FB, since B is called from FB. In general, you can amend your definitions using var_?(VectorQ[#, NumericQ] &) and k_?NumericQ. Although that allows the calculation to start, it seems to take a very long time (I aborted it after a few minutes running). Apr 18, 2018 at 17:35
• Thanks, your suggestions works, .although the integration is long.
– p.s
Apr 18, 2018 at 17:43