6

I've been having issues with integrating with a Dirac delta. To compute the area of a sphere centered at $(0,0,0)$ it seems to work just fine:

$$\int_{0}^{2\pi}{\int_{0}^{\pi}{\int_{0}^{\infty}{\delta(r-\rho)r^2\sin\theta\, dr}\,d\theta}\,d\phi} = 4\pi\rho^2$$

Now I will take the same sphere but offset by $(0,0,\rho)$, that is: $x^2 + y^2 + (z-\rho)^2 = \rho^2$. Going to spherical coordinates yields: $r^2\cos^2\phi\sin^2\theta + r^2\sin^2\phi\sin^2\theta + (r\cos\theta-\rho)^2 = \rho^2$, which yields: $r(r-2\rho\cos\theta)=0$, and we can express the sphere in spherical coordinates as: $r(\theta) = 2\rho\cos\theta, \theta \in [0,\pi/2], \phi\in[0,2\pi]$. Integrating yields: $$\int_{0}^{2\pi}{\int_{0}^{\frac{\pi}{2}}{\int_{0}^{\infty}{\delta(r-2\rho\cos\theta)r^2\sin\theta\, dr}\,d\theta}\,d\phi} = \frac{8\pi\rho^2}{3}$$

Now this is not right clearly. The only reason I can think of has to do something with properties of the Dirac delta I am unaware of. Note that I have not studied measure theory. I need the Dirac delta and not a surface integral because I will be using this to compute transformations of probability density functions which I will need to write through a Dirac delta.

Edit: References covering this for engineers/computer science students are welcome.

Edit 2: Taking into account David Holden's answer I came up with the following fact which must hold (I hope it's correct): $$\int_{V}{\delta(f(x)) \,dx} = \int_{S = \{x|f(x) =0\}}{\,dA}$$

Edit 3: I found some more information on the subject: Impulse functions over curves and surfaces Properties_in_n_dimensions Surface area from indicator function Property of Dirac delta function in $\mathbb{R}^n$ Does the coarea formula hold for delta-function?

