MathGroup Archive 2006

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

Search the Archive

Re: NIntegrate[Abs] bug in v5.1, not v5.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64228] Re: NIntegrate[Abs] bug in v5.1, not v5.0
  • From: Peter Pein <petsie at dordos.net>
  • Date: Tue, 7 Feb 2006 03:35:57 -0500 (EST)
  • References: <ds1sk5$g0t$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Solomon, Joshua schrieb:
> First, I establish that everything works in v5.0.
> 
> In[1]:=
> 
> f[x_]:=E^-(Sin[.1+x]^2)-E^-(Sin[.1-x]^2)
> 
> 
> In[2]:=
> 
> {$Version,$ReleaseNumber}
> 
> Out[2]=
> 
> {5.0 for Mac OS X (June 10, 2003),0}
> 
> 
> In[3]:=
> 
> Timing[NIntegrate[-f[x],{x,0,Pi/2},AccuracyGoal->1]]
> 
> Out[3]=
> 
> {0.001438 Second,0.125515}
> 
> 
> In[4]:=
> 
> Timing[NIntegrate[Abs[f[x]],{x,0,Pi/2},AccuracyGoal->1]]
> 
> Out[4]=
> 
> {0.0015 Second,0.125515}
> 
> 
> Now I try again in v5.1.
> 
> In[1]:=
> 
> f[x_]:=E^-(Sin[.1+x]^2)-E^-(Sin[.1-x]^2)
> 
> 
> In[2]:=
> 
> {$Version,$ReleaseNumber}
> 
> Out[2]=
> 
> {5.1 for Mac OS X (October 25, 2004),0}
> 
> In[3]:=
> 
> Timing[NIntegrate[-f[x],{x,0,Pi/2},AccuracyGoal->1]]
> 
> Out[3]=
> 
> {0.001286 Second,0.125515}
> 
> 
> In[4]:=
> 
> Timing[NIntegrate[Abs[f[x]],{x,0,Pi/2},AccuracyGoal->1]]
> 
> 
> This produces no output for several minutes. Then the Kernel crashes. Any
> ideas?
> 
> j
Your function has negative values for 0<x<Pi/2. You can take the absolute value outside the integral:
In[1]:= f[x_] := E^(-Sin[1/10 + x]^2) - E^(-Sin[1/10 - x]^2)
In[2]:=AbsoluteTiming[Abs[NIntegrate[f[x], {x, 0, Pi/2}]]]
Out[2]= {0.*Second, 0.12551526601896873}


  • Prev by Date: Strange Syntax problem
  • Next by Date: Re: creating packages of my own.
  • Previous by thread: Re: NIntegrate[Abs] bug in v5.1, not v5.0
  • Next by thread: Compile arguments