Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*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 2003

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

Search the Archive

Re: [Integrate] Why two results of same eq. are different?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44700] Re: [Integrate] Why two results of same eq. are different?
  • From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
  • Date: Fri, 21 Nov 2003 05:13:22 -0500 (EST)
  • References: <bphtag$1kr$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Sung Jin Kim" <kimsj at mobile.snu.ac.kr> wrote:
> I got very extraordinary results today from below two same integrals
> except one is symbolic one and the other is numeric one:
> A. In[1]= N[Integrate[ Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, Infinity}]]
>     Out[1]= -3.77002
> B. In[2]= NIntegrate[ Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, Infinity}]
>     Out[2]= 4.05856
>
> Why did I got the different results of these, surprisingly?

The reason is a bug in
Integrate[ Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, Infinity}].
But see below for more comments and _another_ bug.

In[1]:=
NIntegrate[Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, Infinity}]

Out[1]=
4.058558368509705

NIntegrate is normally fairly trustworthy, in my experience.

In[2]:=
Integrate[Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, Infinity}]

Out[2]=
(-8 + 9*E^(1/10)*ExpIntegralEi[-(1/10)])/Log[1024]

In[3]:=
N[%]

Out[3]=
-3.7700193602844947

This is clearly wrong. After all, the integrand is _nonnegative_. There's
a bug somewhere.

Also note that N[Integrate[...]], which is what you had done, is formally
equivalent to NIntegrate[...] only when a symbolic antiderivative cannot
be computed.

In[4]:=
Integrate[Log[2, 1 + 10*x]*Exp[-x]*x, x]

Out[4]=
(9*E^(1/10 + x)*ExpIntegralEi[-(1/10) - x] - 10*(1 + (1 + x)*Log[1 +
10*x]))/(E^x*(10*Log[2]))

In[5]:=
% /. x -> 0

Out[5]=
(-10 + 9*E^(1/10)*ExpIntegralEi[-(1/10)])/(10*Log[2])

In[6]:=
Limit[%%, x -> Infinity]

Out[6]=
0

In[7]:=
N[% - %%]

Out[7]=
4.058558368462288

This is correct, indeed, to the last decimal place. As such, it is more
accurate than Out[1].

Now for a different method.

In[8]:=
Assuming[a > 0, Integrate[Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, a}]]

Out[8]=
(10 + E^a*(-10 + 11*E^(1/10)*ExpIntegralEi[-(1/10)] + 11*E^(1/10)*Gamma[0,
1/10 + a]) - 10*(1 + a)*Log[1 + 10*a])/(E^a*(10*Log[2]))

In[9]:=
Limit[%, a -> Infinity]

Out[9]=
(-10 - 11*E^(1/10)*Gamma[0, 1/10])/(10*Log[2])

In[10]:=
N[%]

Out[10]=
-4.63986133014525

This is, of course, incorrect. There was a bug (different from the earlier
one) causing Out[8] to be wrong.

David Cantrell


  • Prev by Date: Re: Alternative to bivariate Taylor series
  • Next by Date: RE: Re: filled plot on part of x-interval
  • Previous by thread: Re: Why two results of same eq. are different?
  • Next by thread: RE: [Integrate] Why two results of same eq. are different?