# Don’t fear the 1/|grad f|

In our Vis paper last year about continuous histograms, we show that the right continuous formulation for histograms is the integral of the inverse gradient magnitude of the scalar field over the desired isosurface:

$\pi(h) = \int_{f^{-1}(x) = h} | \nabla f(x) |^{-1} \; dS$

In this note, I want to show that for most well-behaved functions, you have no reason to be afraid of that infinity term that will prop up in critical points. More precisely: for Morse functions and critical values h, $\lim_{x \to h} \pi(x)$ exists and is the same from both sides. I’ll stick with two-dimensional functions for now, but it works for higher dimensions.

Around a critical point of a function, choose a rotated coordinate system such that $f(x,y) = k_0 x^2 +k_1 y^2 + \epsilon$, where $\epsilon$ are all third-order terms. Since this a Morse function, the critical point is non-degenerate and isolated, and so $k_0, k_1 \neq 0$.
Then, $|| \nabla f(x,y) || = g \approx \sqrt{4 k_0^2 x^2 + 4 k_1^2 y^2}$. First, we assume $k_0 = k_1$. Then,

$g = (2 \sqrt{2k}) (x^2 + y^2)^{1/2}$

$g = (2 \sqrt{2k}) r$

Now we just compute $\pi$ at a point around a critical point with radius r:

$\int_{x^2 + y^2 = r^2} (2 \sqrt{2} r)^{-1} dS = \frac{2 \pi r}{2\sqrt{2k}r} = \pi/\sqrt{2k}$

This means that around a source or a sink in 2D, the critical point tends toward a constant (since we’re getting rid of the higher-order terms). The case where $k_0 \neq k_1$ but they share a sign is also easy: simply upper-bound the integral by using a larger domain of integration (instead of an ellipse, use the corresponding larger circle) and integrand (use the smallest gradient over the ellipse). Both factors are finite, so the integral is also finite. Similarly, the case where $k_0 = - k_1$ can be solved by substituting the complicated integral over a hyperbola with an integral over a portion of the asymptotes that has greater length.

This result should not be surprising: since $\pi$ is really the continuous analog of a histogram, $\pi$ could only be infinite if the cumulative distribution function of the scalar field were discontinuous. This implies a thick slab of the field being constant (that is, $\{ f^{-1}(h) = x \}$ would have positive measure). This does not happen in Morse functions (since critical values are isolated).

I believe that a similar argument holds for Sven’s continuous scatterplots. It has to, by analogy with multi-dimensional histograms. The situation is more complicated, though, because the values where their denominator is zero are the Jacobi sets of the sets of functions, and I just don’t know enough about them to be able to tell.

(Update: fixed typos. Thanks, Gordon!)