# Is this a bug in mathematica for integrals of multiple error functions?

I'm scratching my head over the the following result in Mathematica (v11.3)

I'm considering the function

B = Erfc[x] Exp[-x^2/2] + Sqrt[2] Erfc[x/Sqrt[2]] Exp[-x^2]


Wich is smooth near $$x=0$$

For instance Plot[B, {x, -1, 1}] gives

They function is also holomporphic and thus analytically continuable into the complex plane such that Plot3D[Abs[B /. x -> (xp + I y)], {xp, -1, 1}, {y, -1, 1}] gives

But if i integrate it using

 BI = Integrate[B, {x, a, \[Infinity]}]


I get the function

 Sqrt[2 \[Pi]] + Sqrt[\[Pi]/2] Erf[a] (-1 + Erf[a/Sqrt[2]]) +  1/2 a ExpIntegralE[1/2, a^2/2]


which has a discontinuity at $$a=0$$?! See e.g. Plot[BI, {a, -1, 1}]

This should not be able to happen with the integral of a smooth function, right?

$Version (* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *) Clear["Global*"] B = Erfc[x] Exp[-x^2/2] + Sqrt[2] Erfc[x/Sqrt[2]] Exp[-x^2];  If you explicitly state that a is a real value, Mathematica will tell you that the result is conditional on a > 0 BI = Assuming[Element[a, Reals], Integrate[B, {x, a, ∞}]] (* ConditionalExpression[ 1/2 (Sqrt[2 π] Erf[a] (-1 + Erf[a/Sqrt[2]]) + a ExpIntegralE[1/2, a^2/2]), a > 0] *)  With the assumption a > 0 the integral simplifies Assuming[a > 0, FullSimplify[BI]] (* Sqrt[π/2] Erfc[a] Erfc[a/Sqrt[2]] *)  Or more directly, BI2 = Assuming[a > 0, Integrate[B, {x, a, ∞}]] (* Sqrt[π/2] Erfc[a] Erfc[a/Sqrt[2]] *)  The same result is returned for a <= 0 Assuming[a <= 0, Integrate[B, {x, a, ∞}]] == BI2 (* True *)  Consequently, BI2 is the integral for all real a Plot[BI2, {a, -1, 1}]  • So as always, it falls back on always telling mathematics everything. – Mikael Fremling May 14 at 17:05 • Mathematica generally assumes that all variables are complex. If that is not the case, you need to tell Mathematica what your assumptions are. – Bob Hanlon May 14 at 17:11 • I consider this behavior to be a bug. Even assuming$a$is complex, the result for real$a$should be continuous. What you have found is just a workaround. – yarchik May 14 at 17:23 • @BobHanlon But the function is holomorphic, with no branch curt near$x=0$, I don't se why a step function should show up here.... – Mikael Fremling May 15 at 5:22 • @MikaelFremling No one has mentioned it, so perhaps it's not obvious, that the branch-cut problem is not with the integrand but with the formula for the integral, specifically with the exponential integral: Series[a ExpIntegralE[1/2, a^2/2], {a, 0, 0}]. This arises in the antiderivative Integrate[E^(-(x^2/2)) Erfc[x], x], even though is it expressible in terms of the holomorph Erf[]: Try Simplify[% // FunctionExpand, x > 0]` on the result, which seems to produce a valid antiderivative. It might also perform the transformation$x\mapsto ax$, which makes$a=0\$ singular. – Michael E2 May 15 at 17:49