1
$\begingroup$

Consider a function

f[x_, Z_, α_, mN_, q_, R_, S_] = 
  Assuming[mN > 0 && x > 0, 
   9*α*Z^2/(2*Pi)*((1 + (1 - x)^2)/x)*
    (q^2 - x^2 mN^2)/q^4*
    SphericalBesselJ[1, 
      R*q]^2/(R*q)^2*
    Exp[-q^2*S^2]];

It is defined in the domain $$ \text{max}[2\cdot 10^{-5}, x\cdot m_{N}]< q< q_{\text{max}} = 4.49/5, \quad 10^{-9}<x <q_{\text{max}}/m_{N} $$ I'm trying to obtain the interpolation of numerical integral $$ \int \limits_{q_{\text{min}}}^{q_{\text{max}}}dq^{2}f[x,42,1/137,100,q,5,0.726] $$ for the given value of x. Namely, I write

g1 = 
  Table[{x, 
    NIntegrate[
     f[x, q, 42, 1/137, 100, 5, 0.726]*2*q, {q, 
      Max[100*x, 2*10^-5], 4.49/5}]}, {x, 10^-9, 4.49/(5*100), 10^-4}];
g[x_] = Interpolation[g1 ][x]

Finally, I want to draw a plot of the function g[x]. I write

LogLogPlot[g[x], {x, 10^-9, 4.49/(5*100)}, PlotRange -> All]

And I see discontinuous plot. The point of discontinuity strongly depends on the table step size (I've tried from $10^{-7}$ to $10^{-2}$). From the other side, if I simply write

LogLogPlot[
 NIntegrate[
  Re[f[x, q, 42, 1/137, 100, 5, 0.726]]*2*q, {q, 
   Max[100*x, 2*10^-5], 4.49/5}], {x, 10^-9, 4.49/(5*100)}, 
 PlotRange -> All],

then the plot is smooth.

How to obtain correct interpolation?

The code sample is

 f[x_, Z_, α_, mN_, q_, R_, S_] = 
      Assuming[mN > 0 && x > 0, 
       9*α*Z^2/(2*Pi)*((1 + (1 - x)^2)/x)*
        (q^2 - x^2 mN^2)/q^4*
        SphericalBesselJ[1, 
          R*q]^2/(R*q)^2*
        Exp[-q^2*S^2]];

    g1 = 
      Table[{x, 
        NIntegrate[
         f[x, 42, 1/137, 100,q, 5, 0.726]*2*q, {q, 
          Max[100*x, 2*10^-5], 4.49/5}]}, {x, 10^-9, 4.49/(5*100), 10^-4}];
    g[x_] = Interpolation[g1 ][x]

    LogLogPlot[g[x], {x, 10^-9, 4.49/(5*100)}, PlotRange -> All]
$\endgroup$
6
  • $\begingroup$ What is PhotonDFx? Please provide sample code that can be evaluated from start to finish. $\endgroup$
    – halirutan
    Commented Feb 17, 2018 at 2:11
  • $\begingroup$ @halirutan : sorry, this is g[x]. $\endgroup$ Commented Feb 17, 2018 at 9:01
  • $\begingroup$ f evaluates to zero: i.sstatic.net/qYsle.png -- In g1, you've substituted the argument q into the slot for Z. Perhaps that's a mistake? (If not, I get a constant 0. for the value of g, not a discontinuous function.) $\endgroup$
    – Michael E2
    Commented Feb 17, 2018 at 21:20
  • $\begingroup$ @MichaelE2 : you're right. Sorry for my mistakes... $\endgroup$ Commented Feb 18, 2018 at 0:37
  • $\begingroup$ Try Plot[g[x], {x, 10^-9, 4.49/(5*100)}, PlotRange -> All] and you'll see that the interpolation goes negative. That's why the log-log plot has a gap. Try InterpolationOrder -> 2 or InterpolationOrder -> 1. $\endgroup$
    – Michael E2
    Commented Feb 18, 2018 at 4:06

1 Answer 1

1
$\begingroup$

The problem is that the interpolation overshoots the x-axis, which makes the log-log plot undefined:

Plot[g[x], {x, 10^-9, 4.49/(5*100)},
 Epilog -> {Red, Point@g1}, PlotRange -> {{0, 0.0005}, All}]

Mathematica graphics

Lowering the interpolation order to 1 or 2 is one way that results in a positive interpolation. Another is to rescale the data:

gg[x_] = Interpolation[Log@g1][Log@x] // Exp

LogLogPlot[{g[x], gg[x]}, {x, 10^-9, 4.49/(5*100)},
 Epilog -> {Red, Point@Log@g1}, 
 PlotStyle -> {Thickness[0.012], Thickness[0.007]}, PlotRange -> All]

Mathematica graphics

$\endgroup$

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.