I have a very long result in my computation where every term carries two delta functions, e.g. a term in the result is of the following form


All the terms are supposed to be integrated over om1, om2 and om3 but the sum in the first delta functions differs for different terms (instead of om1+om2 it might be om2+om3 or om1+om3). f and g are some arbitrary functions whose further specifications are unimportant (they differ for different terms).

Performing the integration term by term takes a very long time. I just wonder if I can use ReplaceAll to "manually" contract the Delta functions. That is, the upper example would just leave me with the term f[om]*g[-om1] which finally needs to be integrated over om1.

I struggle a little bit, because I don't know how to define a general replacement rule to contract the Delta functions for the different variants and eventually get rid of them in the replacement.

  • $\begingroup$ Such notations as Integrate[DiracDelta[x]*DiracDelta[x - 1], {x, -Infinity, Infinity}] have no sense in traditional math (see en.wikipedia.org/wiki/Dirac_delta_function as a first reading). I see there are traditional math and Wolfram math. $\endgroup$
    – user64494
    Jul 26, 2018 at 21:53

1 Answer 1


This might get you started; probably this is a bit too carely with the signs due to subsitution:

expr = f[om3]*g[om2]*DiracDelta[om1 + om2]* DiracDelta[om - om1 - om2 - om3]
deltas = Cases[expr, DiracDelta[_], ∞];
vars = Union@Cases[deltas, _Symbol, ∞]
eq = Thread[deltas == 0] /. DiracDelta -> Identity
sols = Solve[eq, vars]
expr /. sols[[1]] /. DiracDelta[0] -> 1

f[om] g[-om1]

So what's left is the integration over om and om1.

  • $\begingroup$ Thank you very much. This is exactly what I was looking for. :) $\endgroup$
    – NeverMind
    Jul 26, 2018 at 21:09
  • $\begingroup$ You're welcome. $\endgroup$ Jul 26, 2018 at 21:10
  • $\begingroup$ The integration is threedimensional (om1,om2,om3). With two DiracDelta- functions the integral reduces to one dimension. I think the given example evalutes to f[om] Integrate[ g[om2],om2] $\endgroup$ Jul 27, 2018 at 9:51
  • $\begingroup$ @UlrichNeumann Very good point! (I leave the post as is; it was only meant as hint anyways.) $\endgroup$ Jul 27, 2018 at 9:58
  • $\begingroup$ @Henrik Schumacher Probably both solutions are ok! $\endgroup$ Jul 27, 2018 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.