1
$\begingroup$

I'm testing the following code:

$Version
fRe[x_, σ_] = 1/(Sqrt[2 π] σ) Exp[-(x^2/(2σ^2))];
Integrate[fRe[x, σ]/(x - X), {x, -∞, ∞}, 
  PrincipalValue -> True, Assumptions -> σ > 0 && X < 0]

On one machine (Core i7-4765T) I get this as output:

"9.0 for Linux x86 (32-bit) (November 20, 2012)"
-((Sqrt[2] DawsonF[X/(Sqrt[2] σ)])/σ)

On another machine (EEE PC 1015PN with Intel Atom N570) the result is different:

"9.0 for Linux x86 (32-bit) (November 20, 2012)"
E^(X^2/(2*σ^2))/(2*Sqrt[2*Pi]*σ)
  (-EulerGamma + CoshIntegral[X^2/(2*σ^2)] - 2*Pi*Erfi[X/(Sqrt[2]*σ)] + Log[2] - 
     2*Log[-X] + 2*Log[σ] + SinhIntegral[X^2/(2*σ^2)] + 
       E^(X^2/(2*σ^2))*Derivative[1, 0, 0][Hypergeometric1F1][1, 1, -(X^2/(2*σ^2))])

On both machines Help->About Mathematica gives version number 9.0.0.0.

How is this possible? I'd expect something similar for numerical calculations due to CPU-specific optimized code paths which might lead to different precision for different CPUs, but this is purely symbolic integration, isn't it?

$\endgroup$
  • 7
    $\begingroup$ I did't read your code in detail, but there can be reasons for getting different symbolic results depending on the performance of the computer. Some of the symbolic processing functions, such as Integrate, use various heuristics. They try one approach to solve the problem, work on it for a given amount of time, and if they don't succeed, they try something else. The fast machine might succeed in the allotted time, the slow one may not. These functions also cache partial results. Caching affects performance. This means that evaluating something multiple times will give different results. $\endgroup$ – Szabolcs May 20 '16 at 7:47
  • 2
    $\begingroup$ I'm certain that there's at least one duplicate for this somewhere on this site, you might want to search to find a more detailed explanation. $\endgroup$ – Szabolcs May 20 '16 at 7:48
1
$\begingroup$

THIS IS AN EXTENDED COMMENT RATHER THAN AN ANSWER.

$Version

(*  "10.4.1 for Mac OS X x86 (64-bit) (April 11, 2016)"  *)

fRe[x_, σ_] = 1/(Sqrt[2 π] σ) Exp[-(x^2/(2 σ^2))];

Integrate[fRe[x, σ]/(x - X), {x, -∞, ∞}, 
 PrincipalValue -> True, Assumptions -> σ > 0]

(*  ConditionalExpression[
   -((Sqrt[2]*DawsonF[X/(Sqrt[2]*σ)])/σ), 
   Re[X] > 0 && Im[X] == 0]  *)

The condition requires that X be real, positive

Integrate[fRe[x, σ]/(x - X), {x, -∞, ∞}, 
 PrincipalValue -> True, Assumptions -> σ > 0 && Element[X, Reals]]

(*  ConditionalExpression[
   -((Sqrt[2]*DawsonF[X/(Sqrt[2]*σ)])/σ), X > 0]  *)

The condition requires that X be positive

Integrate[fRe[x, σ]/(x - X), {x, -∞, ∞}, 
 PrincipalValue -> True, Assumptions -> σ > 0 && X > 0]

(*  -((Sqrt[2]*DawsonF[X/(Sqrt[2]*σ)])/σ)  *)

Satisfying the conditions returned the expected result. However, explicitly violating the condition (as in the OP's question) returns the same result

Integrate[fRe[x, σ]/(x - X), {x, -∞, ∞}, 
 PrincipalValue -> True, Assumptions -> σ > 0 && X < 0]

(*  -((Sqrt[2]*DawsonF[X/(Sqrt[2]*σ)])/σ)  *)

% == %%

(*  True  *)

It appears that either the conditions are wrong or the integral for X < 0 is wrong.

Note: I get identical results with version 10.1 and 9.0

$\endgroup$
  • $\begingroup$ Note that DawsonF is an odd function over the reals: DawsonF[u] == -DawsonF[-u]. The integral is actually valid for all real X. Therefore, the conditional result is sufficient, but not necessary. $\endgroup$ – m_goldberg May 20 '16 at 14:26
  • $\begingroup$ Your final comparison % == %% doesn't seem to make a useful point, It is either a tautology (over any common domain) or invalid because you are making the comparison over domains with an empty intersection. $\endgroup$ – m_goldberg May 20 '16 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.