# Arc length of implicit curve using gradient magnitude of the unit step function?

I came across a funny formula for the arc length of an implicit curve in the paper here, given at the top of page 5. Let me set the context:

Consider a function $\phi: \mathbb{R}^2 \to \mathbb{R}$ with all the necessary partial derivatives. Suppose that the region $A = \{ (x,y) \; | \; \phi(x,y) > 0 \}$ is open, and its boundary, $\partial A = \{ (x,y) \; | \; \phi(x,y) = 0 \}$, implicitly defines a rectifiable curve.

Next, define the unit step function, $H(t) = \begin{cases} 1 & t > 0 \\ 0 & t < 0\end{cases}$

Finally, it is stated that:

$$\text{length}\{\phi=0\} = \int_{\mathbb{R}^2} \left| \nabla H(\phi(x,y)) \right| \; dx \; dy \tag{1}$$

I cannot grasp where this formula arises.

I have tried using the divergence theorem,

$$\text{length}\{\phi = 0 \} = \int_{\partial A} ds = \int_A \text{div}\left(\frac{\nabla \phi}{|\nabla \phi|}\right) \; dx \; dy = \int_{\mathbb{R}^2} H(\phi(x,y)) \;\text{div}\left(\frac{\nabla \phi}{|\nabla \phi|}\right) \; dx \; dy \tag{2}$$

but I can't seem to match this to $(1)$. My questions are:

1. How can we show equation $(1)$?
2. What is the potential advantage of $(1)$ over $(2)$?

So, I chased references and came across this paper, where a slightly different version of the equality in question is proved (see equation 15 in the linked paper). I followed the reasoning in their proof to show equation $(1)$ in my question. It seems like there could be a more straight-forward approach?

EDIT: This appears to simply just be an instance of the Coarea formula, making the calculation below somewhat unnecessary.

We first take $(1) = \int_{\mathbb{R}^2} \delta(\phi(x,y)) |\nabla \phi| dx \; dy$, where $\frac{d}{dt} H(t) = \delta(t)$ in a distributional sense.

Next, we change variables, $u = \phi(x,y)$ and $v = \psi(x,y)$, where $\psi(x,y)$ is chosen such that $\psi_x = -\phi_y$ and $\psi_y = \phi_x$. The linked paper goes into detail about constructing $\psi(x,y)$. Now, we have that

$$\left| \frac{\partial(u,v)}{\partial(x,y)} \right|= |\nabla\phi|^2$$

and the original integral is now transformed:

$$\int_Q \delta(u) \frac{1}{|\nabla \phi|} du \; dv = \int_{\{u = 0\}} \frac{1}{|\nabla \phi|} dv$$

where $Q$ is the transformed region (this region contains $\{u = 0\}$). The region, $\{u = 0\}$, is exactly $\partial A$. Parameterize the curve defined by $\partial A$ by $r: [0,1] \to \partial A$. Then,

$$dv = \langle \nabla \psi(r(t)), r'(t) \rangle \; dt = |\nabla \phi| \; |r'(t)| \; dt$$

since $\psi$ is orthognal to $\phi$ with equal magnitude. This proves equation $(1)$.