I believe the issue was that whenever I offset the sphere the Dirac delta changed such that $\delta(f(r)) \rightarrow \delta(g(r,\theta))$ and $g$ was then a non-trivial mapping (so it's not the one-dimensional dirac delta I am used to anymore). Based on the first article I believe that I can rewrite it as a surface Dirac delta $\delta(g(r,\theta)) = \delta_S(r,\theta)$ which yields the surface integral giving a correct result. The other threads and wikipedia state that I should have a normalization by the magnitude of the gradient. I think I am missing an important piece since for the result to be correct this normalization factor should cancel out with something. More precisely: $$\int_V{\delta(r-2\rho\cos\theta)r^2\sin\theta \,dr\,d\theta\,d\phi} = \int_S{\frac{\,d\sigma}{\sqrt{r^2+\rho^2-2r\rho\cos\theta}}}$$ The only idea I have is that somehow the normalization factor will pop out of the $\,d\sigma$. No idea though since it's supposed to be a 'Minkowski content measure' which is way over my head as a computer science student.

To add to this I would also like to be able to solve the same problem with a heaviside function (for integrating the volume of the offset ball). I am unsure whether similar considerations apply there, however if I integrate it, the result seems correct. I still want to make sure this is valid for other volumes also (maybe it's just a coincidence like the sphere centered at $(0,0,0)$). So I would be grateful if somebody with more knowledge on geometric measure theory could clarify all of the points.

lightxbulb
  • 2,047
  • @Bernard I can't understand what was edited in the integrals. Can you elaborate for future reference? – lightxbulb Jan 23 '19 at 00:22
  • 1
    Dirac is a surname, so it has an initial capital. Also I added unbreakable thin spaces ( code: \,) in front of the differentials. – Bernard Jan 23 '19 at 00:28
  • 1
    Related: https://math.stackexchange.com/questions/1864255/surface-area-of-sphere-using-dirac-delta – leonbloy Jan 23 '19 at 01:38
  • $8 \pi \rho^2/3$ is the correct value for the given integral, it's just a consequence of $\int_{\mathbb R} \delta(x - a) \phi(x) dx = \phi(a)$. However, the correct relation between the volume and the surface integrals is $$\int_{\mathbb R^n} \delta(f(\mathbf x)) ,|\nabla f(\mathbf x)| ,d\mathbf x = \int_{f(\mathbf x) = 0} dA.$$ – Maxim Jan 23 '19 at 13:26
  • @Maxim It's not the correct value since I've implicitly dealt with a composition of a delta function with a submersion as if it were a the one dimensional delta function, which is incorrect. – lightxbulb Jan 24 '19 at 02:25
  • With the standard definition of $\delta(f)$, the first two integrals can be evaluated simply as iterated integrals (in any order), the second one giving $8 \pi \rho^2/3$, while the formulas in Edit 2 and Edit 3 are incorrect. You can introduce some other definition and work with some other functional $\delta_f$, but I believe the issue is that you'll end up with different change of variables formulas for regular and singular functionals. Also, if you write $\int_V$, first you have to assign a meaning to $\int_0^\infty \delta(x) dx$. – Maxim Jan 24 '19 at 08:50
  • @Maxim The point is that they cannot. Namely this step is incorrect: $\int_V{\delta(r-2\rho\cos\theta)r^2\sin\theta,dr,d\theta,d\phi} = \int_S{4\rho^2\cos^2\theta\sin\theta,d\theta,d\phi}$. It is inconsistent with the definition of the Dirac delta (as you will notice from the linked references). $\delta$ already has a well-defined meaning as the limit of normal distributions, I don't think I can change that. – lightxbulb Jan 24 '19 at 10:20
  • I don't know what normal distributions are and why you would need to define the delta function as a limit. Also not sure what you mean by $\int_S d\theta d\phi$. If it's a surface integral over the sphere, then the equality doesn't hold. If it's a double integral over the rectangle in the $(\theta, \phi)$ plane, the equality holds. Your formula in Edit 2 would imply $\int_{\mathbb R^n} \delta(2 f(\mathbf x)) d\mathbf x = \int_{\mathbb R^n} \delta(f(\mathbf x)) d\mathbf x$, which doesn't obey the change of variables rule. – Maxim Jan 24 '19 at 13:58
  • @Maxim The normal distribution is also known as the Gaussian distribution, check the definition of the Dirac delta for further details. I didn't get what you found wrong with my derivation in edit 3. It is an application of $\int_{R^n}{\delta(g(x))dx} = \int_{g^{-1}(0)}{\frac{,d\sigma}{|\nabla g|}}$ to my problem, my issue being the normalization factor. The other thing is that I know for a fact that $\frac{8\pi\rho^2}{3}$ is wrong, since translating the sphere does not change its surface area (and by extension does not change a uniform probability density defined on it). – lightxbulb Jan 24 '19 at 14:17
  • In that case you mean the pdf of a normal distribution (distribution in the sense of probability theory), and you can get a consistent definition of the delta function only if you take the distributional limit (distributional in the sense of generalized functions), which is a very roundabout way to define $(\delta, \phi) = \phi(0)$. Are you using the identity from Edit 2 now or from your last comment? They are incompatible. – Maxim Jan 24 '19 at 14:38
  • @Maxim I never really used the identity from edit 2 since it's something I came up with and I don't trust it (even though it gives the correct answer in this case I am uncertain whether it generalises to other cases, the first reference would imply that it does). The thing I used for edit 3 is what I specified in my previous answer with $g(r,\theta) = r-2\rho\cos\theta$, you can see that the denominator is simply $|\nabla g|$ in this case. The thing left to prove is what $,d\sigma$ expands into, and the denominator should cancel for one to get $2\rho^2\sin 2\theta ,d\theta,d\phi$. – lightxbulb Jan 24 '19 at 14:45
  • So you think the formula with the gradient should give the surface area and at the same time the formula without the gradient should give the surface area (instead of $8 \pi \rho^2/3$)? $d\sigma$ is an area element, you do not need generalized functions to compute it. The proper calculation goes like this: (continued) – Maxim Jan 24 '19 at 18:27
  • 1
    $$\int_{\mathbb R^3} \delta(x^2 + y^2 + (z - \rho)^2 - \rho^2) ,|\nabla(x^2 + y^2 + (z - \rho)^2 - \rho^2)| ,dx dy dz = \ 2 \pi \int_0^{\pi/2} \int_0^\infty \delta(r (r - 2 \rho \cos \theta)) ,2 \sqrt{r^2 + \rho^2 - 2 \rho r \cos \theta} ;r^2 \sin \theta ,dr d\theta.$$ Note that the factor $r$ inside the delta function cannot be ignored and the gradient in spherical coordinates is not $(\partial_r f, \partial_\theta f, \partial_\phi f)$ (which is why your Edit 3 cannot be correct). Now if you evaluate this as an iterated integral, you'll get $4 \pi \rho^2$. – Maxim Jan 24 '19 at 18:27
  • @Maxim No, I thought that the measures $d\sigma$ and $dA$ were different. Thanks for pointing out that I messed up the gradient in edit 3. What bothers me though is that you're computing $\int_{R^3}{\delta(f(x))|\nabla f(x)|dx}$ which is not $\int_{R^3}{\delta(f(x))dx}$. Also could you clarify why I cannot get rid of the $r$? $r(\theta) = 2\rho\cos\theta$ clearly describes the sphere I want. If I integrate it (as a surface) I get precisely what I would expect. I am also unsure how you evaluated the integral, as the substitution leaves me with $4\rho^2r\cos\theta\sin\theta$ as integrand. – lightxbulb Jan 24 '19 at 20:13
  • If you take a different measure, you'll get a different answer, which will not be the surface area. Ditto if you drop the gradient. Ditto if you drop $r$. The inner integral is $$\int_0^\infty \delta(r (r - 2 \rho \cos \theta)) \phi(r) dr = \frac {\phi(r)} {\left| \frac d {dr} (r (r - 2 \rho \cos \theta)) \right|} \bigg\rvert_{r = 2 \rho \cos \theta}$$ (the contribution from the zero at $r = 0$ is zero because of $r^2$ in the Jacobian). – Maxim Jan 24 '19 at 20:38
  • @Maxim Is $\phi(r) = r^2\sin\theta|\nabla (r(r-2\rho\cos\theta))|$? Where did you get the denominator from? – lightxbulb Jan 24 '19 at 20:44

3 Answers3

2

To summarize the discussion in the comments, the definition of $\delta(f)$ is derived from postulating two basic properties: the substitution rule $$\int_{\mathbb R^n} \delta(f(\mathbf x)) \,\phi(\mathbf x) \,d\mathbf x = \int_U \delta(f(\mathbf x(\mathbf u))) \,\phi(\mathbf x(\mathbf u)) \left| \det D \mathbf x(\mathbf u) \right| d\mathbf u$$ and $$\int_{\mathbb R^n} \delta(x_1) \,\phi(\mathbf x) \,d\mathbf x = \int_{\mathbb R^{n - 1}} \phi(\mathbf x) \rvert_{x_1 = 0} \,dx_2 \cdots dx_n.$$ If you try to set $$\small \int \delta(f(\mathbf x)) d\mathbf x = \int_{f(\mathbf x) = 0} dS = \int_{2 f(\mathbf x) = 0} dS = \int \delta(2 f(\mathbf x)) d\mathbf x,$$ you violate the first rule. If you try to set $$\small \iint \delta(r - f(\theta)) \phi(r, \theta) dr d\theta \neq \int \phi(f(\theta), \theta) d\theta,$$ you violate the second rule. If you adopt the definition that the rest of the world is using derived from the two stated properties, you get the identity $$\int_{\mathbb R^n} \delta(f(\mathbf x)) \left| \nabla f(\mathbf x) \right| \phi(\mathbf x) \,d\mathbf x = \int_{f(\mathbf x) = 0} \phi(\mathbf x) \,dS(\mathbf x),$$ which is formally the same as the coarea formula because both are essentially the same change of variables formula. The first two formulas in your question will in fact be correct, while the last two will be incorrect.

Maxim
  • 10,764
  • There are some small details, like the coarea formula being more general than the substitution. I think Federer developed it not so long ago too either. But for the problem at hand both work equally well. Thank you for all of the input. After I figured everything out, I found many references of this in physics books, so it certainly helps asking the right question. – lightxbulb Jan 29 '19 at 19:32
  • Also what first two formulae are you referring to? The second equality in my question is wrong. All the equalities in my answer should be correct however. @Maxim – lightxbulb Jan 29 '19 at 22:10
  • I refer to the formulas $\iiint = 4 \pi \rho^2$ and $\iiint = 8 \pi \rho^2/3$. If you still insist that the second one is wrong, then we haven't made any progress. I specifically tried to explain above why insisting that it should give some other answer is incompatible with the formula you're trying to derive. – Maxim Jan 29 '19 at 22:43
  • I am not sure how you managed to integrate that thing. Using the coarea formula the second formula gives you $|\nabla f| = \sqrt{1 + 4\rho^2\sin^2\theta / r^2}$ in the denominator. And $2\rho\sin2\theta,d\theta,d\phi$ in the numerator with integration limits $\phi \in [0,2\pi]$ and $\theta \in [0,\pi/2]$. My issue is really that $r^2$ in the denominator. I am assuming it's supposed to be $r = 2\rho\cos\theta$. But even then I don't think you'll get $8\pi\rho^2/3$. – lightxbulb Jan 30 '19 at 00:33
  • 1
    First, $dS = 2 \rho^2 \sin 2 \theta ,d\theta d\phi$. Then $$2 \pi \int_0^{\pi/2} \frac {2 \rho^2 \sin 2 \theta} {\sqrt{1 + \frac {4 \rho^2 \sin^2 \theta} {r^2}}} \bigg\rvert_{r = 2 \rho \cos \theta} ,d\theta = \frac {8 \pi \rho^2} 3.$$ But this exercise is completely pointless if you ignore the reason why $$2 \pi \int_0^{\pi/2} \int_0^\infty \delta(r - 2 \rho \cos \theta) ,r^2 \sin \theta ,dr d\theta = 2 \pi \int_0^{\pi/2} r^2 \sin \theta \rvert_{r = 2 \rho \cos \theta} ,d\theta$$ gives the same result. – Maxim Jan 30 '19 at 23:59
  • Oh it does in fact match, guess I integrated wrong. This is just a coincidence though I guess because of the form of the submersion. In the general case this will not work I take it. So it turns out that with $r-2\rho\cos\theta$ I was modeling the wrong problem indeed, since even though if it describes the surface of a translated sphere, the parametrisation matters. If I had $\delta_S(r,\theta)$ it would have modelled the 'correct' problem. Thank you for all the comments on this. – lightxbulb Jan 31 '19 at 00:17
  • And I do realize that the last 2 equations in my question are incorrect that's why I fixed them in the answer, I left them in the question just so that it would be obvious where my confusion stems from. It seems like I really wanted to use $\delta_S$ the whole time rather than $\delta$, I just didn't know the relationship between the two previously. And as you mentioned the coarea formula seems to be unnecessary for the smooth case, where a substitution yields the desired result. – lightxbulb Jan 31 '19 at 00:26
  • What are the hypotheses on the function $f$? and the set $U$? in the substitution rule? – pre-kidney Jun 29 '19 at 03:59
  • @pre-kidney The usual conditions required to make the corresponding real analysis theorems hold. $\mathbf u \to \mathbf x(\mathbf u): U \to \mathbb R^n$ is bijective with non-zero jacobian, $\nabla f$ is non-zero. – Maxim Jun 29 '19 at 13:13
  • The case when $x$ is bijective is not too interesting, since the zero set is a single point (and does not apply in recent posts we are discussing that link to here). Also, you neglected to state hypotheses on $U$ - is it assumed to be an open set? – pre-kidney Jun 29 '19 at 22:47
  • @pre-kidney It has to be bijective: injective for the u-substitution theorem to hold and surjective to give all of $\mathbb R^n$. That part has nothing to do with zero-dimensional sets. The point is that from those two properties we can derive the last formula (by choosing local coordinates where $f$ is one of the coordinates in a small neighborhood of a point on $f = 0$, then applying the change of variables, then the sifting property). – Maxim Jun 29 '19 at 23:51
  • Right, but my point is that this formula cannot be used to define quantities like $\delta(g)$ when $g$ is non-bijective, as (I thought) you had suggested in the discussion on the post linking to here. – pre-kidney Jun 29 '19 at 23:53
  • @pre-kidney $\mathbf u \to \mathbf x(\mathbf u)$ is bijective. $g$ (called $f$ here) is $\mathbb R^n \to \mathbb R$, obviously we do not require it to be bijective. – Maxim Jun 30 '19 at 00:00
1

when you write integrating yields... you may be making an unwarranted assumption about what is the "element of area". a simple geometric approach suggests:

$$ dA = \rho d(2\theta) \rho \sin 2\theta d\phi = 2 \rho^2 \sin 2\theta d\theta d\phi $$

note that with $dA$ thus defined:

$$ \int_0^{2\pi}\int_0^{\frac{\pi}2} dA = 4\pi\rho^2 $$

David Holden
  • 18,040
  • I am not changing the parametrisation nor am I integrating over area though. I know very well how to compute the area as a surface integral. My point is that I want the factors to pop out from the Dirac delta's change. Basically I want this explained in terms of the Dirac delta and what am I doing wrong with it (in the general case not only for sphere). I've seen a property in 1D where the absolute value of derivative pops out of the Dirac delta when applying a transformation $\delta(f(x))$. I would like the multidimensional case, preferably with an example applied to my problem. – lightxbulb Jan 23 '19 at 02:09
1

I finally figured out why I am getting a 'wrong' result. As expected I cannot substitute with the delta directly since it's a composition with a submersion. However the following equality holds from the coarea formula: $$\int_{R^n}{f(x)\delta(g(x))\,dx} = \int_{g^{-1}(0)}{\frac{f(x)}{|\nabla g(x)|}\,d\sigma(x)}$$ Where $g:R^n\rightarrow R$, $|\nabla g(x)|\ne 0$, and $d\sigma$ is the measure on the surface $g^{-1}(0)$. Let us consider the non-normalized uniform probability density function on the sphere with center $(0,0,0)$ and radius $\rho$ in spherical coordinates: $p_A(x,y,z) = \delta(r-\rho)r^2\sin\theta$. Unsurprisingly integrating it yields $4\pi\rho^2$: $$\int_{0}^{2\pi}{\int_{0}^{\pi}{\int_{0}^{\infty}{\delta(r-\rho)r^2\sin\theta\,dr}\,d\theta}\,d\phi} = \int_{0}^{2\pi}{\int_{0}^{\pi}{\frac{\rho^2\sin\theta}{1}\,d\theta}\,d\phi} = 4\pi\rho^2$$

Note that the division by $1$ is to emphasize that $|\nabla g| = 1$. That is, I have used the coarea formula above even if it may seem unnecessary (but as we'll see later it is actually important for other mappings, and this is simply a special case where we have the standard delta function). Now let us compute the area of the translated sphere. Going to Cartesian coordinates gives us: $p_B(x,y,z) = \frac{p_A(r,\theta)}{|r^2\sin\theta|} = \delta(\sqrt{x^2+y^2+z^2}-\rho)$ (we have used the invertible pdf transformation theorem). Translating by $(0,0,\rho)$ yields: $p_C(x,y,z) = p_B(x,y,z-\rho)$, where the Jacobian of this transformation is $1$. Finally going back to spherical coordinates we have: $$p_D(r,\theta) = \delta(\sqrt{r^2\cos^2\phi\sin^2\theta + r^2\sin^2\phi\sin^2\theta + r^2\cos\theta^2 + \rho^2 - 2r\rho\cos\theta}-\rho)r^2\sin\theta = \\ = \delta(\sqrt{r^2+\rho^2-2r\rho\cos\theta}-\rho)r^2\sin\theta$$ We compute the gradient of the mapping as: $\nabla g(r,\theta) = \frac{1}{2\sqrt{r^2+\rho^2-2\rho\cos\theta}}(2r-2\rho\cos\theta, 2\frac{r}{r}\sin\theta,0)$. Finally $|\nabla g(r,\theta)| = 1$. We may compute $g^{-1}(0) = \{(2\rho\cos\theta, \theta, \phi),\theta \in [0,\frac{\pi}{2}], \phi \in [0,2\pi]\}$. The surface area element is $dA = 2\rho^2\sin2\theta\,d\theta\,d\phi$. Then finally: $$\int_{0}^{2\pi}{\int_{0}^{\frac{\pi}{2}}{\int_{0}^{\infty}{p_D(r,\theta)\,dr}\,d\theta}\,d\phi} = \int_{0}^{2\pi}{\int_{0}^{\frac{\pi}{2}}{\rho^2\sin2\theta\,d2\theta}\,d\phi} = 4\pi\rho^2$$

Now let us consider a slightly different variant: $p_A(r) = \delta(r^2 - \rho^2)r^2\sin\theta$, $|\nabla g(r)| = 2r$ $$\int_{0}^{2\pi}{\int_{0}^{\pi}{\int_{0}^{\infty}{\delta(r^2-\rho^2)r^2\sin\theta\,dr}\,d\theta}\,d\phi} = \int_{0}^{2\pi}{\int_{0}^{\pi}{\frac{\rho^2\sin\theta}{2\rho}\,d\theta}\,d\phi} = 2\pi\rho$$

Rather surprisingly (at least for me) we get a different result, which however for the $\delta$ defined as is, is supposedly correct (I believe that the result being $2\pi\rho$ is just a lucky coincidence). So one has to be careful about the mapping.

After transforming to cartesian coordinates, translating and returning to spherical coordinates we get $p_D(r, \theta) = \delta(r^2-2\rho\cos\theta)r^2\sin\theta$, $|\nabla g(r,\theta)| = 2\sqrt{r^2+\rho^2-2r\rho\cos\theta}$. Using the coarea formula once again:

$$\int_{0}^{2\pi}{\int_{0}^{\frac{\pi}{2}}{\int_{0}^{\infty}{p_D(r,\theta)\,dr}\,d\theta}\,d\phi} = \int_{0}^{2\pi}{\int_{0}^{\frac{\pi}{2}}{\frac{\rho^2\sin2\theta}{2\sqrt{\rho^2}}\,d2\theta}\,d\phi} = 2\pi\rho$$

In conclusion, it seems that it is not correct to substitute directly when the delta function is composed with a function different than the identity (or $\pm const$). In that specific case the coarea formula has to be used. Additionally we seem to have the relationship $\delta_S(x) = \delta(g(x))|\nabla g(x)|$, where $S=g^{-1}(0)$:

$$\int_{R^n}{f(x)\delta(g(x))|\nabla g(x)|\,dx} = \int_{R^n}{f(x)\delta_S(x)\,dx} = \int_{S}{f(x)\,d\sigma(x)}$$

I very much appreciate the input from Maxim and David Holden, which ultimately helped me figure this out.

Edit: A very interesting read I found later: https://www.mathpages.com/home/kmath663/kmath663.htm It certainly helps to understand the problem from an intuitive point of view also.

lightxbulb
  • 2,047