0
$\begingroup$

What I do is Integrate a formula and then NItegrate the output of the previous integration. The problem is I get different NItegrate results depending on whether I copy the Integrate output manually or put it as a defined variable.

The formula is

(0.0232723 kx Sin[3.2 kx])/((-kx^2 - ky^2 - 0.00008649 kz^2)*
 (0.0232723 + kx^2 + ky^2 + kz^2))

First I do the Integrate

f = Assuming[{kz ∈ Reals && kz != 0 && kx ∈ Reals && ky ∈ Reals}, 
Integrate[(0.0232723 kx Sin[3.2 kx])/((-kx^2 - ky^2 - 0.00008649 kz^2)*
 (0.0232723 + kx^2 + ky^2 + kz^2)), {ky, -∞, ∞}, {kz, -∞, ∞}]]

where the output is

(845.3256946557052 kx ((0. + 0.060962518629646675 I) Log[1. - (0. + 0.0014188019531818545 I)/Sqrt[-2.0129989823526456`*^-6 + 1. kx^2]] - (0. + 0.060962518629646675 I) Log[1. + (0. + 0.0014188019531818545 I)/ Sqrt[-2.0129989823526456*^-6 + 1. kx^2]] - (0. + 0.060962518629646675 I) Log[1. - (0. + 0.15255934980455418 I)/Sqrt[-2.0129989823526456*^-6 + 1. kx^2]] + (0. + 0.060962518629646675 I) Log[1. + (0. + 0.15255934980455418 I)/Sqrt[-2.0129989823526456*^-6 + 1. kx^2]]) Sin[3.2 kx])/(Sqrt[-0.023272342213805974 + 11561.030292527505 kx^2])

Now onto the NIntegrate. I can either do

NIntegrate[f, {kx, -∞, ∞}]

and get

-47.0578 + 0. I

or copy the Integrate output manually and do

NIntegrate[(845.3256946557052` kx ((0.` + 0.060962518629646675` I) Log[1.` - (0.` + 0.0014188019531818545` I)/
 Sqrt[-2.0129989823526456`*^-6 + 1.` kx^2]] - (0.` + 0.060962518629646675` I) Log[1.` + (0.` + 0.0014188019531818545` I)/
 Sqrt[-2.0129989823526456`*^-6 + 1.` kx^2]] - (0.` + 0.060962518629646675` I) Log[1.` - (0.` + 0.15255934980455418` I)/
 Sqrt[-2.0129989823526456`*^-6 + 1.` kx^2]] + (0.` + 0.060962518629646675` I) Log[1.` + (0.` + 0.15255934980455418` I)/
 Sqrt[-2.0129989823526456`*^-6 + 1.` kx^2]]) Sin[3.2` kx])/(Sqrt[-0.023272342213805974` + 11561.030292527505` kx^2]), 
 {kx, -∞, ∞}]

This gives

-0.359278 + 0. I

Why are the results different and how can I know which is the correct one?

P.S. The results include imaginary numbers even though I wrote assumptions that $kx$, $ky$, $kz$ are real, I don't know why the results are still with I.

$\endgroup$
1
  • 1
    $\begingroup$ In V13.3.0 (Mac ARM) I get -0.359278 for the integral of f, the output copied from my notebook, and the posted output above. $\endgroup$
    – Michael E2
    Aug 16, 2023 at 14:58

1 Answer 1

2
$\begingroup$

If you Rationalizethe integrand first it's possible to Integrate along ky,kz

expr = Rationalize[(0.0232723 kx Sin[3.2 kx])/((-kx^2 - ky^2 - 0.00008649 kz^2)*(0.0232723 + kx^2 +ky^2 + kz^2)), 0]

$\frac{232723 \text{kx} \sin \left(\frac{16 \text{kx}}{5}\right)}{10000000 \left(-\text{kx}^2-\text{ky}^2-\frac{8649 \text{kz}^2}{100000000}\right) \left(\text{kx}^2+\text{ky}^2+\text{kz}^2+\frac{232723}{10000000}\right)}$

intyz = Integrate[expr , {ky, -\[Infinity], \[Infinity]} , {kz, -\[Infinity], \\[Infinity]}, Assumptions -> {Element[{kx }, Reals], kx > 0}] 

enter image description here

Result shows a restriction kx > (93 Sqrt[232723/999913510])/1000 which indicates that further integration -Infinity<kx<Infinity isn't possible!

addendum

If we ignore these restrictions (there is a removable singularity at kx == \[PlusMinus](93 Sqrt[232723/999913510])/1000) we get (without message)

NIntegrate[intyz[[1]], {kx, -Infinity, Infinity} ]
(*-0.359278*)

Knowing the singularities we can "confirm" this result

NIntegrate[expr, {kx, -Infinity, Infinity}, {ky,Infinity,Infinity},{kz, -Infinity, Infinity} , 
Method -> "PrincipalValue",Exclusions -> {kx == -((93Sqrt[232723/999913510])/1000), kx == (93 Sqrt[232723/999913510])/1000 }]   
(*-0.358437*)

Last result gives a message ...error estimate 0.010923508468859621

Hope it helps!

$\endgroup$
4
  • $\begingroup$ You made an assumption that kx > 0 while it can vary from $-\infty$ to $\infty$. Without your assumption the condition is kx > (93 Sqrt[232723/999913510])/1000 || kx < -((93 Sqrt[232723/999913510])/1000) or kx > 0.0014188 || kx < -0.0014188 which in my opinion is acceptable as it's a small range that can be skipped without the loss of precision. So in my understanding further NIntegrate should still be possible in the $-\infty<kx<\infty$ range. I guess some exception for the kx > 0.0014188 || kx < -0.0014188 condition should be manually put in the formula? But I don't know how. $\endgroup$
    – Patrycja
    Aug 15, 2023 at 13:19
  • $\begingroup$ @Patrycja Integral is symmetric in kx , though try NIntegrate[intyz,{kx,0.0014188,Infinity}]. But I don't know how to estimate the integration error. $\endgroup$ Aug 15, 2023 at 13:35
  • $\begingroup$ In this case the problem is still the same - whether I put intyz into the NIntegrate or its explicit form I get two very different results, -46.8549 and 0.535058 respectively, with the explicit form giving the following error DoubleExponentialOscillatory has failed to converge for the integrand. $\endgroup$
    – Patrycja
    Aug 15, 2023 at 20:12
  • $\begingroup$ @Patrycja "DoubleExponentialOscillatory has failed to converge for the integrand" is not an error, it is a warning. :) Try the same integrand with different method. $\endgroup$ Aug 16, 2023 at 14:40

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.