# A Pair of Counterexamples in Vector Calculus

## Fred Akalin

While recently reviewing some topics in vector calculus, I became curious as to why violating seemingly innocuous conditions for some theorems leads to surprisingly wild results. In fact, I was struck by how these theorems resemble computer programs, not in some abstract way, but in how the lack of “input validation” leads to non-obvious behavior in the face of erroneous input.

I found that understanding why these counterexamples lead to wild
results deepened my understanding of the theorems involved and their
proofs.^{[1]} Besides,
pathological examples are more interesting than well-behaved ones!

First, let's look at a “counterexample” to Green's theorem:

1. Two functions \(L, M \colon \mathbb{R}^2 \to \mathbb{R}\) and a positively-oriented, piecewise smooth, simple closed curve \(C\) in \(\mathbb{R}^2\) enclosing the region \(D\) such that \[ \oint_C L \,dx + M \,dy \ne \iint_D \left( \frac{\partial{M}}{\partial{x}} - \frac{\partial{L}}{\partial{y}} \right) \,dx \,dy \text{.} \]

Let
\[
\begin{aligned}
L &= -\frac{y}{x^2+y^2} \text{, } M = \frac{x}{x^2+y^2} \text{,}
\end{aligned}
\]
and \(C\) be a curve going clockwise around the rectangle \(D = [-1,
1]^2\).^{[2]} Then the integral of \(L \,dx + M \, dy\) around \(C\) is \(2
\pi\) since it encloses the origin. But
\[
\frac{\partial{M}}{\partial{x}} = \frac{\partial{L}}{\partial{y}} = \frac{y^2-x^2}{x^2+y^2}
\]
so the difference of the two vanishes everywhere but the origin, where
neither function is defined. Therefore, the (improper) integral over
\(D\) also vanishes, proving the inequality. ∎

Of course, the easy explanation is that the discontinuity of \(L\) and \(M\) at the origin violates a condition of Green's theorem. But that doesn't really tell us anything, so let's break down the theorem and see where exactly it fails.

Green's theorem is usually proved first for rectangles \([a, b] \times [c, d]\), which suffices for our purpose. If \(C\) is a curve that goes counter-clockwise around such a rectangle \(D\), then we can easily show that \[ \oint_C L \,dx = - \iint_D \frac{\partial{L}}{\partial{y}} \,dx \,dy \] and \[ \oint_C M \,dy = \iint_D \frac{\partial{M}}{\partial{x}} \,dx \,dy \text{,} \] with the sum of these two formulas proving the theorem.

So the first sign of trouble is that the theorem freely interchanges addition and integration. Since the partial derivatives of our functions diverge at the origin, if \(D\) contains the origin then the integrals of those partial derivatives over \(D\) may not even be defined, even if the integral of their difference is.

But the problem arises even before that. The statements above are proved by showing \[ \oint_C L \,dx = - \int_a^b \left( \int_c^d \frac{\partial{L}}{\partial{y}} \,dy \right) \,dx \] and \[ \oint_C M \,dy = \int_c^d \left( \int_a^b \frac{\partial{M}}{\partial{x}} \,dx \right) \,dy \text{.} \] both of which hold for our example. But notice that in one case we integrate with respect to \(y\) first, and in the other case we integrate with respect to \(x\) first. Therefore, we have to interchange the order of integration or convert to a double integral in order to get them to a form where we can add them. And there's the rub: if \(D\) contains the origin, switching the order of integration for either integral above switches the sign of the result!

This fully explains the discrepancy; since the result of both integrals above (with the iteration order preserved) is \(\pi\), adding them together as-is gives the expected result of \(2 \pi\). But if we switch the iteration order of one of the iterated integrals as done in the proof of Green's theorem, then we switch the result of that integral to \(-\pi\), which cancels with the result of the other unchanged integral to produce \(0\).

So now let's examine this strange behavior of the sign of an integration's result depending on the iteration order. This leads us to our next “counterexample,” this time for Fubini's theorem:

