Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71408] NIntegrate
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Fri, 17 Nov 2006 04:30:33 -0500 (EST)

Clear["Global`*"]

Consider the following simple function

f[x_] := Exp[-5*x^2] + 1/2

As far as I know the default setting for the option Method of
NIntegrate is the Gauss-Kronrod algorithm for 1D integrals.

In view of this note I can't understand the difference between the
outputs of

Reap[NIntegrate[f[x], {x, -3, 3}, Method -> Automatic,
EvaluationMonitor :> Sow[x]]]
Length[%[[2,1]]]

and

Reap[NIntegrate[f[x], {x, -3, 3}, Method -> GaussKronrod,
EvaluationMonitor :> Sow[x]]]
Length[%[[2,1]]]


The following user defined functions will demostrate better the
difference in the sampled points between the two settings of the Method
option:

NIntSampledPointsPlot[f_, {x_, a_, b_}, method_, {optsint___},
{optsplot___}] :=
  Block[{lst = {}}, lst = Reap[NIntegrate[f, {x, a, b}, Method ->
method, optsint, EvaluationMonitor :> Sow[x]]];
    ListPlot[lst[[2,1]], optsplot, PlotLabel ->
StringJoin["method\[Rule]", ToString[method], ",  sampled points: ",
       ToString[Length[lst[[2,1]]]], "\nestimate value: ",
ToString[lst[[1]]]]]]

NIntLinePlot[f_, {x_, a_, b_}, method_, {optsint___}, {optsplot___}] :=

  Block[{lst = {}, ff}, ff = Function[{x}, f]; lst = Reap[NIntegrate[f,
{x, a, b}, Method -> method, optsint,
       EvaluationMonitor :> Sow[x]]]; Show[(Graphics[{Red, Line[{{#1,
0}, {#1, ff[#1]}}]}] & ) /@ lst[[2,1]], optsplot]]

Then

(NIntSampledPointsPlot[f[x], {x, -3, 3}, #1, {PrecisionGoal -> 20,
WorkingPrecision -> 30},
    {ImageSize -> 600, PlotStyle -> PointSize[0.01], Frame -> {True,
True, False, False},
     TextStyle -> {FontFamily -> "Times"}}] & ) /@ {GaussKronrod,
Automatic}
(*plot to be displayed*)

Show[GraphicsArray[(NIntLinePlot[Exp[-5*x^2] + 1/2, {x, -3, 3}, #1, {},
{Frame -> True, DisplayFunction -> Identity,
       PlotLabel -> ToString[#1]}] & ) /@ {Automatic, GaussKronrod}],
ImageSize -> 800]
(*plot to be displayed*)


Thanks in advance
Dimitris


  • Prev by Date: Re: RE:Need Help: Can not use Ticks under PolarPlot
  • Next by Date: Re: About NIntegrate
  • Previous by thread: Rectangle with Scaled (a plot inside a plot)
  • Next by thread: Re: NIntegrate