# Integral with DiracDelta. Can Mathematica be made to solve this?

This was an exam question.

$$\int_0^{2 \pi} \delta(\sin^2(\theta) -x ) \,d\theta$$

Direct use of Integrate on it does not give the solution. Is there a trick or workaround? Here is the code I used

ClearAll[theta,x]
integrand = DiracDelta[Sin[theta]^2 - x]
Integrate[ integrand, {theta, 0, 2 Pi}]


Here is the key solution analytical solution

The solution uses this known relation (half way down the Wikipedia page)

Where the sum above is over all zeros of $$g(x)$$ in the integration interval. Mathematica does not seem to know this relation?

ps. Maple can't do it either.

• The integral under consideration makes no sense in traditional math: DiracDelta is not a usual function, but a distribution (see en.wikipedia.org/wiki/Dirac_delta_function as a first reading). Commented May 9, 2019 at 6:29

You need to give Integrate assumptions:

Integrate[DiracDelta[Sin[θ]^2-x], {θ, 0, 2 π}, Assumptions -> 0<x<1]


2/Sqrt[-(-1 + x) x]

Unfortunately, Integrate is not quite smart enough to use the assumption x ∈ Reals:

Integrate[DiracDelta[Sin[θ]^2-x], {θ, 0, 2 π}, Assumptions -> x ∈ Reals]


Integrate[DiracDelta[-x + Sin[θ]^2], {θ, 0, 2 π}, Assumptions -> x ∈ Reals]

• Nice! For some reason, this does not work for exponents other than 2 (e.g., Sin[θ]^3 - x). My code does not work either, presumably for the same reason (Solve is unable to determine the roots). Any idea how to work around this? Commented May 8, 2019 at 20:55
• @AccidentalFourierTransform One hack is to replace x with EulerGamma, that will produce a result for Sin[θ]^3 - x, which you can then extrapolate into a generic answer. Commented May 8, 2019 at 21:18
• The integral under consideration makes no sense in traditional math: DiracDelta is not a usual function, but a distribution (see en.wikipedia.org/wiki/Dirac_delta_function as a first reading). Commented May 9, 2019 at 6:30
f[θ_, x_] := Sin[θ]^2 - x
Derivative[1, 0][f][θ, x] /. Solve[{f[θ, x] == 0, 0 < θ < 2 π}, θ, Reals]
Integrate[DiracDelta[x - θ]/Abs[%], {θ, 0, 2 π}] // Total


This code should also work for other functions $$f$$, presumably.

• You have an extra [θ, x], and your Solve would work better if you added the domain Reals. Probably more robust than just relying on Integrate. Commented May 8, 2019 at 21:16
• @CarlWoll Ah, yes, thank you! Commented May 8, 2019 at 21:28
• The integral under consideration makes no sense in traditional math: DiracDelta is not a usual function, but a distribution (see en.wikipedia.org/wiki/Dirac_delta_function as a first reading). Commented May 9, 2019 at 6:30