Re: How to make results from Integrate and NIntegrate agree
- To: mathgroup at smc.vnet.net
- Subject: [mg66693] Re: How to make results from Integrate and NIntegrate agree
- From: "David W.Cantrell" <DWCantrell at sigmaxi.org>
- Date: Sat, 27 May 2006 03:51:56 -0400 (EDT)
- References: <e510la$8di$1@smc.vnet.net> <e56ejk$23m$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Paul Abbott <paul at physics.uwa.edu.au> wrote: > In article <e510la$8di$1 at smc.vnet.net>, riazzi at hotmail.com wrote: [snip] > Perhaps you could tell us what the real problem is so that other > approaches could be suggested? I happen to know, from private email, that Will's real problem involves integrating polynomials in x times the fractional part of 1/x. > > So what I'm looking for is a way to make Integrate produce a > > closed-form expression for my integrand that does not produce these > > discontinuities, > > While I'm a big fan of obtaining closed-form expressions, their utility > is variable. Sometimes they are too cumbersome to be useful -- so the > application you have in mind should determine how much work you should > devote to obtaining a closed-form expression. I was able to provide Will with what he needed. I'll just copy here from my email to him: "In any event, let me just give you what you need to get a continuous antiderivative for any polynomial in x times {1/x}: Since {t}, the fractional part of t, is the same as t - Floor[t], all I should need to give you is a continuous antiderivative for x^n*Floor[1/x]. It's (x^(n + 1)*Floor[1/x] + Zeta[n + 1, Floor[1/x] + 1])/(n + 1) for integer n >= 1. For n = 0, you already have the result from my earlier response to you." > Note that, since Fr is the fractional part of 1/x, you can compute the > integral (in this simple example) using Piecewise as follows: > > g[x_] = Piecewise[Table[{1/x - n, 1/(n + 1) <= x < 1/n]},{n, 5}]] > > Integrate[g[x], x] > > but this will not work if you have an infinite number of discontinuities. > > > plus some insight as to why they appear. I'd guess > > the latter has to do with branch cuts in the complex plane for the > > functions involved, and where the solution might have to do with > > picking a different contour or somesuch, but that's getting into areas > > I've long forgotten or never learned. > > David Cantrell and Zdislav V. Kovarik have posted on this topic on > sci.math. Essentially, computer algebra systems often fail to give > continuous antiderivatives for piecewise integrands. That's not the "bad" part, actually, IMO. They also sometimes fail to give continuous antiderivatives for continuous integrands (defined in just one piece). That, I think, is bad, at least when a continuous antiderivative can be expressed easily in closed form. Here's a simple (and important type of) example: In[1]:= Integrate[1/(5 + 3*Cos[t]), t] Out[1]= -1/2*ArcTan[2*Cot[t/2]] The integrand is continuous on R. The above result, however, has jump discontinuities at integer multiples of 2*Pi. Of course, that result is an antiderivative over intervals which do not contain such multiples, but it is not an antiderivative over R. But an antiderivative over R not only exists (of course) but it can be expressed easily in closed form: t/4 - ArcTan[Sin[t]/(3 + Cos[t])]/2 Regards, David Cantrell