Re: Integration in Mathematica

*To*: mathgroup at smc.vnet.net*Subject*: [mg92161] Re: [mg92123] Integration in Mathematica*From*: danl at wolfram.com*Date*: Mon, 22 Sep 2008 05:25:34 -0400 (EDT)*References*: <200809200902.FAA12037@smc.vnet.net>

> Dear group, > > Let > > f[n_]:= Sin[Pi x] Cos[Pi x] Sin[n Pi x]; > > We then want to integrate f[n] w.r.t. x from 0 to 1 and therefore > issue the command > > Integrate[f[n],{x,0,1}] > > which yields > > Sin[n Pi]/((-4 + n^2) Pi) > > If we assume that n is an integer, the result is 0. > > However, for n=2, the result above is not defined but nevertheless > > Integrate[f[2],{x,0,1}] > > returns 1/4, which is correct. In fact, n=2 is the only integer for > which the integral of f[n] is different from 0. [Other than n=-2, that is.] > This leads me to ask if Mathematica should be able to single out the > case n=2 automatically, or if it at all would be able to. Of course, > the result Sin[n Pi]/((-4 + n^2) Pi) should lead you to examine the > case n=2 closer, but if you in advance told Mathematica to assume that > n is an integer, you would just get a plain 0 as a result. > > What are your thoughts on the example above? > > Regards, > Sigmund Vestergaard This has come up a few times in this forum. The issue is that the simplification capabilities used are not very good at avoiding what amount to discrete cases such as this one, and so one might get "0" instead of "0 except at ...". For the next release of Mathematica, Integrate assumptions involving integrality are largely ignored. It turns out there are some subtleties to this. For example, we are trying to have Assuming[this,Integrate[that]] behave equivalently to Integrate[this,Assumptions->that] The coplications entailed by this sort of thing are what make me a bit hesitant to claim we have it all fully working. That, and the fact that I ran down a lingering bug a couple of days ago involving exazctly this situation, wherein an assumption of integrality was not entirely "removed". Moreover, we actually need such assumptions in order to simplfy conditions we might ourselves generate, even if they cannot safely simplify results. So the situation is as follows. "Remove them, but don't remove them completely. And make sure to do that everywhere." Any wonder I seem confused? As I wrote, it gets a bit complicated. The upshot is at this time we believe it is safer to largely ignore integrality assumptions than to give overly assertive results such as the one you indicate above. It is my hope that this is the behavior one will see once code currently under development goes into release. Daniel Lichtblau Wolfram Research

**References**:**Integration in Mathematica***From:*sigmundv@gmail.com