# Integral of function involving Dirac delta

I am performing lots of simple calculations with dirac delta functions. It would be awesome if Mathematica could do this routine exercise for me, eliminating any possible human errors. For example, this integral:

Integrate[DiracDelta[t - a - (r^2 + (z - a)^2)^(1/2)] /
(4 Pi (r^2 + (z - a)^2)^(1/2)), {a, -Infinity, Infinity}]


Mathematica does not know how to evaluate it.

I tried using FunctionalExpand to expand the delta-function, but in this case it does nothing. But I can easily take the integral above manually.

Maybe there is a way of evaluating such integrals automatically?

• This integral makes no sense in traditional math (see Encyclopedia of Mathematics and references there). Aug 13, 2021 at 19:41

Adding assumptions finds two of the cases.

Assuming[{a, t, r, z} ∈ Reals && t > z,
Integrate[
DiracDelta[
t - a - (r^2 + (z - a)^2)^(1/2)]/(4 Pi (r^2 + (z - a)^2)^(1/2)),
{a, -Infinity, Infinity}]
]
(*  1/(4 π t - 4 π z)  *)

Assuming[{a, t, r, z} ∈ Reals && t < z,
Integrate[
DiracDelta[
t - a - (r^2 + (z - a)^2)^(1/2)]/(4 Pi (r^2 + (z - a)^2)^(1/2)),
{a, -Infinity, Infinity}]
]
(*  (-t + z)/(4 π r^2)  *)


The case t == z seems to reveal a bug:

Assuming[{a, r, z} ∈ Reals,
Integrate[
DiracDelta[
t - a - (r^2 + (z - a)^2)^(1/2)]/(4 Pi (r^2 + (z - a)^2)^(1/2)) /. t -> z,
{a, -Infinity, Infinity}]
]


Select::normal: Nonatomic expression expected at position 1 in Select[IntegrateImproperDumpnewx,IntegrateNLtheoremDumpsel\$293548]. >> • At t==z, the argument of DiracDelta vanishes only at Infinity. Feb 12, 2015 at 16:38
• @bbgodfrey Yes, however, the interesting thing to me (with respect to this site) was that the internal code committed a programming error. Feb 12, 2015 at 18:02

Although Mathematica cannot solve

Integrate[DiracDelta[g[x]] h[x], x]


as written, it can be transformed to

Integrate[DiracDelta[x-x0] h[x] / (Abs[D[g, x]]/.x -> x0), x]


using standard formulas, where g[x0] == 0. (Note that, if g[x] has multiple real zeroes, the preceding expression must be summed over those zeroes.)

This can be applied to the specific case here as follows, with q the original integral:

arg = Cases[q, DiracDelta[z_] -> z, Infinity];
a0 = a /. First@Solve[arg == 0, a];
q /. DiracDelta[z_] :> DiracDelta[a - a0]/(Abs[D[arg, a] /. a -> a0])

(* {Boole[-Infinity < -((r^2 - t^2 + z^2)/(2*t - 2*z)) < Infinity]/
(2*Pi*Sqrt[(r^2 + (t - z)^2)^2/(t - z)^2]*
Abs[1 + (-r^2 + (t - z)^2)/(Sqrt[(r^2 + (t - z)^2)^2/(t - z)^2]*(t - z))])} *)


If the constants contained in the argument of Boole are real, it evaluates to 1, and the expression greatly simplifies.

Assuming[{a, t, r, z} \[Element] Reals, Simplify[%]]
(* Piecewise[{{(4*Pi*t - 4*Pi*z)^(-1), t >= z}}, (-t + z)/(4*Pi*r^2)] *)


(This is, of course, the approach used by Alexei Boulbitch in his earlier answer.)

• I think there's something missing from your code -- q at least -- but I can't reproduce your answer. I guess I'm brain-dead or something. If you Simplify your answer with assumptions that the variables are real, it comes out nice. Feb 12, 2015 at 15:57
• @MichaelE2 Sorry, q is the original integral. I have updated my answer (and also rerun the code to assure that it works). Thanks for pointing out the omission. Feb 12, 2015 at 16:15
• +1 It works now. Note also if I use q = Inactivate[<integral>, Integrate] and then Activate on the last line, I save myself about 6 seconds on the first, fruitless attempt at the integral. Feb 12, 2015 at 16:29
• @MichaelE2 Thanks for the Inactivate suggestion. By the way, I simplified my final result by assuming all constants are real, as you did. Feb 12, 2015 at 16:31
• My question was whether this could be done automatically or not. Feb 13, 2015 at 14:08

Try this:

    1/(4 Pi (r^2 + (z - a)^2)^(1/2)) /. (Solve[
t - a - (r^2 + (z - a)^2)^(1/2) == 0, a][[1, 1]]) // Simplify

(*  1/(2 \[Pi] Sqrt[(r^2 + (t - z)^2)^2/(t - z)^2])  *)


Have fun!