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

wrong result when computing a definite integral

145 views
Skip to first unread message

Dexter Filmore

unread,
Jan 10, 2013, 9:38:22 PM1/10/13
to
hi group,

i run into this problem today when giving a bunch of easy integrals to mathematica.
here's a wolfram alpha link to the problem:
http://www.wolframalpha.com/input/?i=Integrate%5BExp%5BI+Sqrt%5B3%5Dy%5D%2C%7Bx%2C-2Pi%2C2Pi%7D%2C%7By%2C-Pi%2CPi%7D%5D#

the integrand does not depend on the 'x' variable, the inner integration should only result in a factor of 4Pi, and the correct result is a real number, yet the below integral gives a complex number which is far off from the correct value:
Integrate[Exp[I Sqrt[3] y], {x, -2 Pi, 2 Pi}, {y, -Pi, Pi}] -> -((4 I (-1 + E^(2 I Sqrt[3] Pi)) Pi)/Sqrt[3])

from some trial and error it seems the result is also incorrect for non-integer factors in the exponential.

Kevin J. McCann

unread,
Jan 11, 2013, 10:22:49 PM1/11/13
to
Well that is disturbing. If you put parens around the inner (y)
integral, it works correctly. Also, the separate individual integrals
work fine. I cannot figure out why this should be.

Kevin

da...@wolfram.com

unread,
Jan 11, 2013, 10:23:26 PM1/11/13
to
Thank you for the example. I reported this as a bug. I apologize for any inconvenience it may have caused.

Daniel Lichtblau
Wolfram Research

DC

unread,
Jan 11, 2013, 10:24:08 PM1/11/13
to
Just 2 observations :

Integrate[Exp[a y], {x, -2 Pi, 2 Pi}, {y, -Pi, Pi}] works;

Integrate[Exp[I Sqrt[3] y], {y, -Pi, Pi}, {x, -2 Pi, 2 Pi}] works.

Alex Krasnov

unread,
Jan 11, 2013, 10:22:43 PM1/11/13
to
Integrate takes the integration variables in prefix order, so perhaps you
meant the following:

In: Integrate[Exp[I*Sqrt[3]*y], {y, -Pi, Pi}, {x, -2*Pi, 2*Pi}]
Out: (8*Pi*Sin[Sqrt[3]*Pi])/Sqrt[3]

Alex

Murray Eisenberg

unread,
Jan 12, 2013, 9:51:15 PM1/12/13
to
Unless there's some issue of branches of complex functions involved that
I'm missing, it should not matter here which order of integration you
use -- since the limits of integration are constants. However, if you
wrap each integrand in ComplexExpand,

a = Integrate[ComplexExpand[Exp[I*Sqrt[3]*y]], {x, -2*Pi, 2*Pi},
{y, -Pi, Pi}]
b = Integrate[ComplexExpand[Exp[I*Sqrt[3]*y]], {y, -Pi, Pi}, {x,
-2*Pi, 2*Pi}]

then you obtain the same result:

{a, b} // InputForm
{(8*Pi*Sin[Sqrt[3]*Pi])/Sqrt[3], (8*Pi*Sin[Sqrt[3]*Pi])/Sqrt[3]}
a == b
True

On Jan 11, 2013, at 10:22 PM, Alex Krasnov <akra...@eecs.berkeley.edu> wrote:

> Integrate takes the integration variables in prefix order, so perhaps you
> meant the following:
>
> In: Integrate[Exp[I*Sqrt[3]*y], {y, -Pi, Pi}, {x, -2*Pi, 2*Pi}]
> Out: (8*Pi*Sin[Sqrt[3]*Pi])/Sqrt[3]
>
> Thu, 10 Jan 2013, Dexter Filmore wrote:
>
>> i run into this problem today when giving a bunch of easy integrals to mathematica.
>> here's a wolfram alpha link to the problem:
>>
http://www.wolframalpha.com/input/?i=Integrate%5BExp%5BI+Sqrt%5B3%5Dy%5D%2C%7Bx%2C-2Pi%2C2Pi%7D%2C%7By%2C-Pi%2CPi%7D%5D#
>>
>> the integrand does not depend on the 'x' variable, the inner
integration should only result in a factor of 4Pi, and the correct
result is a real number, yet the below integral gives a complex number
which is far off from the correct value:
>> Integrate[Exp[I Sqrt[3] y], {x, -2 Pi, 2 Pi}, {y, -Pi, Pi}] -> -((4 I (-1 + E^(2 I Sqrt[3] Pi)) Pi)/Sqrt[3])
>>
>> from some trial and error it seems the result is also incorrect for non-integer factors in the exponential.

---
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 5 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305






Alex Krasnov

unread,
Jan 14, 2013, 12:01:18 AM1/14/13
to
I should have probably read the problem before posting. There should be no
issue with branches, since Exp is single-valued. Interestingly, the
incorrect result differs by a phase factor of (-2+Sqrt[3])*Pi.

I also noticed that the documentation states that Integrate computes
multiple integrals. It actually computes interated integrals in prefix
notation:

Integrate[f, y, x] <=> Integrate[dy*Integrate[dx*f]]

This is clear from the following example:

In: Integrate[(x^2-y^2)/(x^2+y^2)^2, {y, 0, 1}, {x, 0, 1}]
Out: -Pi/4

In: Integrate[(x^2-y^2)/(x^2+y^2)^2, {x, 0, 1}, {y, 0, 1}]
Out: Pi/4

Since multiple and iterated integrals are equal only through Fubini's
theorem and similar results, perhaps the documentation should be
corrected.

Alex
0 new messages