Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have pasted a code that has been giving me some trouble and errors when I try to compute.

ERROR: "The integrand 1435.1232 E^(-6.4703566*10^6 s^2) deEntrance[s,phi]^2 has evaluated to non-numerical values for all sampling points in the region with boundaries "

I tried implementing the ?NumericQ function to ensure the functions are evaluated numerically with no issues but have no success. I've been at it for days, so if anyone can be of any help I would greatly appreciate it!

e = 1.60217657*10^-19;
rcgs = 2.8179403267*10^-13;
gamma = 1600/0.511;
n = (10^-10)/e;
lm = 0.549267;
theta = 0.07;
r = lm/theta;
sigmaSbeg = 2.759026*10^-004;
sigmaSend = 2.779847*10^-004;

eta1[phi_] := -(phi^2/(2 r))
eta1prime[phi_] := -((phi*theta)/lm)    
sL[phi_?NumericQ] := (r*phi^3)/24
lambdaBeg[z_] := 1/(sigmaSbeg*Sqrt[2 Pi]) Exp[-(z^2/(2*sigmaSbeg^2))]
lambdaEnd[z_] := 1/(sigmaSend*Sqrt[2 Pi]) Exp[-(z^2/(2*sigmaSend^2))]
lambdaCompress[z_, phi_] := 
     1/((((sigmaSend - sigmaSbeg)/theta)*phi + sigmaSbeg)*Sqrt[2 Pi])
     Exp[-(z^2/(2*(((sigmaSend - sigmaSbeg)/theta)*phi + sigmaSbeg)^2))]

deEntrance[s_, phi_?NumericQ] := With[{sL = sL[phi]}, 
(-((2*n*rcgs*gamma^-1)/(3^(1/3) r^(2/3))))*((lambdaCompress[s - sL, phi] - 
lambdaBeg[s - 4 sL])/sL^(1/3) + NIntegrate[
  (1/(s - sprime)^(1/3)*D[lambdaCompress[sprime, phi], sprime]),{sprime, s - sL, s}])]

deEntranceRMS[x_, phi_] := Sqrt[
NIntegrate[lambdaEnd[s]*(deEntrance[s, phi])^2, {s, -x*sigmaSend, x*sigmaSend}] - 
(NIntegrate[lambdaEnd[s]*(deEntrance[s, phi]), {s,-x*sigmaSend, x*sigmaSend}])^2]

kick1 = NIntegrate[(eta1[phi])*deEntranceRMS[3, phi], {phi, 0.0, lm}]
kick1prime = NIntegrate[(eta1prime[phi])*deEntranceRMS[3, phi], {phi, 0.0, lm}]
share|improve this question
you need the NumericQ in more places such as deEntranceRMS. Be sure to restart your kernel or Clear things when you modify the argument patterns. – george2079 Jun 22 '14 at 12:22
Hmm, yeah that's definitly my issue. I tried many places where I thought ?NumericQ should go, but no success. ANy help? – user1886681 Jun 22 '14 at 20:50
test evaluate each function that appears explicitly in NIntegrate with symbolic arguments. If you get an error add NumericQ. ( The one i mentioned in the first comment would be a good place to start.) – george2079 Jun 23 '14 at 12:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.