I'm trying to take the following integral
NIntegrate[
((Sin[Q 1]-Q 1*Cos[Q 1])/(Q 1)^3)^2
* S[Q,0.4,2]
* Q BesselJ[0,0.5Q]
, {Q,0,Infinity}]
but it fails with the following error message
First::first: "{} has a length of zero and no first element."
However, if I replaced the 0.5 in the Bessel function with a 1/2
NIntegrate[((Sin[Q 1] - Q 1*Cos[Q 1])/(Q 1)^3)^2
* S[Q, 0.4, 2]
* Q BesselJ[0, Q/2]
, {Q, 0, Infinity}]
I get back the result (0.046852).
S[Q,0.4,2] is included below for completeness, but it's mostly just trig functions and polynomials, so I'd be surprised if it was the issue. It certainly doesn't contain a call to first.
Why would the calculation fail for the floating point value but succeed on the rational one? Also, what does any of this have to do with First?
S[Q,0.4,2]==(1+0.095493 (-(0.000127501 (118891. +208412. Q^2-(392972. Q^4-104206. Q^2 (-2+3.93305 Q^2)+4953.78 (24-47.1966 Q^2+15.4689 Q^4)) Cos[1.98319 Q]+2 Q (-117892.-30305.8 Q^2) Sin[1.98319 Q]))/(Q^6 (1+1/Q^60.0000121755 (118891. +208412. Q^2-(392972. Q^4-104206. Q^2 (-2+3.93305 Q^2)+4953.78 (24-47.1966 Q^2+15.4689 Q^4)) Cos[1.98319 Q]+2 Q (-117892.-30305.8 Q^2) Sin[1.98319 Q])))-1/Q^40.00681547 ((-16109.8 Q^2+138.778 (144+31.4644 Q^2)) Cos[1.98319 Q]-4 (-4061.58 Q^2+138.778 (36+7.3277 Q^2)) Cos[2 Q]+8 Q (3217.18 Sin[1.98319 Q]-3259.16 Sin[2 Q]))+(10.0812 (Q^3 Cos[2 Q]-3.6092 (26.0526 +Q^2) Sin[2 Q]))/(678.74 Q+Q^5)))/(1-0.904507 (-(0.000127501 (118891. +208412. Q^2-(392972. Q^4-104206. Q^2 (-2+3.93305 Q^2)+4953.78 (24-47.1966 Q^2+15.4689 Q^4)) Cos[1.98319 Q]+2 Q (-117892.-30305.8 Q^2) Sin[1.98319 Q]))/(Q^6 (1+1/Q^60.0000121755 (118891. +208412. Q^2-(392972. Q^4-104206. Q^2 (-2+3.93305 Q^2)+4953.78 (24-47.1966 Q^2+15.4689 Q^4)) Cos[1.98319 Q]+2 Q (-117892.-30305.8 Q^2) Sin[1.98319 Q])))-1/Q^40.00681547 ((-16109.8 Q^2+138.778 (144+31.4644 Q^2)) Cos[1.98319 Q]-4 (-4061.58 Q^2+138.778 (36+7.3277 Q^2)) Cos[2 Q]+8 Q (3217.18 Sin[1.98319 Q]-3259.16 Sin[2 Q]))+(10.0812 (Q^3 Cos[2 Q]-3.6092 (26.0526 +Q^2) Sin[2 Q]))/(678.74 Q+Q^5)))
Q 1
? How did that space get there? $\endgroup$Q R
with an implied multiplication, but a substitution of/. R->1
Turned them intoQ 1
. It's not supposed to beQ1
$\endgroup$