       Re: Boolean Integral

• To: mathgroup at smc.vnet.net
• Subject: [mg62396] Re: Boolean Integral
• From: "antononcube" <antononcube at gmail.com>
• Date: Wed, 23 Nov 2005 01:12:11 -0500 (EST)
• References: <dlupfj\$nb2\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```These settings seem to work:

In:=  NIntegrate[chi[foo[x], y1, y2], {x, 0, 20}, MinRecursion -> 4,
MaxRecursion -> 200, SingularityDepth -> 1000]

NIntegrate::slwcon:
Numerical integration converging too slowly; suspect one of the
following:
singularity, value of the integration being 0, oscillatory
integrand, or
insufficient WorkingPrecision. If your integrand is oscillatory try
using
the option Method->Oscillatory in NIntegrate.

Out= 1.33977

As you said, the reason for NIntegrate to stop with the default
settings is because the sampling points of the first integration step
are where the integrand is 0. Increasing the number of initial sampling
points with the option MinRecursion allows NIntegrate to see that the
integrand is non-zero, and on what areas the computational efforts
should be concentrated.

These plots with different values for the parameter minrec (eg, 0, 2,
4) might clarify my explanation further:

In:= minrec = 4;

In:=pnts = Reap[NIntegrate[chi[foo[x], y1, y2], {x, 0, 20},
MinRecursion -> minrec, MaxRecursion -> 200,
SingularityDepth -> 1000, EvaluationMonitor :> Sow[x]]][[2,1]];

In:= Length[pnts]
Out= 4972

In:=ListPlot[Transpose[{pnts, Range[Length[pnts]]}]]

Further, if the zeroes of your function foo are known (e.g.
foo[x_]:=Sin[x]) the piecewise handling of NIntegrate will simplify the
integrand to the non-zero parts of it only (and the integration will be
much faster). Again you can see this with the plots above, and using
Length[pnts].

In:=pnts = Reap[NIntegrate[chi[Sin[x], y1, y2], {x, 0,
20},EvaluationMonitor :> Sow[x]]][[2,1]];

In:=Length[pnts]

Out=77

In:=ListPlot[Transpose[{pnts,Range[Length[pnts]]}]]

Anton Antonov,
Wolfram Research, Inc.

```

• Prev by Date: Re: How to read a data file in text format?_from a new learner
• Next by Date: Mathematica Performance
• Previous by thread: Re: Boolean Integral
• Next by thread: Re: Boolean Integral