Re: Discrepancy between Integrate and NIntegrate

*To*: mathgroup at smc.vnet.net*Subject*: [mg83617] Re: Discrepancy between Integrate and NIntegrate*From*: "David W.Cantrell" <DWCantrell at sigmaxi.net>*Date*: Sun, 25 Nov 2007 04:31:40 -0500 (EST)*References*: <fi8pjd$gti$1@smc.vnet.net>

chuck009 <dmilioto at comcast.com> wrote: > Jesus David, . . . thanks. Nicely done. Here's the AoPS thread that > this comes from: > > http://www.artofproblemsolving.com/Forum/viewtopic.php?t=175132 > > Maybe you could provide a comment there as well? Otherwise, I'll study > your analysis and post one my own. Thanks again. :) I don't think I'll be posting to the AoPS thread, but having looked at it, I'll make another comment here. The original integral considered there can be done by Mathematica directly as a definite integral: In[2]:= Integrate[Cos[x]/Cosh[x], {x, -Infinity, Infinity}] Out[2]= Pi*Sech[Pi/2] But it can also be done using Mathematica's indefinite integral and then applying Newton-Leibniz: In[6]:= Integrate[Cos[x]/Cosh[x], x] Out[6]= (1/2 + I/2)*E^((1 - I)*x)*(Hypergeometric2F1[1/2 - I/2, 1, 3/2 - I/2, -E^(2*x)] - I*E^(2*I*x)*Hypergeometric2F1[1/2 + I/2, 1, 3/2 + I/2, -E^(2*x)]) In[7]:= indef = FullSimplify[%, Element[x, Reals]] Out[7]= ((-(1/2))*I*((-1)^I*Beta[-E^(2*x), 1/2 - I/2, 0] + Beta[-E^(2*x), 1/2 + I/2, 0]))/(-1)^(I/2) In[8]:= indef /. x -> -Infinity Out[8]= 0 In[9]:= Limit[indef, x -> Infinity] Out[9]= (1/2 + I/2)*(Gamma[1/2 + I/2]*Gamma[3/2 - I/2] - I*Gamma[1/2 - I/2]*Gamma[3/2 + I/2]) In[10]:= FullSimplify[%] Out[10]= Pi*Sech[Pi/2] The above worked correctly because Mathematica's indefinite integral gave an antiderivative which was valid on the whole real line. If you have any further questions, let me know. David