MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Different answer when running cell second time?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109807] Re: Different answer when running cell second time?
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Tue, 18 May 2010 06:12:58 -0400 (EDT)
  • Organization: Aioe.org NNTP Server
  • References: <hse3lp$34s$1@smc.vnet.net>

"Jason Quinn" <jason.lee.quinn at gmail.com> wrote in message 
news:hse3lp$34s$1 at 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




  • Prev by Date: Re: Multiple FindRoot
  • Next by Date: combining ArrayPlot with ListLinePlot
  • Previous by thread: Re: Different answer when running cell second time?
  • Next by thread: Re: Part specification... is neither an integer nor a