0
$\begingroup$

I am trying to Plot an integral equation that involves exponential function. My code is as follow,

w=1;
L[α_] := 
  NIntegrate[
   1/(k + I*0.1) (
    Exp[I*k*x] (Exp[Sqrt[k^2 + α/w^2]*w] - 1) (Exp[k*w] - 1 + 
       I*0.1) Sqrt[
     k^2 + α/
      w^2])/((Sqrt[k^2 + α/w^2] + k) (Exp[
        Sqrt[k^2 + α/w^2]*w - Exp[k*w]]) + (Sqrt[
        k^2 + α/w^2] - 
        k) (Exp[(k + Sqrt[k^2 + α/w^2]) w] - 
        1)), {k, -100, 100}];
Plot[{Re[L[10]], Re[L[100]], Re[L[500]]}, {x, -0.45, 0.45}, 
 PlotRange -> Full]. 

But this integral gives a lot of oscillations which it should not. This is fig 2 in this article "https://arxiv.org/pdf/1508.00836.pdf" and Eq: 38 that I am trying to plot. Any help will be highly appreciated.

$\endgroup$
3
  • 1
    $\begingroup$ I included w=1;, what are you using? I changed L[alpha_] to L[alpha_,x_] I changed your I*0.1 to I/10and added WorkingPrecision->32 to NIntegrate and changed Plot to ListPlot[Table with exact rational steps, all to see if this is a precision problem. I get errors about NIntegrate not being able to get 32 bits of precision and I still see the oscillations you see. Plotting your integrand shows it doesn't blow up but oscillates wildly so I am guessing that you need to find a way to tell NIntegrate that it has to work much harder to get accurate results from your integrand. $\endgroup$
    – Bill
    Aug 14, 2019 at 4:25
  • $\begingroup$ @Nasser, Thanks for pointing this out. w=1. $\endgroup$ Aug 14, 2019 at 4:26
  • $\begingroup$ Consider the magnitude of the integrand around k == 100: Block[{w = 1, \[Alpha] = 10, x = 0.10}, Plot[ Abs[ 1/(k + I*0.) (Exp[ I*k*x] (Exp[Sqrt[k^2 + \[Alpha]/w^2]*w] - 1) (Exp[k*w] - 1 + I*0.) Sqrt[ k^2 + \[Alpha]/w^2])/((Sqrt[k^2 + \[Alpha]/w^2] + k) (Exp[ Sqrt[k^2 + \[Alpha]/w^2]*w - Exp[k*w]]) + (Sqrt[ k^2 + \[Alpha]/w^2] - k) (Exp[(k + Sqrt[k^2 + \[Alpha]/w^2]) w] - 1)) ], {k, -200, 200}] ] $\endgroup$
    – Michael E2
    Aug 15, 2019 at 10:56

1 Answer 1

1
$\begingroup$

Regarding the suggestions (thanks @Bill) and using Method -> "LevinRule"

L[\[Alpha]_?NumericQ, x_?NumericQ] := 
NIntegrate[1/(k + I/10) (Exp[I*k*x] (Exp[Sqrt[k^2 + \[Alpha]/w^2]*w] - 1) (Exp[k*w] -1 + I/10) Sqrt[k^2 + \[Alpha]/w^2])/((Sqrt[k^2 + \[Alpha]/w^2] + k) (Exp[Sqrt[k^2 + \[Alpha]/w^2]*w - Exp[k*w]]) + (Sqrt[k^2 + \[Alpha]/w^2] - k) (Exp[(k + Sqrt[k^2 + \[Alpha]/w^2]) w] - 1)), {k, -100,100}
, Method -> "LevinRule"];

the integral can be evaluated and plotted without error message!

L[10, 0.4]
(*68.3565 - 3.11055 I*)

Plot[{Re[L[10, x]] }, {x, -0.45, 0.45}, PlotRange -> Full,Evaluated -> True]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ You should check your function ! $\endgroup$ Aug 15, 2019 at 5:57
  • $\begingroup$ Thanks, I am still working on it. $\endgroup$ Aug 16, 2019 at 0:38

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.