It seems that Mathematica’s handling of principal value integrals fails on some corner cases. Consider these two expressions (which should give the same result):
Integrate[UnitBox[x]/(x0 - x), {x, -Infinity, Infinity},
PrincipalValue -> True, Assumptions -> {x0 > 0}] /. x0 -> 1 // Simplify
Integrate[UnitBox[x]/(x0 - x) /. x0 -> 1, {x, -Infinity, Infinity},
PrincipalValue -> True]
In Mathematica 7.0.0 I get
I Pi+Log[3]
Log[3]
Has this been fixed in later versions? Does anybody have an idea for a (more or less) general workaround?
EDIT: The two expressions above should calculate the same result, the first by calculating a general form of the integral and evaluating it at x0=1, the second by performing the integral with x0 set to 1. Since the Cauchy principal value has a precise mathematical definition, Mathematica should give the same result or decline to answer.
EDIT 2: A perhaps simpler example of the same bug, putting a factor of -1 inside and outside the Integral give different answers (second one gives the correct answer, first one doesn’t):
-Integrate[ UnitBox[x]/(x0 - x), {x, -Infinity, Infinity}, PrincipalValue -> True, Assumptions -> {x0 > 0}]
Integrate[-UnitBox[x]/(x0 - x), {x, -Infinity, Infinity}, PrincipalValue -> True, Assumptions -> {x0 > 0}]
I don’t think this is a bug in
PrincipalValue. In the first linePrincipalValuedoes not work “correctly” because the position of the pole is not known until afterIntegrateis done.EDIT:
I played around in Mathematica a bit and this is exactly what happens. You can see for yourself by using the
Trace[]command. The output is a bit messy (which is why I don’t replicate it here), but you can see where the integration gets done and where the value forx0is substituted and how that messes withPrincipalValue.EDIT2:
So back to solving your actual problem. If you use an Assumption that specifies which side of x=1/2 x0 lies, then the two examples give the same answer.