0
$\begingroup$

I am trying to evaluate the numerical integration of a very long function and no matter what I do, I get the error that "NIntegrate::inumr: The integrand has evaluated to non-numerical values for all sampling points...". This is the code I have now:

 points = 2;
Monitor[Itab = 
Table[{{η, 
   xp, ϕ} = {-3 + 
    6 (n - 1)/points, .001 + (m - 1) (xpf - 0.001)/
     points, -π + (k - 1) 2 π/points};
 NIntegrate[Clear[Int]; Int[ϕp_?NumericQ] := (Int[ϕp] =

     NIntegrate[ -Z*
       x ((3/2 π*RA^3) Sqrt[
          RA^2 - x^2 + 
           b x Cos[ϕp] +b^2/4])(*first part of the field*)((e^2/4 π) Sinh[
          Y0] (xp Cos[ϕ] - 
           x Cos[ϕp]) (τ^2 Sinh[Y0 - η]^2 + xp^2 + 
            x^2 - 2 xp x Cos[ϕ - ϕp])^(-3/
            2) (σ Sinh[
             Y0] Sqrt[τ^2 Sinh[Y0 - η]^2 + xp^2 + x^2 - 
               2 xp x Cos[ϕ - ϕp]]/2 + 
           1) Exp[σ Sinh[Y0 - η] Sinh[Y0] τ/
             2 - σ/2 Sinh[
             Y0] Sqrt[τ^2 Sinh[Y0 - η]^2 + xp^2 + x^2 - 
              2 xp x Cos[ϕ - ϕp]]])(*second part of the \
   field*)((e^2/4 π) Sinh[
          Y0] (xp Cos[π - ϕ] - 
           x Cos[ϕp]) (τ^2 Sinh[Y0 + η]^2 + xp^2 + 
            x^2 - 2 xp x Cos[π - ϕ - ϕp])^(-3/
            2) (σ Sinh[
             Y0] Sqrt[τ^2 Sinh[Y0 + η]^2 + xp^2 + x^2 - 
               2 xp x Cos[π - ϕ - ϕp]]/2 + 
           1) Exp[σ Sinh[Y0 + η] Sinh[Y0] τ/
             2 - σ/2 Sinh[
             Y0] Sqrt[τ^2 Sinh[Y0 + η]^2 + xp^2 + x^2 - 
              2 xp x Cos[π - ϕ - ϕp]]]), {x, -Cos[\
    ϕp] b/2 + Sqrt[RA^2 - b^2 Sin[ϕp]^2/4], 
       Cos[ϕp] b/2 + Sqrt[RA^2 - b^2 Sin[ϕp]^2/4]}]); 
    Int[ϕp], {ϕp, -π/2, π/2}]}, {n, 1, 
   points + 1}, {m, 1, points + 1}, {k, 1, points + 1}], {n, m, k}];

I would be very thankful if you can tell me what errors you can detect in the code!

I also tried this code:

   i1[ϕp_?NumericQ] := i2[ϕp] =
    NIntegrate[ -Z*
     x ((3/2 π*RA^3) Sqrt[
    RA^2 - x^2 + 
     b x Cos[ϕp] +(*I think there was a sign problem here*)
     b^2/4])(*first part of the field*)((e^2/4 π) Sinh[
    Y0] (xp Cos[ϕ] - 
     x Cos[ϕp]) (τ^2 Sinh[Y0 - η]^2 + xp^2 + x^2 - 
      2 xp x Cos[ϕ - ϕp])^(-3/
      2) (σ Sinh[
       Y0] Sqrt[τ^2 Sinh[Y0 - η]^2 + xp^2 + x^2 - 
         2 xp x Cos[ϕ - ϕp]]/2 + 
     1) Exp[σ Sinh[Y0 - η] Sinh[Y0] τ/
       2 - σ/2 Sinh[
       Y0] Sqrt[τ^2 Sinh[Y0 - η]^2 + xp^2 + x^2 - 
        2 xp x Cos[ϕ - ϕp]]])(*second part of the \
   field*)((e^2/4 π) Sinh[
    Y0] (xp Cos[π - ϕ] - 
     x Cos[ϕp]) (τ^2 Sinh[Y0 + η]^2 + xp^2 + x^2 - 
      2 xp x Cos[π - ϕ - ϕp])^(-3/
      2) (σ Sinh[
       Y0] Sqrt[τ^2 Sinh[Y0 + η]^2 + xp^2 + x^2 - 
         2 xp x Cos[π - ϕ - ϕp]]/2 + 
     1) Exp[σ Sinh[Y0 + η] Sinh[Y0] τ/
       2 - σ/2 Sinh[
       Y0] Sqrt[τ^2 Sinh[Y0 + η]^2 + xp^2 + x^2 - 
        2 xp x Cos[π - ϕ - ϕp]]]), {x, 0, 5}];
     NIntegrate[i2[ϕp], {ϕp, -π/2, π/2}];
$\endgroup$
  • $\begingroup$ Many of your symbols do not have numeric values. For example, Z, RA, b, e, Y0, $\tau$, $\sigma$, $\phi$, x, xp, maybe others. Examine your integrand first and make sure it evaluates to a numeric value when $\phi p$ is numeric. Note that your integrand does not seem to depend on {n,m,k}. Once the integrand is evaluating to a plausible numeric value, I would then put it into NIntegrate[] and look at a few values. If they look right, I would put the integral into the Table[]. $\endgroup$ – LouisB Jul 13 '17 at 18:31
  • $\begingroup$ I have numerical values for these: Tc = 170 ; T = 1.5 Tc ; a = 0.15 ; [Zeta] = 1;(* [Kappa]=1.05; )T0 = 10.8; \ fs = 11; b = 7; Y0 = 7.6; Z = 82 ; e = Sqrt[4 [Pi]/137]; Tf = 130 ; t0 = 0.125( fm ); R = 5 ( fm ); RA = 7 ( fm ); [Epsilon] = 1; [Sigma] =(*0.37 (T/Tc)^2) [Zeta] 0.018 T /197; (* fm^-1 *) [Tau] := t0/cosh[[Eta]]; xpf = 5 ; $\endgroup$ – Susan AB Jul 13 '17 at 18:48
  • $\begingroup$ Do not supply needed numerical values in a comment. Edit your question to so it includes the definitions of these values. $\endgroup$ – m_goldberg Jul 21 '17 at 3:45
  • 1
    $\begingroup$ What happens when you plug in a numerical value for your integration variable into your integrand? (E.g. for NIntegrate[f, {x, 0, 1}] try something like f /. x -> 0.5, substituting your integrand for f, your variable for x, and numerical value in the interval of integration for 0.5.) $\endgroup$ – Michael E2 Jul 21 '17 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.