From: Jason Quinn on
If I open Mathematica 7.01.0 (64-bit Linux version) that only contains
the following input in a single cell,

Assuming[\[Sigma] > 0, Integrate[p/((Pi*\[Sigma]^2)*E^((p^2 -
2*p*p0*Cos[2*(\[Phi] - \[Phi]0)] + p0^2)/(2*\[Sigma]^2))), {p0, 0,
Infinity}]]

When I hit shift-enter, I get an answer. If I hit, shift-enter a
second time, I get a different answer. Can anybody tell me why? This
seems like a bug. It happens even if I clear all the variables used in
the calculation.

Jason

PS This version of Mathematica on Linux has been extremely buggy for
me. Abort and Interrupt do not work properly. Mathematica crashes very
frequently and seems to revert my documents back to the state they
when when I opened Mathematica even if I have saved in the mean time.
Palletes and other floating popups do not function properly with the
window manager on Ubuntu and sometimes have no title bar or other
means to move them around.

PPS The two answers are

(E^(-((p^2 Sin[2 \[Phi] - 2 \[Phi]0]^2)/(
2 \[Sigma]^2))) p (Sqrt[p^2 Cos[2 \[Phi] - 2 \[Phi]0]^2] +
p Cos[2 \[Phi] - 2 \[Phi]0] Erf[Sqrt[(
p^2 Cos[2 \[Phi] - 2 \[Phi]0]^2)/\[Sigma]^2]/Sqrt[
2]]))/(Sqrt[\[Pi]] \[Sigma] Sqrt[
p^2 (1 + Cos[4 \[Phi] - 4 \[Phi]0])])



and


(E^(-((p^2 Sin[2 \[Phi] - 2 \[Phi]0]^2)/(
2 \[Sigma]^2))) p (1 +
Erf[(p Cos[2 \[Phi] - 2 \[Phi]0])/(Sqrt[2] \[Sigma])]))/(Sqrt[
2 \[Pi]] \[Sigma])


From: Bill Rowe on
On 5/12/10 at 7:33 AM, jason.lee.quinn(a)gmail.com (Jason Quinn) wrote:

>If I open Mathematica 7.01.0 (64-bit Linux version) that only
>contains the following input in a single cell,

>Assuming[\[Sigma] > 0, Integrate[p/((Pi*\[Sigma]^2)*E^((p^2 -
>2*p*p0*Cos[2*(\[Phi] - \[Phi]0)] + p0^2)/(2*\[Sigma]^2))), {p0, 0,
>Infinity}]]

>When I hit shift-enter, I get an answer. If I hit, shift-enter a
>second time, I get a different answer. Can anybody tell me why? This
>seems like a bug. It happens even if I clear all the variables used
>in the calculation.

I get the same results using Mathematica 7.01 on Mac OS X. The
two results look to be equivalent with the second result being
simpler than the first. When Integrate does its thing, it caches
intermediate results. The first time you execute Integrate, it
returns an answer likely based on the first solution found and
time constraints built into the algorithms Integrate uses. But
the second time you execute Integrate, the intermediate results
are still available in a cache. These intermediate results allow
further simplification within whatever constraints are built
into Integrate.


From: Nasser M. Abbasi on

"Jason Quinn" <jason.lee.quinn(a)gmail.com> wrote in message
news:hse3lp$34s$1(a)smc.vnet.net...
> If I open Mathematica 7.01.0 (64-bit Linux version) that only contains
> the following input in a single cell,
>
> Assuming[\[Sigma] > 0, Integrate[p/((Pi*\[Sigma]^2)*E^((p^2 -
> 2*p*p0*Cos[2*(\[Phi] - \[Phi]0)] + p0^2)/(2*\[Sigma]^2))), {p0, 0,
> Infinity}]]
>
> When I hit shift-enter, I get an answer. If I hit, shift-enter a
> second time, I get a different answer. Can anybody tell me why? This
> seems like a bug. It happens even if I clear all the variables used in
> the calculation.
>
> Jason
>
> PS This version of Mathematica on Linux has been extremely buggy for
> me. Abort and Interrupt do not work properly. Mathematica crashes very
> frequently and seems to revert my documents back to the state they
> when when I opened Mathematica even if I have saved in the mean time.
> Palletes and other floating popups do not function properly with the
> window manager on Ubuntu and sometimes have no title bar or other
> means to move them around.
>
> PPS The two answers are
>
> (E^(-((p^2 Sin[2 \[Phi] - 2 \[Phi]0]^2)/(
> 2 \[Sigma]^2))) p (Sqrt[p^2 Cos[2 \[Phi] - 2 \[Phi]0]^2] +
> p Cos[2 \[Phi] - 2 \[Phi]0] Erf[Sqrt[(
> p^2 Cos[2 \[Phi] - 2 \[Phi]0]^2)/\[Sigma]^2]/Sqrt[
> 2]]))/(Sqrt[\[Pi]] \[Sigma] Sqrt[
> p^2 (1 + Cos[4 \[Phi] - 4 \[Phi]0])])
>
>
>
> and
>
>
> (E^(-((p^2 Sin[2 \[Phi] - 2 \[Phi]0]^2)/(
> 2 \[Sigma]^2))) p (1 +
> Erf[(p Cos[2 \[Phi] - 2 \[Phi]0])/(Sqrt[2] \[Sigma])]))/(Sqrt[
> 2 \[Pi]] \[Sigma])
>
>

I get the same behavior on windows 7 XP2, using M7

But the good thing is that, both results are correct, as can be seen by
using FullSimplify:

Assuming[\[Sigma] > 0, FullSimplify[
Integrate[p/((Pi*\[Sigma]^2)*E^((p^2 - 2*p*p0*Cos[2*(\[Phi] - \[Phi]0)] +
p0^2)/(2*\[Sigma]^2))),
{p0, 0, Infinity}]]]

You will now get the second, shorter looking result.

My guess of what happens is this: When you first run the command, some
internal package gets loaded, but it is loaded in some order by which its
effect does not show up yet.

When you run the command again, now this package is loaded, and its effect
shown up. The effect is just more simplification is done on the expression.

--Nasser