MathGroup Archive 2005

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

Search the Archive

Re: Boolean Integral

  • To: mathgroup at
  • Subject: [mg62432] Re: [mg62357] Boolean Integral
  • From: "Carl K. Woll" <carlw at>
  • Date: Thu, 24 Nov 2005 06:33:30 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at

Brambilla Roberto Luigi (CESI-PGE) wrote:
> Hi,
> I have defined the following support function:
> chi[func_,y1_,y2_]:=Boole[yi<func<y2]
> that gives 1 if yi<func<y2 and 0 otherwise. It works well with Plot :
> (*example*)	
> foo[x_]:=-BesselJ[1,x]
> y1=.12;
> y2=.16;
> Plot[{foo[x],chi[foo[x]],y1,y2],y1,y2},{x,0,20},
> PlotRange->All,PlotStyle->{Black,Red,Blue,Blue}]
> but if I want to *measure* the sum of intervals where y1<foo<y2, the answer is wrong:  the integral
> NIntegrate[chi[foo[x],y1,y2],{x,0,20}]
> often gives 0 since x-sample points (Gauss points) of a numerical method may fall into intervals where chi=0. 
> If I use Method->MonteCarlo the results is rather slow (10 sec.) and change a little bit at every execution
> NIntegrate[chi[foo[x],y1,y2],{x,0,20},Method->MonteCarlo]
> 1.3668
> There are other NIntegrate settings to obtain the wright result more quicly?
> (I would like to avoid to use FindRoot and to fragment the integral etc...)
> Any help well accepted.
> Thank You.
> Rob.

Anton already answered your question.

I wanted to point out that if it is easy to find the locations where 
foo[x] equals y1 and y2, then inserting these points into the 
integration contour would provide an accurate answer quickly. For your 
particular example, it is very easy to find out where foo[x] equals y1 
and y2 by using the package BesselZeros:





Construct the integration path:



Evaluate the integral. Note that we don't need to "fragment" the integral:


{0.047 Second,1.33977}

Of course, if the end points are known, it is simpler to just add them up:



> CESI SpA ha adottato il Modello Organizzativo ai sensi del D.Lgs.231/2001, in forza del quale l'assunzione di obbligazioni da parte della Società avviene con firma di un procuratore, munito di idonei poteri.
> CESI adopts a Compliance Programme under the Italian Law (D.Lgs.231/2001). According to this CESI Compliance Programme, any commitment of CESI is taken by the signature of one Representative granted by a proper Power of Attorney.
> Le informazioni contenute in questo messaggio di posta elettronica sono riservate e confidenziali e ne e' vietata la diffusione in qualsiasi modo o forma. Qualora Lei non fosse la persona destinataria del presente messaggio,   La invitiamo a non diffonderlo e ad eliminarlo, dandone gentilmente comunicazione al mittente.
> The information included in this e-mail and any attachments are confidential and may also be privileged. If you are not the correct recipient, you are kindly requested to notify the sender immediately, to cancel it and not to disclose the contents to any other person.

Carl Woll
Wolfram Research

  • References:
    • Boolean Integral
      • From: "Brambilla Roberto Luigi (CESI-PGE)" <>
  • Prev by Date: Re: Re: How to View Mathematica and Hardcopy Books
  • Next by Date: Re: Time needed for calculation
  • Previous by thread: Boolean Integral
  • Next by thread: Re: Boolean Integral