# A Pair of Counterexamples in Vector Calculus

## Fred Akalin

### November 27, 2011

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. 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 $∮_C L \,dx + M \,dy \ne ∬_D \left( \frac{∂{M}}{∂{x}} - \frac{∂{L}}{∂{y}} \right) \,dx \,dy \text{.}$

Let $L = -\frac{y}{x^2+y^2} \text{,} \quad M = \frac{x}{x^2+y^2} \text{,}$ and $$C$$ be a curve going clockwise around the rectangle $$D = [-1, 1]^2$$. Then the integral of $$L \,dx + M \, dy$$ around $$C$$ is $$2 π$$ since it encloses the origin. But $\frac{∂{M}}{∂{x}} = \frac{∂{L}}{∂{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 $∮_C L \,dx = - ∬_D \frac{∂{L}}{∂{y}} \,dx \,dy$ and $∮_C M \,dy = ∬_D \frac{∂{M}}{∂{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 $∮_C L \,dx = - ∫_a^b \left( ∫_c^d \frac{∂{L}}{∂{y}} \,dy \right) \,dx$ and $∮_C M \,dy = ∫_c^d \left( ∫_a^b \frac{∂{M}}{∂{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 $$π$$, adding them together as-is gives the expected result of $$2 π$$. 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 $$-π$$, 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 $∫_{-1}^1 \left( ∫_{-1}^1 f(x, y) \,dy \right) \,dx \qquad \text{ and } \qquad ∫_{-1}^1 \left( ∫_{-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 $U(x) = ∫_{-1}^1 u_x(y) \,dy \qquad \text{ and } \qquad V(y) = ∫_{-1}^1 v_y(x) \,dx \text{,}$ we can write the iterated integrals as $∫_{-1}^1 U(x) \,dx \qquad \text{ and } \qquad ∫_{-1}^1 V(y) \,dy \text{.}$

Computing $$U(x)$$ for $$x ≠ 0$$, we get \begin{aligned} U(x) &= ∫_{-1}^1 \frac{∂{}}{∂{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) &= ∫_{-1}^1 \frac{0^2-y^2}{(0^2+y^2)^2} \,dy \\ &= - ∫_{-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 $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} ∫_{-1}^1 U(x)\,dx &= \lim_{a \nearrow 0} \left( ∫_{-1}^a -\frac{2}{x^2+1} \,dx \right) + \lim_{a \searrow 0} \left( ∫_{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} \\ &= -π \text{.} \end{aligned}

Similarly, $∫_{-1}^1 V(y)\,dy = π \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$$: $∫_{-n}^n f(x, y) \,dy \lt 0 \qquad \text{ and } \qquad ∫_{-m}^m f(x, y) \,dx \gt 0 \text{.}$ Therefore, $∫_{-m}^m \left( ∫_{-n}^n f(x, y) \,dy \right) \,dx \lt 0 \qquad \text{ and } \qquad ∫_{-n}^n \left( ∫_{-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 = [δ, 1] \times [ϵ, 1]$$ where we can vary $$δ$$ and $$ϵ$$ at will.

Let \begin{aligned} I_{yx}(δ, ϵ) &= ∫_{δ}^1 \left( ∫_{ϵ}^1 f(x, y) \,dy \right) \,dx \\ I_{xy}(δ, ϵ) &= ∫_{ϵ}^1 \left( ∫_{δ}^1 f(x, y) \,dx \right) \,dy \text{.} \end{aligned} Then, for $$ϵ ≠ 0$$: \begin{aligned} I_{yx}(δ, ϵ) &= ∫_{δ}^1 \left( ∫_{ϵ}^1 \frac{y^2-x^2}{(x^2+y^2)^2} \,dy \right) \,dx \\ &= ∫_{δ}^1 \left( \left. -\frac{y}{x^2+y^2} \right|_{y=ϵ}^{y=1} \right) \,dx \\ &= ∫_{δ}^1 \Biggl( -\frac{1}{1+x^2} - \left( -\frac{ϵ}{ϵ^2+x^2} \right) \Biggr) \,dx \\ &= ∫_{δ}^1 \frac{dx/ϵ}{1+(x/ϵ)^2} - ∫_{δ}^1 \frac{dx}{1+x^2} \\ &= \arctan\left(\frac{1}{ϵ}\right) - \arctan\left(\frac{δ}{ϵ}\right) - \frac{π}{4} + \arctan(δ) \text{,} \end{aligned} and for $$ϵ = 0$$: $I_{yx}(δ, 0) = -\frac{π}{4} + \arctan(δ) \text{.}$ Similarly, for $$δ ≠ 0$$: \begin{aligned} I_{xy}(δ, ϵ) &= ∫_{ϵ}^1 \left( ∫_{δ}^1 \frac{y^2-x^2}{(x^2+y^2)^2} \,dx \right) \,dy \\ &= ∫_{ϵ}^1 \left( \left. \frac{x}{x^2+y^2} \right|_{x=δ}^{x=1} \right) \,dy \\ &= ∫_{ϵ}^1 \left( \frac{1}{1+y^2} - \frac{δ}{δ^2+x^2} \right) \,dy \\ &= ∫_{ϵ}^1 \frac{dy}{1+y^2} - ∫_{ϵ}^1 \frac{dy/δ}{1+(y/δ)^2} \\ &= \frac{π}{4} - \arctan(ϵ) - \arctan\left(\frac{1}{δ}\right) + \arctan\left(\frac{ϵ}{δ}\right) \text{,} \end{aligned} and for $$δ = 0$$: $I_{xy}(0, ϵ) = \frac{π}{4} - \arctan(ϵ) \text{.}$ Then let $$Δ = 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{π}{2} \sgn(x)$ to simplify $$Δ(δ, ϵ)$$ if neither $$δ$$ nor $$ϵ$$ is zero: \begin{aligned} Δ(δ, ϵ) &= \bigl( π/4 - \arctan(ϵ) - \arctan(1/δ) + \arctan(ϵ/δ) \bigr) \\ & \quad \mathbin{-} \bigl( \arctan(1/ϵ) - \arctan(δ/ϵ) - π/4 + \arctan(δ) \bigr) \\ &= π/2 - \bigl( \arctan(ϵ) + \arctan(1/ϵ) \bigr) \\ & \quad \mathbin{-} \bigl( \arctan(δ) + \arctan(1/δ) \bigr) \\ & \quad \mathbin{+} \bigl( \arctan(δ/ϵ) + \arctan(ϵ/δ) \bigr) \\ &= \frac{π}{2} \bigl( 1 - \sgn(ϵ) - \sgn(δ) + \sgn(δ/ϵ) \bigr) \text{.} \end{aligned}

Using the properties of $$\sgn(x)$$, we can simplify this to the final expression: $Δ(δ, ϵ) = \frac{π}{2} \bigl( 1 - \sgn(δ) \bigr) \bigl( 1 - \sgn(ϵ) \bigr)$ which we can prove still holds if either $$δ$$ or $$ϵ$$ is zero (or both).

So with the simplified expression for $$Δ(δ, ϵ)$$, it becomes apparent how $$\sgn(x)$$ is used to control the value of $$Δ(δ, ϵ)$$; as long as either $$δ$$ or $$ϵ$$ is positive, $$1 - \sgn(x)$$ zeroes out the entire expression.

Like this post? Subscribe to my feed or follow me on Twitter .

## Footnotes

 There are actually whole books dedicated to counterexamples. They make good bathroom reading material.

 The vector field $$(L, M)$$ also serves as the canonical “counterexample” to the gradient theorem.

 $$U(x)$$ and $$V(y)$$ are also (partial) real functions.

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

 Note that $$U(x)$$ and $$V(y)$$ differ only in variable name and sign.