Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

I: Bug in NIntegrate[]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126894] I: Bug in NIntegrate[]?
  • From: "Brambilla Roberto Luigi (RSE)" <Roberto.Brambilla at rse-web.it>
  • Date: Fri, 15 Jun 2012 15:30:12 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com


-----Messaggio originale-----
Da: Brambilla Roberto Luigi (RSE) 
Inviato: venerd=EC 15 giugno 2012 10.18
A: 'GS'
Oggetto: R: Bug in NIntegrate[]?

Weak formulation. This works:

f[x_] := If[0 <= x <= 1, 1, 0]
Integrate[f[x], {x, -13, 13}]
1
Bye Rob
-----Messaggio originale-----
Da: GS [mailto:vokaputs at gmail.com] 
Inviato: venerd=EC 15 giugno 2012 9.41
A: mathgroup at smc.vnet.net
Oggetto: Bug in NIntegrate[]?

I define the function f[x] as follows:

f[x_] := 0 /; x < 0 || x > 1;
f[x_] := 1

It is zero outside of the interval [0,1]. This can be verified by plotting
Plot[f[x], {x, -1, 2}]

Now I integrate it from -1 to 2:
In[270]:= NIntegrate[f[x], {x, -1, 2}]
Out[270]= 3.

The result should be 1, but it is 3. Clearly Mathematica ignores the fact that f[x] is zero outside of [0,1].

This caused a lot of headache for me recently when I encountered such behavior in one of my research code.
GS 


RSE 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=E0 avvie=
ne con firma di un procuratore, munito di idonei poteri.
RSE adopts a Compliance Programme under the Italian Law (D.Lgs.231/2001). Ac=
cording to this RSE Compliance Programme, any commitment of RSE 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 ris=
ervate e confidenziali e ne e' vietata la diffusione in qualsiasi modo o for=
ma. Qualora Lei non fosse la persona destinataria del presente messaggio, La=
 invitiamo a non diffonderlo e ad eliminarlo, dandone gentilmente comunicazi=
one 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 rec=
ipient, you are kindly requested to notify the sender immediately, to cancel=
 it and not to disclose the contents to any other person.



  • Prev by Date: Re: is Head[] part of the expression?
  • Next by Date: Re: Bug in NIntegrate[]?
  • Previous by thread: Re: Tracing of Manipulate solutions
  • Next by thread: System of Integro-differential equations