2. A function \(f \colon \mathbb{R}^2 \to \mathbb{R}\) whose iterated integrals over a rectangle \(D = [a, b] \times [c, d] \subset \mathbb{R}^2\) differ.

Let \[ f(x, y) = \frac{x^2-y^2}{(x^2+y^2)^2} \quad \text{ and } \quad D = [-1, 1]^2\text{.} \] The two iterated integrals of \(f\) over \(D\) are usually written as \[ \int_{-1}^1 \left( \int_{-1}^1 f(x, y) \,dy \right) \,dx \qquad \text{ and } \qquad \int_{-1}^1 \left( \int_{-1}^1 f(x, y) \,dx \right) \,dy \] but let's define them more carefully to make it easier to justify our calculations.

Let \[ \begin{aligned} u_k &= y \mapsto f(k, y) \\ v_l &= x \mapsto f(x, l) \text{.} \end{aligned} \] In other words, given the real constants \(k\) and \(l\), construct the (possibly partial) real functions \(u_k(y)\) and \(v_l(x)\) by partially-evaluating \(f\) at \(x = k\) and \(y = l\), respectively.

Then, if we also let^{[3]}
\[
U(x) = \int_{-1}^1 u_x(y) \,dy
\qquad \text{ and } \qquad
V(y) = \int_{-1}^1 v_y(x) \,dx \text{,}
\]
we can write the iterated integrals as
\[
\int_{-1}^1 U(x) \,dx
\qquad \text{ and } \qquad
\int_{-1}^1 V(y) \,dy \text{.}
\]

Computing \(U(x)\) for \(x \neq 0\), we get^{[4]}
\[
\begin{aligned}
U(x) &= \int_{-1}^1 \frac{\partial{}}{\partial{y}} \left( -\frac{y}{x^2+y^2} \right) \,dy \\
&= \left. -\frac{y}{x^2+y^2} \right|_{y=-1}^{y=1} \\
&= -\frac{2}{x^2+1} \text{.}
\end{aligned}
\]

Attempting to evaluate \(U(0)\), we see that \[ \begin{aligned} U(0) &= \int_{-1}^1 \frac{0^2-y^2}{(0^2+y^2)^2} \,dy \\ &= - \int_{-1}^1 \frac{dy}{y^2} \end{aligned} \] which diverges. So \[ U(x) = -\frac{2}{x^2+1} \text{ for } x \ne 0 \text{.} \]

By a similar computation, we find that^{[5]}
\[
V(y) = \frac{2}{y^2+1} \text{ for } y \ne 0 \text{.}
\]

Since \(U(x)\) isn't defined at \(0\), we have to treat it as an improper integral, although doing so poses no real difficulty: \[ \begin{aligned} \int_{-1}^1 U(x)\,dx &= \lim_{a \nearrow 0} \left( \int_{-1}^a -\frac{2}{x^2+1} \,dx \right) + \lim_{a \searrow 0} \left( \int_{a}^1 -\frac{2}{x^2+1} \,dx \right) \\ &= \lim_{a \nearrow 0} \Bigl( \left. -2 \arctan(x) \right|_{-1}^{a} \Bigr) + \lim_{a \searrow 0} \Bigl( \left. -2 \arctan(x) \right|_{a}^{1} \Bigr) \\ &= \left. -2 \arctan(x) \right|_{-1}^{0} + \left. -2 \arctan(x) \right|_{0}^{1} \\ &= \left. -2 \arctan(x) \right|_{-1}^{1} \\ &= -\pi \text{.} \end{aligned} \]

Similarly, \[ \int_{-1}^1 V(y)\,dy = \pi \text{,} \] so the iterated integrals of \(f(x, y)\) over \([-1, 1]^2\) differ; in fact, as we claimed above, switching the iteration order switches the sign of the result. ∎

