# Numerical integration of a function with Dirac delta

I have a little question about the numerical integration of a function that includes a Dirac delta. I have the following function:

f[x_,y_,z_]=Cot[x + z] Cot[x - y z] (-Cot[x - y z] Csc[x + z]^2 + y Cot[x + z] Csc[x - y z]^2)


Then I have to compute the following integral:

NIntegrate[DiracDelta[y - 1] f[x, y, z], {x, 0.1, 0.2}, {y, -Infinity,Infinity},{z, 0, x + y},AccuracyGoal->5]


The idea is: evaluate the symbolic integral in the variable 'z', then evaluate the resulting function of 'x' and 'y' for 'y=1' (this is perfermed by the integration of the Dirac delta), then compute the integral on the variable 'x'.

With numerical integration I obtaine the result of '0.',but it is not correct. I have tried with non-numerical integral:

Integrate[DiracDelta[y - 1] f[x, y, z], {x, 0.1, 0.2}, {y, -Infinity,Infinity},{z, 0, x + y}]


and I obaine the result of '-142.527'.

I need this numeric integral because, the function f[x,y,z], might not admit a primitive closed function.

Thanks for any tips and helps!

• Since z goes past x it looks like it diverges? Commented Jan 3, 2022 at 20:56
• I don't think it diverges, infact the analitic integral converges at '-142.527'. I think the problem is in the integration of the Dirac delta function... Commented Jan 3, 2022 at 21:10
• I can use a simplier function like 'f[x_,y_,z_]=x y z', the analitic integral gives the correct result, the nuemrical integral gives me '0' Commented Jan 3, 2022 at 21:13
• @Lorenzo Your Integrate expression returns the input with an error: "Integral of Cos[2 x] Csc[x-z]^2 Csc[x+z]^2 DiracDelta[-1+y] Sin[2 z] does not converge on {0, x+y}." on MMA 12.0 (Win10-64). How did you get that -142 numerical value? Commented Jan 3, 2022 at 21:36
• I am sorry, you all are right; I wrote the wrong function. I'm going to edit my question. Commented Jan 3, 2022 at 21:51

Mathematica Can compute this integral symbolically:

\$Version
(* "13.0.0 for Microsoft Windows (64-bit) (December 3, 2021)"*)

f[x_, y_, z_] = Cot[x + z] Cot[
x - y z] (-Cot[x - y z] Csc[x + z]^2 + y Cot[x + z] Csc[x - y z]^2);

Z = Integrate[f[x, y, z], {z, 0, x + y}, Assumptions -> {x > 0, y \[Element] Reals}]

(*Long time computation about few minutes*)

(*1/2 (-Cos[2 x] Csc[x]^4 +
Cos[3 x + y - y (x + y)] Cos[x + y + y (x + y)] Csc[2 x + y]^2 Csc[
x - y (x + y)]^2)*)

Y = Integrate[DiracDelta[y - 1] Z[[1]], {y, -Infinity, Infinity}, Assumptions -> x > 0]
(*-(1/2) Cos[2 x] (Csc[x]^4 - Cos[2 + 2 x] Csc[1]^2 Csc[1 + 2 x]^2)*)

X = Integrate[Y, {x, 1/10, 2/10}]
(*-(1/6) (1 + 3 Cos[1/5] + 3 Cos[2/5]) Csc[1/5]^3 +
1/40 Csc[1]^2 (-2 + 5 Cos[2] (Cot[6/5] - Cot[7/5]) +
Csc[1] (-5 Csc[6/5] Sin[1/5] + 5 Csc[7/5] Sin[2/5]))*)

X//N
(*-142.527*)

• The integral Integrate[DiracDelta[y - 1] Z[[1]], {y, -Infinity, Infinity}, Assumptions -> x > 0] makes no sense in math. That was discussed here many times. Both Encyclopedia of Mathematics and W. Rudi, Functional analysis say nothing about the definite integrals of distributions. Commented Jan 4, 2022 at 13:27
• @user64494 ,The integral makes sense in math. That was discussed here many times. Commented Jan 4, 2022 at 13:30
• Can you give a serious math reference instead of your ungrounded claim? TIA. Commented Jan 4, 2022 at 13:33
• Thanks for the answer, but there can be cases of functions f[x,y,z] that can not be integrated symbolically, and I can't use your prescription... For example if the function is 'f[x_,y_,z_]=Exp[-z^2 Exp[-z^2]]' , the symbolic integrate doesen't work... Commented Jan 4, 2022 at 13:37
• And @user64494, the integral makes perfect sense. It is an example of the first integral presented in the encyclopediaofmath.org/wiki/Delta-function paper you referenced me that verified one of my previous answers. Commented Jan 5, 2022 at 6:48