Message Boards Message Boards

[✓]  Plot for numerical integration?

GROUPS:

How can I plot a graph and interval table for the following function?

 NIntegrate[0.00159155/(x^2 + 0.000025^2), {x, -10, 10, 0.2}, Method ->
 {"MultiPanelRule", Method -> {"TrapezoidalRule", "Points" -> 2, "RombergQuadrature" -> False}, 
 "Panels" -> 50}, MaxRecursion -> 0] // Quiet
Attachments:
POSTED BY: Mujtaba Mozumder
Answer
5 days ago

By graph, I assume you mean the graph of the integrand 0.00159155/(x^2 + 0.000025^2) from x == -10 to x == 10:

Plot[0.00159155/(x^2 + 0.000025^2), {x, -10,10}]

I'm not sure what it means to "plot a...interval table." Do you just want a table of intervals NIntegrate used, or do you want to mark the intervals on on the plot in some way?

The 0.2 in {x, -10, 10, 0.2} will be interpreted by NIntegrate as a point to be treated as a singularity in the integrand. Did you mean it in the same way it is used in Table, to indicate the difference between successive steps?

POSTED BY: Michael Rogers
Answer
5 days ago

Want a table of intervals NIntegrate used

POSTED BY: Mujtaba Mozumder
Answer
5 days ago

Since MaxRecursion is set to 0, this should work:

{int, {evals}} = 
  Reap[NIntegrate[
     0.00159155/(x^2 + 0.0000001 x + 0.000025^2), {x, -10, 10, 0.2}, 
     Method -> {"TrapezoidalRule", "Points" -> 51, 
       "RombergQuadrature" -> False},
     EvaluationMonitor :> Sow[x, "EVAL"],
     MaxRecursion -> 0] // Quiet,
   {"EVAL"}];

evals
(*
{{-10., -9.8, -9.6, -9.4, -9.2, -9., -8.8, -8.6, -8.4, -8.2, -8., 
  -7.8, -7.6, -7.4, -7.2, -7., -6.8, -6.6, -6.4, -6.2, -6., -5.8, -5.6, 
  -5.4, -5.2, -5., -4.8, -4.6, -4.4, -4.2, -4., -3.8, -3.6, -3.4, -3.2, 
  -3., -2.8, -2.6, -2.4, -2.2, -2., -1.8, -1.6, -1.4, -1.2, -1., -0.8, 
  -0.6, -0.4, -0.2, 0., 0.2, 0.4, 0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8, 2., 
  2.2, 2.4, 2.6, 2.8, 3., 3.2, 3.4, 3.6, 3.8, 4., 4.2, 4.4, 4.6, 4.8, 
  5., 5.2, 5.4, 5.6, 5.8, 6., 6.2, 6.4, 6.6, 6.8, 7., 7.2, 7.4, 7.6, 
  7.8, 8., 8.2, 8.4, 8.6, 8.8, 9., 9.2, 9.4, 9.6, 9.8, 10., 10., 
  9.902, 9.804, 9.706, 9.608, 9.51, 9.412, 9.314, 9.216, 9.118, 9.02, 
  8.922, 8.824, 8.726, 8.628, 8.53, 8.432, 8.334, 8.236, 8.138, 8.04, 
  7.942, 7.844, 7.746, 7.648, 7.55, 7.452, 7.354, 7.256, 7.158, 7.06, 
  6.962, 6.864, 6.766, 6.668, 6.57, 6.472, 6.374, 6.276, 6.178, 6.08, 
  5.982, 5.884, 5.786, 5.688, 5.59, 5.492, 5.394, 5.296, 5.198, 5.1, 
  5.002, 4.904, 4.806, 4.708, 4.61, 4.512, 4.414, 4.316, 4.218, 4.12, 
  4.022, 3.924, 3.826, 3.728, 3.63, 3.532, 3.434, 3.336, 3.238, 3.14, 
  3.042, 2.944, 2.846, 2.748, 2.65, 2.552, 2.454, 2.356, 2.258, 2.16, 
  2.062, 1.964, 1.866, 1.768, 1.67, 1.572, 1.474, 1.376, 1.278, 1.18, 
  1.082, 0.984, 0.886, 0.788, 0.69, 0.592, 0.494, 0.396, 0.298, 0.2}}
*)

If you are surprised that the values go from -10. to 10. and then from 10. to 0.2, it's because your code {x, -10, 10, 0.2} tells NIntegrate to do that.

POSTED BY: Michael Rogers
Answer
5 days ago

An additional guess:

{int, {evals}} = 
  Reap[NIntegrate[
     0.00159155/(x^2 + 0.0000001 x + 0.000025^2), {x, -10, 10, 0.2}, 
     Method -> {"TrapezoidalRule", "Points" -> 51, 
       "RombergQuadrature" -> False}, 
     EvaluationMonitor :> 
      Sow[{x, 0.00159155/(x^2 + 0.0000001 x + 0.000025^2)}, "EVAL"], 
     MaxRecursion -> 0] // Quiet, {"EVAL"}];

ListPlot@evals

enter image description here

POSTED BY: Valeriu Ungureanu
Answer
4 days ago

Just what i was looking for!

POSTED BY: Mujtaba Mozumder
Answer
4 days ago

Thank you

POSTED BY: Mujtaba Mozumder
Answer
4 days ago

My pleasure!

POSTED BY: Valeriu Ungureanu
Answer
4 days ago

How can I do Reap NIntegrate and list plot for the same function 0.00159155/(x^2 + 0.0000001 x + 0.000025^2) using simpson's rule or boole's rule? The one before was trapezoidal rule.

Attachments:
POSTED BY: Mujtaba Mozumder
Answer
2 days ago

Group Abstract Group Abstract