0
$\begingroup$

I have trouble evaluating a simple integral in Mathematica. I have the code:

integrand = f[1/x] DiracDelta[-r0 + rm - rm x + rp x]
Assuming[{rp, rm, r0} \[Element] Reals && rp > 0 && rm > 0 && r0 > 0, Integrate[integrand, {x, -\[Infinity], \[Infinity]}]]
(*Integral of ... does not converge on ...*)

This surprised me, since using the usual dirac delta identity is $$ \delta(g(x)) = \sum_i \frac{\delta(x-x_i)}{|g'(x_i)|} \ \ \ \ \text{where}\ x_i\ \text{are roots of}\ g $$ We can say $$ \delta(-r0 + rm - rm \ x + rp \ x) = \frac{\delta(x- \frac{r0+rm}{rm-rp})}{|rp-rm|} $$ and inserting this into Mathematica I get the "correct" result:

integrand2 = DiracDelta[-((-r0 + rm)/(rm - rp)) + x]/Abs[-rm + rp] f[1/x]
    Assuming[{rp, rm, r0} \[Element] Reals && rp > 0 && rm > 0 && r0 > 0, Integrate[integrand2, {x, -\[Infinity], \[Infinity]}]]
    (*f[(-rm + rp)/(r0 - rm)]/Abs[rm - rp]*)

My question is why doesn't the first code integrate to the correct value?

$\endgroup$
2
  • $\begingroup$ The support of DiracDelta[-r0 + rm - rm x + rp x] is x==(-r0 + rm)/(rm - rp). This does not make sense if rm==rp in both cases you considered. $\endgroup$
    – user64494
    Sep 25, 2023 at 13:40
  • $\begingroup$ rm = 1 + I; rp = 1; r0 = 1; integrand2 = DiracDelta[-((-r0 + rm)/(rm - rp)) + x]/Abs[-rm + rp] f[1/x]; Integrate[integrand2, {x, -\[Infinity], \[Infinity]}] results in f[1]. All this would be funny if it isn't so sad. $\endgroup$
    – user64494
    Sep 25, 2023 at 14:28

1 Answer 1

1
$\begingroup$

Mathematica's DiracDelta shows problems with scaling property.

As a workaround try

dirac = Function[x, Exp[-(x^2/(2 eps))]/Sqrt[2 Pi eps]] 

Assuming[{rp, rm, r0} \[Element] Reals && rp > 0 && rm > 0 && r0 > 0 &&eps > 0, 
Integrate[1 dirac [-r0 + rm - rm x + rp x], {x, -\[Infinity], \[Infinity]}]]
(*1/Abs[rm - rp]*)

which gives the correct scaling factor.

The integral you asked for follows to f[(rp-rm)/(rm-r0)]/Abs[rm - rp]

Hope it helps!

$\endgroup$
1
  • $\begingroup$ The result of Assuming[{rp, rm, r0} \[Element] Reals && rp > 0 && rm > 0 && r0 > 0 && eps > 0, Integrate[ 1 dirac[-r0 + rm - rm x + rp x], {x, -\[Infinity], \[Infinity]}, GenerateConditions -> True]] is the same! We see the implementation of DiracDelta in Mathematica leaves much to be desired. $\endgroup$
    – user64494
    Sep 25, 2023 at 13:56

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.