1

I need to plot the following singular double integration $u(x,t)$ for $t=0, t=0.2, t=0.4, t=1$ and $t=2$ in one figure as a line. That is, I need $u$-coordinate vertically and $x$-coordinate horizontally.

enter image description here

where $f(y)= \exp(-(y-4.68)^2/0.4)$. Due to singularities, I cannot plot $u(x,t)$ for $x=0..15$. I checked the NIntegrate Integration Strategies website. But, I could not manage.

t = 0.2;
m = 0.2;
f[y_] := Exp[-(y - 4.68)^2/0.4]
u[x_, t_, m_] := 
 NIntegrate[
  f[y] (2. Sin[(x^2 + y^2)/(8. (t - r)) + \[Pi]/4] Cos[( x y)/(
      4. (t - r))]) (Exp[-(x + y)^2/(8. r)] (x + y - 4. m r)/(
      4. \[Pi] r Sqrt[r (t - r)]) + (m^2 Sqrt[2.])/Sqrt[\[Pi] (t - r)]
       Exp[m (x + y) + 2. m^2 r] Erfc[(x + y + 4. m r)/(
       2. Sqrt[2 r])]), {y, 0., Infinity}, {r, 0, t}]
Anton Antonov
  • 37,787
  • 3
  • 100
  • 178
Wita
  • 111
  • 2

1 Answers1

3

Here is a way to plot the sampling points of the integration process. (If this is what it is asked.)

First using the functions Sow and Reap and the option EvaluationMonitor we gather the sampling points:

Block[{x = 0.2, t = 0.2, m = 0.2}, 
 res = Reap[
    NIntegrate[
     f[y] (2. Sin[(x^2 + y^2)/(8. (t - r)) + \[Pi]/
           4] Cos[(x y)/(4. (t - r))]) (Exp[-(x + y)^2/(8. r)] (x + y - 
            4. m r)/(4. \[Pi] r Sqrt[r (t - r)]) + (m^2 Sqrt[2.])/
          Sqrt[\[Pi] (t - r)] Exp[
          m (x + y) + 2. m^2 r] Erfc[(x + y + 4. m r)/(2. Sqrt[2 r])]), {y, 
      0., Infinity}, {r, 0, t}, PrecisionGoal -> 3, 
     EvaluationMonitor :> Sow[{y, r}]]];
 ]

Note that I have decreased the precision goal.

Here we separate the integral estimate from the gathered sampling points:

integralEstimate = res[[1]];
samplingPoints = res[[2, 1]];

Because of the coordinates magnitudes the following plot takes the logarithms of the sampling points coordinates.

Graphics[{Point[
   samplingPoints /. {x_?NumericQ, y_?NumericQ} :> {Log[x + 0.0001], 
      Log[y]}]}, AspectRatio -> 1, Frame -> True]

enter image description here

If we add a z-axis we can see the order in which the points are sampled.

k = 0;
Graphics3D[
 Point[{samplingPoints /. {x_?NumericQ, 
      y_?NumericQ} :> {Log[x + 0.0001], Log[y], k++}}], 
 BoxRatios -> {1, 1, 1}, Axes -> True]

enter image description here

(It will help rotating the 3D plot in Mathematica to get a better impression of the points distribution.)

Anton Antonov
  • 37,787
  • 3
  • 100
  • 178