Using a function without specifying it
I want to ask sagemath if
$\int_{-\infty}^\infty |x - a| f(x) dx = \int_{-\infty}^a (a -x) f(x) dx + \int_{a}^\infty (x -a) f(x) dx$
which is obviously true without specifying $f(x)$ (a probability density). Is this possible in SageMath ?
I would assume the left-hand side is computed via
but it somehow fails.
Sorry there was a little mistake. I correct it in the text
According to your remark the question is why SageMath is not able return
true
tobool(definite_integral(abs_symbolic(x-a)*f(x), x, -oo, +oo)==definite_integral(abs_symbolic(a-x)*f(x), x, -oo, a)+definite_integral(abs_symbolic(x-a)*f(x), x, a, +oo))
.One could imagine rewriting the left-hand side by substituting $\lvert x-a \rvert = (x-a)\cdot \chi_{\geqslant a}(x) + (a-x)\cdot \chi_{\lt a}(x)$ where the $\chi$'s are indicator functions, expanding the integrand, using linearity of the integral, and replacing the indicator function factors by narrowed integration bounds. That's easier said than done-with-Sage, though.
This is true for a real function of a real variable and for a real ; in this case,$|x-a|$ is of course either $x-a$ or $a-x$ depending on the sign of $x-a$. If either $x$ or $a$ is complex, this is no longer true.
Furthermore, in the complex case, you may have discrepancies if the integration paths of the left and right hands of your equation loop around different poles.