Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Integration in Mathematica

1 view
Skip to first unread message

sigm...@gmail.com

unread,
Sep 20, 2008, 5:02:33 AM9/20/08
to
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.

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

David W.Cantrell

unread,
Sep 21, 2008, 11:48:59 PM9/21/08
to
sigm...@gmail.com wrote:
> 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.

Not quite. When n is -2, the integral should be -1/4.

> 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?

As I've mentioned in this newsgroup before, your sort of question could be
avoided if Mathematica were to give a result which is valid for all complex
values of the parameter n. Such a result can be expressed neatly in version
6 of Mathematica using the sine cardinal function, Sinc. Specifically,
Integrate[f[n], {x, 0, 1}] is equal to

1/4 * (Sinc[(n - 2) Pi] - Sinc[(n + 2) Pi])

for all complex values of the parameter n. And BTW, the corresponding
indefinite integral Integrate[f[n], x] is equal to

x/4 * (Sinc[(n - 2) Pi x] - Sinc[(n + 2) Pi x]).

David W. Cantrell

da...@wolfram.com

unread,
Sep 22, 2008, 5:25:28 AM9/22/08
to
> 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

0 new messages