Search code examples
pythonsympysymbolic-mathsimplification

Simplification of Dirac delta in xδ(x)


I cannot get sympy to simplify xδ(x) to 0, where δ is DiracDelta.

In : simplify(x*DiracDelta(x))
Out: x⋅δ(x)

Is there another simplification routine that would evaluate the terms in factor of Dirac function at the zeros of its argument and check whether they vanish?

This would be useful when constructing piecewise functions, such as f(x)= x H(x) (where H is Heaviside function), whose derivative should be H(x), but is x⋅δ(x) + Heaviside(x) in sympy. Mathematica does simplify xδ(x) to 0.


Solution

  • You can massage x*DiracDelta(x) into 0 by integrating and then differentiating, since integrate understands what is going on and returns 0.

    >>> (x*DiracDelta(x)).integrate(x).diff(x)
    0
    

    This, however, doesn't solve the original problem, and in any case this isn't how it's supposed to work. I raised an issue.