When you actually evaluate the integral, you integrate pA
in the second integral.
In the description you say it should be 1 - pA
, so I'll assume that's what you want.
The fact that the integral doesn't evaluate appears to be a bug in SymPy. Here is a modification that works on my machine.
import sympy as sy
x = sy.symbols('x')
b = 1
sA = b + sy.exp(- sy.Abs(x - xA))
sB = b + sy.exp(- sy.Abs(x - xB))
pA = 1 / (1 + (sB / sA))
sy.N(sy.Integral(pA, (x, 0, 0.5)) + sy.Integral(1 - pA, (x, 0.5, 1)))
Unfortunately this is still horribly slow. Both the fact that this works and the fact that it takes so long could be idiosyncrasies of my installation since I install the development version of sympy regularly.
I would really suggest using some form of numerical integration unless you specifically need a symbolic expression. Given the same initialization and imports above (but not the integral) this can be done like this:
from sympy.mpmath import quad
# Make the expression into a callable function.
pA_func = sy.lambdify([x], pA)
quad(pA_func, [0, .5]) + quad(lambda x: 1 - pA_func(x), [.5, 1])
SciPy also has some integration routines. The following would be an alternative to the above two lines.
from scipy.integrate import quad
# Make the expression into a callable function.
pA_func = sy.lambdify([x], pA)
quad(pA_func, 0, .5)[0] + quad(lambda x: 1 - pA_func(x), .5, 1)[0]
Hope this helps!