We can repeat the above calculations for an arbitrary rectangle to see that the iterated integrals of \(f(x, y)\) differ if \(D\) contains the origin either as an interior point or a corner. But there's an easier way to prove that statement and also gain some insight as to why \(f(x, y)\) has this strange property.

Note that the key facts in the above calculations were that \(U(x) \lt 0\) for any \(x \ne 0\) and \(V(y) \gt 0\) for any \(y \ne 0\). Therefore, integrating \(U(x)\) over any interval on the \(x\)-axis would produce a negative result and integrating \(V(x)\) over any interval on the \(y\)-axis would produce a positive result, leading to the difference in iterated integrals. This holds more generally; for any \(m, n \gt 0\): \[ \int_{-n}^n f(x, y) \,dy \lt 0 \qquad \text{ and } \qquad \int_{-m}^m f(x, y) \,dx \gt 0 \text{.} \] Therefore, \[ \int_{-m}^m \left( \int_{-n}^n f(x, y) \,dy \right) \,dx \lt 0 \qquad \text{ and } \qquad \int_{-n}^n \left( \int_{-m}^m f(x, y) \,dx \right) \,dy \gt 0 \] so the iterated integrals of \(f(x, y)\) differ over the rectangles \([-m, m] \times [-n, n]\). Since any rectangle \(D\) containing the origin as an interior point must contain some smaller rectangle \(E = [-m, m] \times [-n, n]\), the iterated integrals of \(f(x, y)\) over \(E\) differ and therefore must also differ over \(D\).

Furthermore, since \(f(x, y)\) is even in both \(x\) and \(y\), you can carry out a similar argument to the above with intervals of the form \([0, m]\) or \([-m, 0]\) to show that the iterated integrals of \(f(x, y)\) must also differ over any rectangle with the origin as a corner.

So the essential property of \(f(x, y)\) is that slicing it along the \(x\)-axis gives a function which has positive area under the curve on any interval symmetric around \(0\) or with \(0\) as an endpoint, and that slicing it similarly along the \(y\)-axis gives a function with has negative area. Therefore, on a rectangle symmetric around the origin or with the origin as a corner, one can choose the sign of the iterated integral by choosing which axis to slice first.

The next thing to investigate is how exactly the iterated integrals of \(f(x, y)\) over the rectangle \(D\) are expressed such that they differ only when \(D\) contains the origin, especially considering that the \(f(x, y)\) is expressed in quite a simple form. To do that, let's consider the simple case of a rectangle \(D = [\delta, 1] \times [\epsilon, 1]\) where we can vary \(\delta\) and \(\epsilon\) at will.

