Why does this happen?

Discussion in 'Mathematica' started by Budaoy, Jul 6, 2007.

  1. Budaoy

    Budaoy Guest

    I have a problem in calculating this integral shown below:

    Integrate[Log[1+Exp[x]/Sqrt[x]],{x,0,Infinity}]
    Pi^2/6

    N[%]
    1.64493

    NIntegrate[Log[1+Exp[x]/Sqrt[x]],{x,0,Infinity}]
    1.01799

    Where does this difference come from and which one is correct?
     
    Budaoy, Jul 6, 2007
    #1
    1. Advertisements

  2. How did you get these results? On what platform are you working?

    (* Mathematica 6.0 -- Similar messages with 5.2 *)

    In[1]:= Integrate[Log[1 + Exp[x]/Sqrt[x]], {x, 0, Infinity}]

    During evaluation of In[1]:= Integrate::idiv: Integral of Log[1+\
    \[ExponentialE]^x/Sqrt[x]] does not converge on {0,\[Infinity]}. >>

    Out[1]= Integrate[Log[1 + E^x/Sqrt[x]], {x, 0, Infinity}]

    In[2]:= NIntegrate[Log[1 + Exp[x]/Sqrt[x]], {x, 0, Infinity}]

    During evaluation of In[2]:= NIntegrate::inumri: The integrand Log[1+\
    \[ExponentialE]^x/Sqrt[x]] has evaluated to Overflow, Indeterminate, \
    or Infinity for all sampling points in the region with boundaries \
    {{0.,4.64782*10^14}}.

    Out[2]= NIntegrate[Log[1 + E^x/Sqrt[x]], {x, 0, Infinity}]

    Regards,
    Jean-Marc
     
    Jean-Marc Gulliet, Jul 7, 2007
    #2
    1. Advertisements

  3. Budaoy

    dimitris Guest

    Budaoy :
    First of all you should tell us WHAT version you use.

    In 5.2 you get

    In[21]:=
    Integrate[Log[1+Exp[x]/Sqrt[x]],{x,0,Infinity}]

    \!\(\*
    RowBox[{\(Integrate::"idiv
    "\), \(\:)\)\(\ \)\), "\"\<Integral of Log[1 +
    E^x/Sqrt[x]] does not converge on {0, }. \!\(
    \*ButtonBox[\(More...\),
    ButtonData:>\\\"Integrate::idiv\\\",
    ButtonStyle->\\\"RefGuideLinkText\\\",
    ButtonFrame->\\\"None\\\"]\)\>\""}]\)

    Out[21]=
    Integrate[Log[1 + E^x/Sqrt[x]], {x, 0, Infinity}]

    which is correct.

    In another CAS I use, I also took

    convert("Integrate[Log[1 + Exp[x]/Sqrt[x]], {x, 0, Infinity}]
    ",FromMma);value(%);

    infinity
    /
    | exp(x)
    | ln(1 + -------) dx
    | sqrt(x)
    /
    0
    infinity

    The problem arise from the behavior of the integrand at infinity.

    Try

    In[29]:=
    Series[Log[1 + Exp[x]/Sqrt[x]], {x, Infinity, 3}]
    (*essential singularity messages are ommited*)
    Out[29]=
    Log[E^x + SeriesData[x, Infinity, {1}, -1, 7, 2]] + SeriesData[x,
    Infinity, {Log[x^(-1)]/2}, 0, 6, 2]

    As regards numerical integration,

    In[23]:=
    NIntegrate[Log[1+Exp[x]/Sqrt[x]],{x,0,Infinity},SingularityDepth-
    \!\(\*
    RowBox[{\(NIntegrate::"ncvb"\), \(\:)\)\(\ \)\), "\<\"NIntegrate
    failed
    to converge to prescribed accuracy
    after \\!\\(7\\) recursive bisections in \\!\\(x\\) near \\!\\(x\
    \) = \\!\
    \\(255.`\\). \\!\\(\\*ButtonBox[\\\"More...\\\", \
    ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \
    ButtonData:>\\\"NIntegrate::ncvb\\\"]\\)\"\>"}]\)

    Out[23]=
    7.022806219872675*^8

    So, the conclusion is that the integral diverges.

    If you want Mathematica's integrator to be more carefully
    regarding convergence checking use the setting
    GenerateConditions->True (at least from version 3 and up
    to 5.2; I don't have version 6 to check it).

    BTW,

    I notice that in version 5.2 we have (*watch the minus sign in the
    exponential*)

    In[58]:=
    Integrate[Log[1 + Exp[-x]/Sqrt[x]], {x, 0, Infinity}]

    Out[58]=
    Pi^2/6

    In[56]:=
    N[%]

    Out[56]=
    1.6449340668482262

    In[59]:=
    NIntegrate[Log[1 + Exp[-x]/Sqrt[x]], {x, 0, Infinity}]

    Out[59]=
    1.0179913870581465

    I think that Vladimir Bondarenko discovered that this bug exists also
    in version 6!
    (in a thread in another forum).

    Dimitris
     
    dimitris, Jul 7, 2007
    #3
  4. Budaoy

    David Reiss Guest

    Perhaps you meant a different integral? The one you posted increases
    monotonically positive as x->Infinity.

    --David
     
    David Reiss, Jul 7, 2007
    #4
  5. Budaoy

    David Reiss Guest

    Oops, my bad. I see that there was only a typo in your expression:
    the Exp should have had a - sign in its argument:

    Integrate[Log[1+Exp[-x]/Sqrt[x]],{x,0,Infinity}]
     
    David Reiss, Jul 7, 2007
    #5
  6. Budaoy

    dh Guest

    Hi Budaoy,

    look at your integrand. For large x you can neglect 1 and get

    Log[Exp[x]/Sqrt[x], but this is Log[Exp[x]]-Log[Sqrt[x]], where the

    first part is mach larger than the second. Therefore the integrand is

    approx.: x. This means, the integral does not exisit.

    hope this helps, Daniel


     
    dh, Jul 7, 2007
    #6
  7. Budaoy

    David Reiss Guest

    OK, since most folks didn't catch Budasoy's typo in the Exp. Here is
    an "analysis" of the problem (Mathematica 6.01. There does appear to
    be a numerical inconsisstency between the exact result and the
    numerical one. Is this possibly due to the singularity of the
    integrand at 0? Or perhaps we have a bug... 'tis not clear to me
    before my morning coffee...


    (M 6) In[1]:= Integrate[Log[1 + Exp[-x]/Sqrt[x]], {x, 0, Infinity}]


    (M 6) Out[1]= \[Pi]^2/6

    (M 6) In[2]:= Limit[Log[1 + Exp[-x]/Sqrt[x]], x -> Infinity]

    (M 6) Out[2]= 0

    (M 6) In[3]:= Limit[Log[1 + Exp[-x]/Sqrt[x]], x -> 0]

    (M 6) Out[3]= \[Infinity]

    (M 6) In[4]:= N[\[Pi]^2/6]

    (M 6) Out[4]= 1.64493

    (M 6) In[5]:= Table[
    NIntegrate[Log[1 + Exp[-x]/Sqrt[x]], {x, 10^-n, n 10}], {n, 1, 10}]


    (M 6) Out[5]= {0.837883, 0.989369, 1.01402, 1.01748, 1.01793, \
    1.01798, 1.01799, 1.01799, 1.01799, 1.01799}

    (M 6) In[6]:= Integrate[Log[1 + Exp[-a x]/x^(1/n)], {x, 0, Infinity},
    Assumptions -> {Re[1/n] < 1, a > 0}]


    (M 6) Out[6]= (n \[Pi]^2)/(12 a (-1 + n))

    (M 6) In[7]:= (n \[Pi]^2)/(12 a (-1 + n)) /. {n -> 2, a -> 1}

    (M 6) Out[7]= \[Pi]^2/6

    (M 6) In[8]:= quickanddirty[delta_] :=
    Module[{data},

    data = Table[
    [email protected][1 + Exp[-x]/Sqrt[x]], {x, 10^-5, 10, delta}];

    Tr[data delta]
    ];

    (M 6) In[9]:= quickanddirty[10^-2]

    (M 6) Out[9]= 1.05924

    (M 6) In[10]:= quickanddirty[10^-3]

    (M 6) Out[10]= 1.02151

    (M 6) In[11]:= quickanddirty[10^-4]

    (M 6) Out[11]= 1.01823
     
    David Reiss, Jul 8, 2007
    #7
  8. Budaoy

    dimitris Guest

    David Reiss :
    It is a bug in Integrate.
    NIntegrate's result is correct!

    Dimitris
     
    dimitris, Jul 9, 2007
    #8
  9. Budaoy

    dreiss Guest

    yes indeed... hence my post....


     
    dreiss, Jul 10, 2007
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.