First of all, I'm a beginner in Mathematica so maybe I missed something very simple. As shown in the image below, I tried to integrate a large integral. However, the result is strange. According to the result, the integral is always zero whatever the values of w, h, L, P, S and k. However, when I try to put some "test values", the result is not zero.

test values: P=1,w=1,h=0.1,L=1,S=0,k=0.2

This is not consistent with ouput 1. So what's wrong with my first input?


Integrate[P/((Sqrt[y^2 + L^2 + z^2]) ((S - y)^2 + P^2 + z^2))Cos[k (Sqrt[y^2 + L^2 + z^2] + 
  Sqrt[(S - y)^2 + P^2 + z^2])], {y, -w/2, w/2}, {z, -h, h}]
NIntegrate[1/((Sqrt[y^2 + 1^2 + z^2]) ((0 - y)^2 + 1^2 + z^2))Cos[0.2 (Sqrt[y^2 + 1^2 + z^2] + 
  Sqrt[(0 - y)^2 + 1^2 + z^2])], {y, -0.5, 0.5}, {z, -0.1, 0.1}]
NIntegrate[Cos[0.4 Sqrt[1 + y^2 + z^2]]/(1 + y^2 + z^2)^(3/2), {y, -0.5, 0.5}, {z, -0.1, 0.1}]


  • 2
    $\begingroup$ The input should be provided in cut-and-pastable form.Please post actual code rather than an image of code. $\endgroup$ Commented Mar 21, 2018 at 13:14
  • $\begingroup$ @MariuszIwaniuk Thanks. I have now added a cut-and-pastable form of the code. $\endgroup$
    – Anon
    Commented Mar 21, 2018 at 13:30
  • $\begingroup$ For convenience, can you please also indicate the values you used for P, L, and other variables? $\endgroup$ Commented Mar 21, 2018 at 13:34
  • $\begingroup$ @J.M. done adding $\endgroup$
    – Anon
    Commented Mar 21, 2018 at 13:38
  • 2
    $\begingroup$ @Daniel Lichtblau and VsevolodA : I have reposted the corrected answer below. Thanks for your comments. Plus 1 to the power of refereeing. $\endgroup$
    – Vixillator
    Commented Mar 22, 2018 at 0:59

1 Answer 1


As seen from Plot 1 below, when we zoom out to the limits {y,-100,100},{z,-100,100}, the integrand f1[y,z] exhibits bilateral diagonal symmetry relative to the directions z = y, and z = - y. Also from Plot 2 of f1[y,z] at z=3 and Plot 3 at z=0.5, we see that the contribution to the positive and negative parts tend towards balancing out in the integral as we zoom out from the origin. The indefinite integral captures the entire domain whereby the sum of the positive parts cancel exactly the sum of the negative parts of the integral, which means that the indefinite integral vanishes over the entire domain. But when we do the definite integration over the narrow limits {y,-0.5,0.5},{z,-0.1,0.1}, we see from Plot 3 and Plot 4 that the integrand is entirely above the y-z surface, therefore the definite integral will have a finite positive value. This means that near the origin, when the limits of integration are narrow and symmetric, the definite integral will be positive and not vanish.

f1[y_,z_]:=P/((Sqrt[y^2+L^2+z^2]) ((S-y)^2+P^2+z^2))Cos[k (Sqrt[y^2+L^2+z^2]+Sqrt[(S-y)^2+P^2+z^2])]
Plot3D[f1[y,z]/.{P->1,w->1,h->0.1,L->1,S->0,k->0.2},{y,-100,100},{z,-100,100}] (* Plot 1 *)

enter image description here Plot 1:

Plot[f1[y,z]/.{P->1,w->1,h->0.1,L->1,S->0,k->0.2,z->3},{y,-100,100},PlotRange->Full] (* Plot 2 *)

enter image description here Plot 2:

Plot[f1[y,z]/.{P->1,w->1,h->0.1,L->1,S->0,k->0.2,z->0.5},{y,-0.5,0.5},PlotRange->Full] (* Plot 3 *)

enter image description here Plot 3:

Plot3D[f1[y,z]/.{P->1,w->1,h->0.1,L->1,S->0,k->0.2},{y,-0.5,0.5},{z,-0.1,0.1}] (* Plot 4 *)

enter image description here Plot 4:

  • $\begingroup$ Thank you very much. $\endgroup$
    – Anon
    Commented Mar 22, 2018 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.