Let \[ \begin{aligned} I_{yx}(\delta, \epsilon) &= \int_{\delta}^1 \left( \int_{\epsilon}^1 f(x, y) \,dy \right) \,dx \\ I_{xy}(\delta, \epsilon) &= \int_{\epsilon}^1 \left( \int_{\delta}^1 f(x, y) \,dx \right) \,dy \text{.} \end{aligned} \] Then, for \(\epsilon \neq 0\): \[ \begin{aligned} I_{yx}(\delta, \epsilon) &= \int_{\delta}^1 \left( \int_{\epsilon}^1 \frac{y^2-x^2}{(x^2+y^2)^2} \,dy \right) \,dx \\ &= \int_{\delta}^1 \left( \left. -\frac{y}{x^2+y^2} \right|_{y=\epsilon}^{y=1} \right) \,dx \\ &= \int_{\delta}^1 \Biggl( -\frac{1}{1+x^2} - \left( -\frac{\epsilon}{\epsilon^2+x^2} \right) \Biggr) \,dx \\ &= \int_{\delta}^1 \frac{dx/\epsilon}{1+(x/\epsilon)^2} - \int_{\delta}^1 \frac{dx}{1+x^2} \\ &= \arctan\left(\frac{1}{\epsilon}\right) - \arctan\left(\frac{\delta}{\epsilon}\right) - \frac{\pi}{4} + \arctan(\delta) \text{,} \end{aligned} \] and for \(\epsilon = 0\): \[ I_{yx}(\delta, 0) = -\frac{\pi}{4} + \arctan(\delta) \text{.} \] Similarly, for \(\delta \neq 0\): \[ \begin{aligned} I_{xy}(\delta, \epsilon) &= \int_{\epsilon}^1 \left( \int_{\delta}^1 \frac{y^2-x^2}{(x^2+y^2)^2} \,dx \right) \,dy \\ &= \int_{\epsilon}^1 \left( \left. \frac{x}{x^2+y^2} \right|_{x=\delta}^{x=1} \right) \,dy \\ &= \int_{\epsilon}^1 \left( \frac{1}{1+y^2} - \frac{\delta}{\delta^2+x^2} \right) \,dy \\ &= \int_{\epsilon}^1 \frac{dy}{1+y^2} - \int_{\epsilon}^1 \frac{dy/\delta}{1+(y/\delta)^2} \\ &= \frac{\pi}{4} - \arctan(\epsilon) - \arctan\left(\frac{1}{\delta}\right) + \arctan\left(\frac{\epsilon}{\delta}\right) \text{,} \end{aligned} \] and for \(\delta = 0\): \[ I_{xy}(0, \epsilon) = \frac{\pi}{4} - \arctan(\epsilon) \text{.} \] Then let \(\Delta = I_{xy} - I_{yx}\) be the difference between the two iterated integrals. We can use the identity \[ \arctan(x) + \arctan\left(\frac{1}{x}\right) = \frac{\pi}{2} \mathrm{sgn}(x) \] to simplify \(\Delta(\delta, \epsilon)\) if neither \(\delta\) nor \(\epsilon\) is zero: \[ \begin{aligned} \Delta(\delta, \epsilon) &= \bigl( \pi/4 - \arctan(\epsilon) - \arctan(1/\delta) + \arctan(\epsilon/\delta) \bigr) \\ & \quad \mathbin{-} \bigl( \arctan(1/\epsilon) - \arctan(\delta/\epsilon) - \pi/4 + \arctan(\delta) \bigr) \\ &= \pi/2 - \bigl( \arctan(\epsilon) + \arctan(1/\epsilon) \bigr) \\ & \quad \mathbin{-} \bigl( \arctan(\delta) + \arctan(1/\delta) \bigr) \\ & \quad \mathbin{+} \bigl( \arctan(\delta/\epsilon) + \arctan(\epsilon/\delta) \bigr) \\ &= \frac{\pi}{2} \bigl( 1 - \mathrm{sgn}(\epsilon) - \mathrm{sgn}(\delta) + \mathrm{sgn}(\delta/\epsilon) \bigr) \text{.} \end{aligned} \]

Using the properties of \(\mathrm{sgn}(x)\), we can simplify this to the final expression: \[ \Delta(\delta, \epsilon) = \frac{\pi}{2} \bigl( 1 - \mathrm{sgn}(\delta) \bigr) \bigl( 1 - \mathrm{sgn}(\epsilon) \bigr) \] which we can prove still holds if either \(\delta\) or \(\epsilon\) is zero (or both).

So with the simplified expression for \(\Delta(\delta, \epsilon)\), it becomes apparent how \(\mathrm{sgn}(x)\) is used to control the value of \(\Delta(\delta, \epsilon)\); as long as either \(\delta\) or \(\epsilon\) is positive, \(1 - \mathrm{sgn}(x)\) zeroes out the entire expression.

[1] There are actually whole books dedicated to counterexamples. They make good bathroom reading material. ↩

[2] The vector field \((L, M)\) also serves as the canonical “counterexample” to the gradient theorem. ↩

[3] \(U(x)\) and \(V(y)\) are also (partial) real functions. ↩

[4] We're justified in applying standard integration techniques here since \(u_k(y)\) for \(k \gt 0\) is defined and bounded for all \(y\). ↩

[5] Note that \(U(x)\) and \(V(y)\) differ only in variable name and sign. ↩