Group Abstract Group Abstract

Message Boards Message Boards

Plot and animate numerically calculated integral?

Posted 5 years ago
Attachments:
POSTED BY: Kevin Bates
5 Replies

Try and adjust the PlotRange.

POSTED BY: Gianluca Gorni

The semicolon";" at the end of the input suppresses the display of the output. Then you must be patient, because those plots take a lot of numerical integrations. Here is a simplified version that runs faster:

Table[ListPlot[
  Table[(1/(2 Sqrt[Pi*((t) + 1)*(\[Epsilon])^(2)])*
      NIntegrate[
       Exp[-(Abs[x - \[Xi]])^2/(4*((t) + 1)*(\[Epsilon])^(2))]*
        g[\[Xi]] G[\[Xi]]*
        (-1/(2*(\[Epsilon])^2)), {\[Xi], p1, p2}])/
    (1/(2 Sqrt[Pi*((t) + 1)*(\[Epsilon])^(2)])*
      NIntegrate[Exp[-(Abs[x - \[Xi]])^2/
          (4*((t) + 1)*(\[Epsilon])^(2))] g[\[Xi]],
       {\[Xi], p1, p2}]),
   {x, 0, 2, 1/10}],
  PlotRange -> All],
 {t, {-2}}]

I took the liberty of changing the PlotRange.

POSTED BY: Gianluca Gorni
Posted 5 years ago

Thank you for the code. After couple of minutes Mathematica had returned the plot. It's a little bit strange that x-axis is shifted. Any way to correct it?

For example I used x from 9.5 to 10.5 with a step 1/2, but it returned "numbers" of numbers: 9.5 is 1, 10 is 2. Not the actual x-axis.

POSTED BY: Kevin Bates

Your solution s is defined in the interval between 0 and 200. Then you integrate between -200 and 200. Are you sure this is what you mean?

POSTED BY: Gianluca Gorni
Posted 5 years ago

Thank you for noticing, I have changed 0 to -200. But it doesn't change nor the result of Nintegrate nor the result of plotting by Table. It's just "running", that's all.

plots = Table[
   Plot[(1/( 2 Sqrt[Pi *((t) + 1)*(\[Epsilon])^(2)]) NIntegrate[
        Exp[-(Abs[x - \[Xi]])^2/(4*((t) + 
               1)*(\[Epsilon])^(2))] g[\[Xi]] G[\[Xi]] (-1/(2*(\
\[Epsilon])^2)), {\[Xi], p1, p2}])/(1/( 
         2 Sqrt[Pi *((t) + 1)*(\[Epsilon])^(2)]) NIntegrate[
        Exp[-(Abs[x - \[Xi]])^2/(4*((t) + 
               1)*(\[Epsilon])^(2))] g[\[Xi]], {\[Xi], p1, p2}]), {x, 
     0, 2}, PlotRange -> {-10, 10}], {t, -2, 0, .25}];

And

Plot3D[Evaluate[(1/( 
       2 Sqrt[Pi *((t) + 1)*(\[Epsilon])^(2)]) NIntegrate[
      Exp[-(Abs[x - \[Xi]])^2/(4*((t) + 
             1)*(\[Epsilon])^(2))] g[\[Xi]] G[\[Xi]] (-1/(2*(\
\[Epsilon])^2)), {\[Xi], p1, p2}])/(1/( 
       2 Sqrt[Pi *((t) + 1)*(\[Epsilon])^(2)]) NIntegrate[
      Exp[-(Abs[x - \[Xi]])^2/(4*((t) + 
             1)*(\[Epsilon])^(2))] g[\[Xi]], {\[Xi], p1, p2}])], {t, 
  0, 10}, {x, -10, 10}]

or even

Plot3D[(1/( 2 Sqrt[Pi *((t) + 1)*(\[Epsilon])^(2)]) NIntegrate[
     Exp[-(Abs[x - \[Xi]])^2/(4*((t) + 
            1)*(\[Epsilon])^(2))] g[\[Xi]] G[\[Xi]] \
(-1/(2*(\[Epsilon])^2)), {\[Xi], p1, p2}])/(1/( 
      2 Sqrt[Pi *((t) + 1)*(\[Epsilon])^(2)]) NIntegrate[
     Exp[-(Abs[x - \[Xi]])^2/(4*((t) + 
            1)*(\[Epsilon])^(2))] g[\[Xi]], {\[Xi], p1, p2}]), {t, 0, 
  10}, {x, -10, 10}]

is also useless.

POSTED BY: Kevin Bates
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard