# Data Aggregation for Hierarchical Clustering

Erich Schubert
TU Dortmund University
<EMAIL_ADDRESS>
&Andreas Lang
TU Dortmund University
<EMAIL_ADDRESS>

###### Abstract

Hierarchical Agglomerative Clustering (HAC) is likely the earliest and most
flexible clustering method, because it can be used with many distances,
similarities, and various linkage strategies. It is often used when the number
of clusters the data set forms is unknown and some sort of hierarchy in the
data is plausible. Most algorithms for HAC operate on a full distance matrix,
and therefore require quadratic memory. The standard algorithm also has cubic
runtime to produce a full hierarchy. Both memory and runtime are especially
problematic in the context of embedded or otherwise very resource-constrained
systems. In this section, we present how data aggregation with BETULA, a
numerically stable version of the well known BIRCH data aggregation algorithm,
can be used to make HAC viable on systems with constrained resources with only
small losses on clustering quality, and hence allow exploratory data analysis
of very large data sets.

This is a preprint of Erich Schubert and Andreas Lang. “5.3 Data Aggregation
for Hierarchical Clustering”. In: Machine Learning under Resource Constraints
– Fundamentals (Volume 1) edited by Katharina Morik and Peter Marwedel,
Berlin, Boston: De Gruyter, 2023, pp. 215-226.
https://doi.org/10.1515/9783110785944-005

##  1 Introduction

Hierarchical Agglomerative Clustering (HAC) is a popular clustering method
that is especially useful if a hierarchy of clusters exists in the data set.
Initially, each data entry is seen as a cluster of one. In each hierarchy
level the two clusters with the least distance (c.f. Section 2) between them
are combined until the whole data set is in one cluster. Another commonly used
name, Simple Agglomerative Hierarchical Nesting (SAHN), reflects this easy-to-
understand core idea. The standard algorithm used for HAC, known as AGNES [5],
requires the pairwise distances between all data points to be stored in a
distance matrix, and when merging clusters, two columns and rows in this
matrix are combined using the Lance-Williams equations [8, 7]. AGNES can be
utilized with different primary distance functions, but also with different
cluster distances (commonly called linkages), see Section 2. Hierarchical
Agglomerative Clustering, like many other clustering methods, is a rather
resource-hungry process commonly implemented using
${O\mathopen{}(N^{2})\mathclose{}}$ memory and
${O\mathopen{}(N^{2})\mathclose{}}$ to ${O\mathopen{}(N^{3})\mathclose{}}$
time, depending on the exact algorithm implemented. One possibility to reduce
the resource demands for big data or when using small embedded systems is data
aggregation. The BIRCH (Balanced Iterative Reducing and Clustering using
Hierarchies) [23, 22] algorithm is a well-known data aggregation technique for
clustering. BIRCH is a multi-step clustering algorithm that aggregates the
data into a tree structure known as CF-tree before the actual clustering. We
will first review some fundamentals of hierarchical clustering, and then
discuss an improved version of BIRCH, called BETULA [10, 9], that avoids some
numerical problems in the original BIRCH. We then show how it can be used to
accelerate HAC for big data, and reduce its memory requirements.

##  2 Hierarchical Clustering Linkages

Because Hierarchical Agglomerative Clustering is based on the idea of always
merging the two closest clusters, we need to define a suitable distance of
clusters, not just of single points. Usually, we want this distance to be
consistent with our distance of single points. This notion of “cluster
distance” is commonly called the “linkage” criterion. The choice of linkages
affect greatly how the resulting clusters look, but they also influence which
algorithms can be used.

The two most widely known linkage strategies are single-link and complete-
link, where the distance of two clusters is defined as the minimum
respectively maximum distance of any two points. However, many other linkages
have been proposed in literature, many already back in the 1950s by, e.g.,
[19, 11, 20, 21]. More recent proposals include Mini-Max [2] and Medoid
linkages [4, 12, 16]. Several (but not all) linkages can be expressed in terms
of Lance-Williams recurrences [8, 7], which offer computational advantages.
WPGMA (McQuitty) and WPGMC (Median linkage), can only be defined in terms of a
recurrence, and do not have a closed-form based only on the sets of points.
The Lance-Williams formula is as follows:

$\displaystyle d(A{\cup}B,C)=$
$\displaystyle\alpha_{A}d(A,C)+\alpha_{B}d(B,C)+\beta
d(A,B)+\gamma|d(A,C){-}d(B,C)|\;.$ (1)

Different linkage strategies can be defined in terms of the factors
$\alpha_{A}$, $\alpha_{B}$, $\beta$, and $\gamma$ as given in Tab. 1. These
may depend on the sizes of the clusters $A$, $B$, and $C$, which we denote as
$n_{A}$, $n_{B}$, and $n_{C}$. For brevity, we use the shorthand
$n_{\\!A\\!B}:=n_{A{\cup}B}=n_{A}{+}n_{B}$, and
$n_{\\!A\\!B\\!C}:=n_{A{\cup}B{\cup}C}=n_{A}{+}n_{B}{+}n_{C}$. An additional –
and often overlooked – detail is the initialization of the distance matrix.
While single, complete, and group-average linkage work with any distance, the
centroid, Ward and median methods need to be initialized with squared
distances, and are closely tied to the Euclidean distance and variance.
Ignoring this initialization difference (and interpretation of the output) can
easily yield to receiving incorrect results [14]. The reason becomes apparent
when considering the objective function of the clustering, respectively the
closed-form, e.g., Eqs. (2) to (4).

Table 1: Common linkages in terms of Lance-Williams factors Linkage | $\alpha_{A}$ | $\alpha_{B}$ | $\beta$ | $\gamma$ | Init.
---|---|---|---|---|---
Single | $1/2$ | $1/2$ | $0$ | $-1/2$ | $d(a,b)$
Complete | $1/2$ | $1/2$ | $0$ | $1/2$ | $d(a,b)$
Group-average (UPGMA) | $\displaystyle\frac{n_{A}}{n_{\\!A\\!B}}$ | $\displaystyle\frac{n_{B}}{n_{\\!A\\!B}}$ | $0$ | $0$ | $d(a,b)$
McQuitty (WPGMA) | $1/2$ | $1/2$ | $0$ | $0$ | $d(a,b)$
Centroid (UPGMC) | $\displaystyle\frac{n_{A}}{n_{\\!A\\!B}}$ | $\displaystyle\frac{n_{B}}{n_{\\!A\\!B}}$ | $-\displaystyle\frac{n_{A}\cdot n_{B}}{{n_{\\!A\\!B}}^{2}}$ | $0$ | $d(a,b)^{2}$
Median (WPGMC) | $1/2$ | $1/2$ | $-1/4$ | $0$ | $d(a,b)^{2}$
Ward | $\displaystyle\frac{n_{\\!A\\!C}}{n_{\\!A\\!B\\!C}}$ | $\displaystyle\frac{n_{\\!B\\!C}}{n_{\\!A\\!B\\!C}}$ | $-\displaystyle\frac{n_{C}}{n_{\\!A\\!B\\!C}}$ | $0$ | $d(a,b)^{2}$

Consider single-linkage first (and, by substituting $\max$ for $\min$,
complete-linkage). Here the aim is to merge clusters $A$ and $B$ with the
smallest distance between their points, i.e., with the smallest
$d_{\text{single}}(A,C):=\min_{a\in A,c\in C}d(a,c)$. If both clusters
consists of a single element, we obviously have
$d_{\text{single}}(\\{a\\},\\{c\\})=d(a,c)$, and we can recursively compute
this linkage using $d_{\text{single}}(A\cup
B,C)=\min\\{d_{\text{single}}(A,C),d_{\text{single}}(B,C)\\}$. It is easy to
see that the weights given in Tab. 1 correspond to using the minimum
respective maximum.

Group-average linkage, also known as Unweighted Pair Group Method with
Arithmetic mean (UPGMA), is another very intuitive linkage, and is often
considered one of the best to use in practice. The idea is to capture the
average distance between elements from different clusters, i.e.,
$d_{\text{avg}}(A,C):=\tfrac{1}{n_{A}n_{C}}\sum_{a\in A}\sum_{c\in C}d(a,c)$.
Clearly, for one-elemental clusters, we have
$d_{\text{avg}}(\\{a\\},\\{c\\})=d(a,c)$. The recursive computation formula is
easy to derive:

$\displaystyle d_{\text{avg}}(A\cup B,C)=$
$\displaystyle\tfrac{1}{n_{\\!A\\!B}n_{C}}\bigg{(}\sum_{a\in A}\sum_{c\in
C}d(a,c)+\sum_{b\in B}\sum_{c\in C}d(b,c)\bigg{)}$ $\displaystyle=$
$\displaystyle\tfrac{1}{n_{\\!A\\!B}n_{C}}\left(n_{A}n_{C}d_{\text{avg}}(A,C)+n_{B}n_{C}d_{\text{avg}}(B,C)\right)$
$\displaystyle=$
$\displaystyle\tfrac{n_{A}}{n_{\\!A\\!B}}d_{\text{avg}}(A,C)+\tfrac{n_{B}}{n_{\\!A\\!B}}d_{\text{avg}}(B,C)\enskip.$
(2)

The literature terminology “weighted” (going back to [20] [19, 20]) can be
confusing: it refers to the influence each point has. In “unweighted” group
average, each _object_ has the same weight (and, hence, the weight of each
cluster is proportional the number of objects contained), whereas in the
“weighted” version i.e McQuitty and Median linkage, each _cluster_ has the
same weight (and, hence, each object in a larger cluster has a reduced
weight). As easily seen in Tab. 1, both “weighted” versions correspond to
their “unweighted” counterparts if we fix the cluster sizes to a constant
$n_{A}=n_{B}:=1$, i.e., ignoring the cluster sizes when merging.

McQuitty’s Weighted Pair-Group Method with Arithmetic mean (WPGMA [11]) can be
recursively defined as $d_{\text{McQ}}(A\cup
B,C)=\tfrac{1}{2}(d_{\text{McQ}}(A,C)+d_{\text{McQ}}(B,C))$, which introduces
an unfortunate dependency on the “merge history” of the child clusters $A$ and
$B$. Given three objects $a,b,c$, merging $a$ and $b$ first, then with $c$ may
yield a different result than first merging one of the other pairs. A similar
argument holds for median linkage (WPGMC), discussed below.

Unweighted Pair-Group Method using Centroids (UPGMC), also known as centroid
linkage, combines clusters by the distance of the cluster means
$\mu_{A}=\tfrac{1}{|A|}\sum_{x\in A}x$, i.e., always merges the smallest
$d_{\text{cent}}(A,C)=\left\lVert\mu_{A}-\mu_{C}\right\rVert$. Computing the
distances between the means explicitly requires many additional distance
computations, and hence is slower and less resource-efficient than a recurrent
approach. But there is a special relationship between the mean, the variance,
and squared Euclidean distance that we can exploit to compute this special
case elegantly with a recurrence. We discuss this relationship, without loss
of generality, only for univariate data, because squared Euclidean is simply
the sum of the squared variates. We then have
$\left\lVert\mu_{A}{-}\mu_{C}\right\rVert^{2}=\mu_{A}^{2}+\mu_{C}^{2}-2\mu_{A}\mu_{C}$
and obtain

$\displaystyle d_{\text{cent}}(A{\cup}B,C)=$
$\displaystyle\tfrac{n_{A}}{n_{\\!A\\!B}}d_{\text{cent}}(A,C)+\tfrac{n_{B}}{n_{\\!A\\!B}}d_{\text{cent}}(B,C)-\tfrac{n_{A}n_{B}}{{n_{\\!A\\!B}}^{2}}d_{\text{cent}}(A,B)$
$\displaystyle=$
$\displaystyle\mu_{AB}^{2}+\mu_{C}^{2}-2\mu_{AB}\mu_{C}=\left\lVert\mu_{AB}-\mu_{C}\right\rVert^{2}\enskip.$
(3)

This means that for squared Euclidean distances, we can compute the distance
of the means without computing the means themselves. Hence, we need to
initialize the distance matrix with squared Euclidean distances, and also need
to interpret the resulting linkage distances as such squared values.

The idea of median linkage (or Weighted Pair-Group Method using Centroids,
WPGMC) is to minimize the distance of the medians, $\left\lVert m_{A\cup
B}-m_{C}\right\rVert$, where the median is recursively defined as $m_{A\cup
B}=\tfrac{1}{2}(m_{A}+m_{B})$, the midpoint of the previous medians. For
squared Euclidean distances, we again have a recurrent formula; the derivation
is exactly as for centroid linkage, but with fixed $n_{A}=n_{B}=1$. Median
linkage and centroid linkage have the oddity that the distance $d(A\cup B,C)$
can be less than the distance of $d(A,C)$, which can yield non-monotone
dendrograms: if we draw a tree representing the cluster merges, and use the
linkage distance as height of a branch, the resulting tree does not
monotonously grow. Such anomalies in the trees also referred to as inversions,
and can only if a linkages does not have the reducibility property of [3]).
Intuitively, this happens when the new center is between two well-separated
clusters, and then closer to a third than either of the two, as illustrated in
Fig. 1. This can cause undesirable results, and these linkages should be used
with care.

abmcd(a,c)d({a,b},c) Figure 1: Example why Median and Centroid linkages are
non-monotone: the midpoint $m$ of the merged cluster $\\{a,b\\}$ is closer to
$c$ than any of its clusters members $a$ and $b$ were.

The popular Ward linkage optimizes the criterion [21, 1, 5]:

$\displaystyle d_{\text{Ward}}(A,B)=$ $\displaystyle\tfrac{2n_{A}\cdot
n_{B}}{n_{\\!A\\!B}}\left\lVert\smash{\mu_{A}-\mu_{B}}\mathstrut\right\rVert^{2}\enskip.$
(4)

The factor 2 in this equation ensures that
$d_{\text{Ward}}(\\{a\\},\\{b\\})=\left\lVert\smash{a,b}\mathstrut\right\rVert^{2}$,
as desired for one-elemental clusters. This criterion can be described as
“minimum increase in the sum of squares” [15], which may come as a surprise
given that the equation only uses the means, and does not appear to contain
the sum of squares. The reader may have noticed that $k$-means clustering also
minimizes the sum of squares. The main difference here is that Ward linkage
imposes a hierarchical structure on the result, whereas $k$-means imposes a
flat partitioning into $k$ partitions. Usually, the result of Ward linkage cut
at $k$ partitions will be (often substantially) worse than that of $k$-means
(for the consistency reasons explained in [16] for the case of medoid
linkage), but on the other hand, $k$-means results for varying $k$ will
usually not nest into a hierarchy of clusters. Equation 4 can be obtained from
rewriting the increase in the sum of squares via the König-Huygens theorem:

$\displaystyle d_{\text{Ward}}(A,B)=$
$\displaystyle\textstyle\sum\limits_{x\in A{\cup}B}\left\lVert
x{-}\mu_{AB}\right\rVert^{2}-\textstyle\sum\limits_{a\in A}\left\lVert
a{-}\mu_{A}\right\rVert^{2}-\textstyle\sum\limits_{b\in B}\left\lVert
b{-}\mu_{B}\right\rVert^{2}$ $\displaystyle=$
$\displaystyle\tfrac{2n_{A}n_{B}}{n_{\\!A\\!B}}\left\lVert\mu_{A}{-}\mu_{B}\right\rVert^{2}$

The Lance-Williams recurrence given in Tab. 1 follows (full derivation
omitted):

$\displaystyle d_{\text{Ward}}(A{\cup}B,C)=$
$\displaystyle\tfrac{2n_{\\!A\\!B}n_{C}}{n_{\\!A\\!B\\!C}}\left\lVert\mu_{AB}{-}\mu_{C}\right\rVert^{2}=\tfrac{2n_{\\!A\\!B}n_{C}}{n_{\\!A\\!B\\!C}}\left\lVert\smash{\tfrac{n_{A}}{n_{\\!A\\!B}}\mu_{A}{+}\tfrac{n_{B}}{n_{\\!A\\!B}}\mu_{B}{-}\mu_{C}}\mathstrut\right\rVert^{2}$
$\displaystyle=$
$\displaystyle\tfrac{n_{\\!A\\!C}}{n_{\\!A\\!B\\!C}}d_{\text{Ward}}(A,C)+\tfrac{n_{\\!B\\!C}}{n_{\\!A\\!B\\!C}}d_{\text{Ward}}(B,C)-\tfrac{n_{C}}{n_{\\!A\\!B\\!C}}d_{\text{Ward}}(A,B)$

##  3 The Cluster Feature Tree (CF-Tree)

$\mathrm{CF}_{1}$$\mathrm{CF}_{2}$$\mathrm{CF}_{3}$…$\mathrm{CF}_{1}$$\mathrm{CF}_{2}$$\mathrm{CF}_{3}$…$\mathrm{CF}_{1}$$\mathrm{CF}_{2}$$\mathrm{CF}_{3}$…$\mathrm{CF}_{1}$$\mathrm{CF}_{2}$…
Figure 2: Basic structure of a CF-Tree

We now briefly introduce the CF-Tree of the improved BETULA version [10, 9],
which improves the numerical accuracy of the original BIRCH CF-Tree [23, 22].

The CF-Tree (Cluster Feature Tree) is a basic height-balanced tree storing
cluster features (CF). Each BETULA cluster feature [10] is a triple

$\displaystyle\mathrm{CF}$ $\displaystyle:=(n,\mu,\mathrm{SSE})$ (5)

where $n$ in this context is the number of data points or their aggregated
weight, $\mu$ denotes the mean vector, and $\mathrm{SSE}$ is the sum of
squared deviations from the mean. Two BETULA cluster features can be
efficiently combined into one:

$\displaystyle n_{\\!A\\!B}=$ $\displaystyle n_{A}+n_{B}$ (6)
$\displaystyle\mu_{AB}=$
$\displaystyle\mu_{A}+\tfrac{n_{B}}{n_{\\!A\\!B}}(\mu_{B}-\mu_{A})$ (7)
$\displaystyle\mathrm{SSE}_{AB}=$
$\displaystyle\mathrm{SSE}_{A}+\mathrm{SSE}_{B}+n_{B}(\mu_{B}-\mu_{A})(\mu_{B}-\mu_{AB})\enskip.$
(8)

A single data point $x$ can be trivially represented by a Cluster Feature
$(1,x,0)$. These update rules also follow from the König-Huygens theorem, and
can be found in [9]. The numerical inaccuracies of the original BIRCH approach
were previously observed by [17].

The CF-Tree is a height-balanced tree: each leaf is a cluster feature that
represents data point(s). Inner nodes store the aggregated information of
their children. The tree is built by sequentially inserting all data points.
When adding a data point or cluster feature to the tree, it is inserted by
traversing the tree and choosing the least distant node on each level. When a
leaf entry is reached the data is added to the leaf entry if the absorption
threshold (c.f. Section 4) is not violated. If the data cannot be added to an
existing leaf entry, a new leaf entry is generated. The threshold can be set
based on expert input which results in a tree of variable size but with a
fixed accuracy guarantee. But because we can also add cluster features to the
CF-Tree the same way, we can dynamically rebuild the tree from its leaf
entries with an increased threshold once a selected maximum number of leaf
entries is reached, to reduce the trees memory usage. In this case the tree is
build within a fixed size range but with variable accuracy, which is
beneficial for scenarios where we have memory resource-constraints.

##  4 Distances for Cluster Features

Zhang et al. [23, 22] originally proposed several distance functions and
absorption criteria for BIRCH cluster features. Both essentially measure a
distance, but distance functions are used to choose insertion subtrees,
whereas absorption criteria are used to decide when to add to an existing
node, or when create a new node. It is difficult to argue why the two
parameters should ever be set different. As suggested by [10], we do not
distinguish between distances and absorption criteria in the following, as
there is no benefit of doing so.

Euclidean distance: $\displaystyle\text{D0}(A,B)=$
$\displaystyle\left\lVert\smash{\mu_{A}-\mu_{B}}\mathstrut\right\rVert_{\phantom{1}}$
(10) Manhattan distance: $\displaystyle\text{D1}(A,B)=$
$\displaystyle\left\lVert\smash{\mu_{A}-\mu_{B}}\mathstrut\right\rVert_{1}$
(11) Inter-cluster distance: $\displaystyle\text{D2}(A,B)=$
$\displaystyle\sqrt{\tfrac{1}{n_{A}n_{B}}\textstyle\sum_{x\in A}\sum_{y\in
B}\left\lVert\smash{x-y}\mathstrut\right\rVert^{2}}$ (12) Intra-cluster
distance (= diameter absorption criterion): $\displaystyle\text{D3}(A,B)=$
$\displaystyle\sqrt{\tfrac{1}{n_{\\!A\\!B}(n_{\\!A\\!B}-1)}\textstyle\sum_{x,y\in
AB}\left\lVert\smash{x-y}\mathstrut\right\rVert^{2}}$ (13) Variance-increase
distance: $\displaystyle\text{D4}(A,B)=$
$\displaystyle\sqrt{\textstyle\sum_{x\in
AB}\left\lVert\smash{x{-}\mu_{AB}}\mathstrut\right\rVert^{2}{-}\\!\sum_{x\in
A}\left\lVert\smash{x{-}\mu_{A}}\mathstrut\right\rVert^{2}{-}\\!\sum_{x\in
B}\left\lVert\smash{x{-}\mu_{B}}\mathstrut\right\rVert^{2}}$ (14) Radius
absorption criterion: $\displaystyle\text{R}(A,B)=$
$\displaystyle\sqrt{\tfrac{1}{n_{\\!A\\!B}}\textstyle\sum_{x\in
AB}\left\lVert\smash{x-\mu_{AB}}\mathstrut\right\rVert^{2}}$ (15)

These distances can be computed efficiently based on the summary statistics
stored in BETULA cluster features. The corresponding equations and their
derivations can be found in [9].

##  5 Hierarchical Clustering with Cluster Features

While the CF-Tree itself already is a form of hierarchical clustering, its
levels and inner structure are not in a form that is easily interpretable.
Because of this, it is usually only used for data aggregation in preparation
of the actual clustering, for which only the leaf entries are used. Naively,
one could just use the centers of the leaf entries and use a standard
hierarchical clustering algorithm. This approach discards the variance
information of the clustering features.

The interesting observation now is that linkages and CF distances are not very
different. We show that there is a correspondence between certain linkages and
CF distances, which can be exploited for clustering by incorporating
additional information stored in the cluster features besides using only the
centers.

Table 2: Linkage strategy for (squared) Euclidean distances and the corresponding BIRCH distance with their objective function. Linkage | Closed form | BIRCH Distance
---|---|---
UPGMA | $\tfrac{1}{n_{A}n_{B}}\textstyle\sum_{x\in A}\sum_{y\in B}\left\lVert\smash{x-y}\mathstrut\right\rVert^{2}$ | $\text{D2}^{2}$
UPGMC | $\left\lVert\smash{\mu_{A}-\mu_{B}}\mathstrut\right\rVert$ | $\text{D0}^{2}$
Ward | $\tfrac{2n_{A}n_{B}}{n_{\\!A\\!B}}\left\lVert\smash{\mu_{A}-\mu_{B}}\mathstrut\right\rVert^{2}$ | $2\cdot\text{D4}^{2}$

In Tab. 2 we summarize the identified relationships between linkage strategies
known from literature and BIRCH distances with their respective object
function. The most obvious similarity can be seen when looking at the
Centroid-Euclidean-Distance (D0, Eq. 10) and the Centroid-linkage (Eq. 3),
which are almost the same. The differences between Ward-linkage (Eq. 4) and
the Variance-increase-distance (D4, Eq. 14) are only in the notation and that
D4 squared is Ward, but since BETULA internally uses squared distances for
computational reasons, this difference is trivial. The last linkage that can
be expressed as a BETULA distance is UPGMA, which is effectively the squared
Inter-cluster-distance (D2, Eq. 12). This similarity becomes obvious when
replacing the general equation with the one for UPGMA with the squared
Euclidean distance:

$\displaystyle d_{\text{UPGMA}}(A,B)=$ $\displaystyle\tfrac{1}{n_{A}\cdot
n_{B}}\textstyle\sum_{a\in A}\sum_{b\in B}d(a,b)$ (16) $\displaystyle=$
$\displaystyle\tfrac{1}{n_{A}\cdot n_{B}}\textstyle\sum_{a\in A}\sum_{b\in
B}\left\lVert\smash{a-b}\mathstrut\right\rVert^{2}.$ (17)

While WPGMA and WPGMA cannot have an exact match, we may nevertheless choose
D2 respectively D0 as with their “unweighted” counterparts because of their
close relationship. With this knowledge we can now meaningfully transition
from cluster features into hierarchical clustering with the Lance-Williams
formula by calculating the distance matrix based on the corresponding
distances between the cluster features.

We can also do the opposite, and instead of using the classic linkage
strategies, we can perform the following adaptation to hierarchical clustering
of cluster features, while using the distance functions from Section 4 instead
of a separate linkage strategy. As in standard hierarchical clustering (e.g.,
AGNES), we find the smallest non-diagonal value in the distance matrix to find
the best next merge. But instead of combining distances using the Lance-
William equation, we can instead combine the corresponding two cluster
features using the update Eqs. (6) to (8), and compute new distances with
respect to the new CF.

For both cases (using Lance-Williams, and using CF distances), we can use the
approach of Anderberg [1] and NN-chain [13] for acceleration. While the first
does not improve the worst-case complexity of
${O\mathopen{}(|\mathrm{CF}|^{3})\mathclose{}}$, it typically performs closer
to quadratic in runtime. The second may yield different results for non-
reducible distances (c.f. [3], Centroid and Median linkage), but guarantees
${O\mathopen{}(|\mathrm{CF}|^{2})\mathclose{}}$ runtime; furthermore, it can
be implemented with only linear memory for some linkages. As the CF-Tree
allows us to reduce the data to a constant size less than
${O\mathopen{}(\sqrt{N})\mathclose{}}$ respectively
${O\mathopen{}(\sqrt[3]{N})\mathclose{}}$ cluster features, we can then
perform hierarchical clustering in time linear in the original data input size
$N$ and within a constant memory limit, making this useful in resource-limited
data processing.

##  6 Experiments

We evaluate hierarchical clustering with and without BETULA cluster features.
We are interested in comparing the runtime and quality of aggregated and non-
aggregated algorithms, but do not compare different linkage strategies. As
baselines, we use the Anderberg [1] and NN-Chain [13] algorithms (the latter
in an implementation that only uses linear-memory). For BETULA we allow a
maximum of 25 000 leaf entries, such that no data aggregation takes place for
the smallest data sets. Both of these HAC algorithms can be combined with
BETULA in different ways. We use “full data” when not using BETULA
aggregation, “CF centers” denotes the naive approach using the Euclidean
distances of the cluster features centers and no weights (found in many
implementations of BIRCH). For “CF linkage”, the initial distances are
computed using the full cluster feature information, but afterward the
algorithm uses the Lance-Williams equations for hierarchical aggregation. The
“CF aggregation” approach maintains cluster features throughout the
hierarchical clustering process.

All algorithms are implemented in the Java framework ELKI [18]. By using the
same framework for all implementations we try to minimize the effects caused
by implementation differences, as recommended for comparing algorithms [6].
Each experiment was repeated 10 times with varying input order on a single
core of an AMD EPYC™ 7302 CPU. Because of our focus on improving the
scalability, we may rely on synthetic data for this experiment. We sample data
from both a 5-dimensional uniformly distributed hypercube, respectively from a
combination of 500 5-dimensional Gaussian clusters. While the uniform
distribution is supposed to adversely affect the aggregation quality of
BETULA, the Gaussian clusters are well-suited for this type of aggregation.

First we look at the runtime analysis with 50 000 data points, the biggest
data set the baseline Anderberg implementation can process.111Because the
array size reaches the $2^{31}$ array length limit of Java. As Tab. 3 shows,
the NN-Chain algorithm can be significantly faster than the Anderberg
algorithm (at least for this low-dimensional data set). While we still largely
limit the data aggregation of BETULA (set to a maximum of 25 000 leaves), the
number of CFs obviously is the main contributor to runtime as seen when
comparing the results on uniform data with those on Gaussians. The design of
BETULA does not allow for an exact control of this number, but when the given
maximum is reached a smaller tree is built from the current leaves. By
choosing a smaller limit, an even larger speedup over the baseline algorithms
would be possible. Because the data aggregation performed by BETULA is
deterministic, the same input leads to the same tree (and hence number of CF
in Tab. 3) independent of the clustering step used afterwards.

Table 3: Average runtime in seconds and number of cluster features after BETULA initialization for different algorithms and data generators with $N$ = 50 000 and $d$ = 5 dimensions. Algorithm | Input | Uniform | Gaussian
---|---|---|---
Runtime | |CF| | Runtime | |CF|
Anderberg | full data | 142.96 | - | 147.05 | -
Anderberg | CF centers | 12.99 | 17482.4 | 4.88 | 9496.7
Anderberg | CF linkage | 12.85 | 17482.4 | 4.71 | 9496.7
NN-Chain | full data | 49.64 | - | 49.44 | -
NN-Chain | CF aggregation | 11.39 | 17482.4 | 4.36 | 9496.7
NN-Chain | CF linkage | 7.18 | 17482.4 | 3.15 | 9496.7

(a) UPGMC

(b) Ward

Figure 3: Runtime versus data set size on uniformly distributed data.

Next we look at the scalability of our approach. Fig. 3 shows the runtime of
the algorithms for Centroid (UPGMC) and Ward linkage on various data set sizes
in a log-log-plot. We can see the quadratic increase in runtime of the
baseline NN-Chain and Anderberg algorithms. For the Anderberg baseline, only
times up to 50 000 points are given because of Java array size restrictions,
but scaling would be at least as bad as for the NN-Chain algorithm. The
runtime for all variants that use BETULA for data aggregation seems to
fluctuate around some constant value. This is caused by changes in the number
of tree leaf CFs (because the results are averaged over multiple permutations
of the data set, tree sizes and tree rebuilds are not constant for a
particular data set size). Even for big data set sizes, the CF-tree
construction phase which has a runtime in ${O\mathopen{}(N)\mathclose{}}$
plays a minor role compared to the later hierarchical clustering phase with
its ${O\mathopen{}(|\mathrm{CF}|^{2})\mathclose{}}$ runtime; and reading the
input data once is unavoidable in most applications.

Table 4: Root mean squared deviation for different linkages, algorithms, and data sets with $N$ = 50 000. All values are given as mean value plus minus standard deviation over 10 runs. Algorithm | Input | Generation | UPGMC | UPGMA | Ward
---|---|---|---|---|---
Anderberg | full data | Uniform |  10.34 $\pm$ 0.00 |  10.11 $\pm$ 0.00 |  10.12 $\pm$ 0.00
Anderberg | CF linkage | Uniform |  10.53 $\pm$ 0.03 |  10.29 $\pm$ 0.02 |  10.27 $\pm$ 0.01
NN-Chain | full data | Uniform |  10.17 $\pm$ 0.04 | - |  10.17 $\pm$ 0.04
NN-Chain | CF linkage | Uniform |  10.36 $\pm$ 0.03 | - |  10.35 $\pm$ 0.02
Anderberg | full data | Gaussian |  3.56 $\pm$ 0.00 |  3.51 $\pm$ 0.00 |  3.38 $\pm$ 0.00
Anderberg | CF linkage | Gaussian |  3.56 $\pm$ 0.00 |  3.53 $\pm$ 0.03 |  3.40 $\pm$ 0.01
NN-Chain | full data | Gaussian |  5.25 $\pm$ 0.05 | - |  5.25 $\pm$ 0.05
NN-Chain | CF linkage | Gaussian |  5.09 $\pm$ 0.05 | - |  4.95 $\pm$ 0.08

The quality of a hierarchical clustering is hard to evaluate properly, because
it very much depends on the data set and application. A thorough evaluation of
a clustering on real data will usually require manual inspection by a domain
expert. For our experiments, we chose to simply compare the variability of the
clusters when cut into $500$ clusters, assuming that a result with less spread
also indicates a better clustering. Tab. 4 shows the root mean squared
deviation (RMSD) for all relevant algorithms for the data sets with 50 000
data points. Here, the runtime improvements with BETULA were significant but
the difference in quality for all algorithms is very small for the uniform
data set (within the variability caused by NN-Chain using a different
processing order than Anderberg). The results on the Gaussian data warrants
further discussion. On this data set, which is favorable to the assumptions of
BETULA, the negative effect of the data aggregation when combined with
Anderberg is even smaller. There is no measurable difference for UPGMC and
only slightly worse results for UPGMA and WARD. The NN-Chain algorithm on the
other hand suffers from its known differences to the Anderberg algorithm
(making greedy locally optimal choices, as opposed to choosing the global
optimum).

(a) Uniform

(b) Gaussian

Figure 4: Root mean squared deviation versus data set size using centroid
(UPGMC) linkage for both data set generators and $k$ = 500.

Finally we evaluate the scalability of our approach. Fig. 4 shows the root
mean squared deviation of the $k$ = 500 clusters. For $N$ = 25 000, where no
aggregation takes place, the results are the same, with and without BETULA.
The results for the data sets with more entries are similar. while the number
of cluster features used stays below 25 000, the quality only is impacted
slightly. On the uniform data the difference in quality between the algorithms
is small. The Gaussian data shows that the difference between the NN-Chain and
Anderberg algorithms is bigger than that of the data aggregation with BETULA.
The only outlier is the combination of BETULA and NN-Chain, which shows a
noticeablly worse result.

##  7 Conclusion

In this section we discussed how the scalability of hierarchical clustering
can be improved by integrating data aggregation techniques from BIRCH (or its
more stable variant BETULA). We show how hierarchical linkages relate to
particular BIRCH distance criteria, and that some criteria improve the
clustering for the same metric. We use this relation to accelerate the
hierarchical clustering with small effects on the quality of the clustering
while keeping most benefits of hierarchical approaches and expanding it to
data set sizes not practical for the standard approaches. This optimization
allows the usage of hierarchical clustering on small or embedded systems with
limited memory by using data aggregation to decouple the total data size from
the input data size of the much more expensive hierarchical clustering step,
leading to better scalability. While there is some loss in clustering quality,
it is small enough for most use cases of explorative data analysis, i.e., we
will still be able to make meaningful choices for the subsequent steps in our
data analysis process.

## References

  * [1] Michael R. Anderberg  “Cluster analysis for applications”  Academic Press, 1973
  * [2] S.. Ao et al.  “CLUSTAG: hierarchical clustering and graph methods for selecting tag SNPs”  In _Bioinformatics_ 21.8, 2005, pp. 1735–1736
  * [3] Michel Bruynooghe  “Méthodes nouvelles en classification automatique de données taxinomiques nombreuses”  In _Statistique et analyse des données_ 2.3 Association pour la statistique et ses illustrations, 1977, pp. 24–42  URL: https://www.numdam.org/item/SAD_1977__2_3_24_0/
  * [4] D. Herr, Q. Han, S. Lohmann and T. Ertl  “Visual Clutter Reduction through Hierarchy-based Projection of High-dimensional Labeled Data”  In _Graphics Interface Conference_ , 2016, pp. 109–116
  * [5] Leonard Kaufman and Peter J. Rousseeuw  “Finding Groups in Data: An Introduction to Cluster Analysis”  John Wiley & Sons, 1990
  * [6] Hans-Peter Kriegel, Erich Schubert and Arthur Zimek  “The (black) art of runtime evaluation: Are we comparing algorithms or implementations?” Online first 2016, paginated 2017  In _Knowledge and Information Systems (KAIS)_ 52.2, 2017, pp. 341–378  URL: https://doi.org/10.1007/s10115-016-1004-2
  * [7] G.. Lance and W.. Williams  “A General Theory of Classificatory Sorting Strategies: 1. Hierarchical Systems”  In _The Computer Journal_ 9.4, 1967, pp. 373–380  URL: https://doi.org/10.1093/comjnl/9.4.373
  * [8] G.. Lance and W.. Williams  “A Generalized Sorting Strategy for Computer Classifications”  In _Nature_ 212.5058, 1966, pp. 218–218  URL: https://doi.org/10.1038/212218a0
  * [9] Andreas Lang and Erich Schubert  “BETULA: Fast Clustering of Large Data with Improved BIRCH CF-Trees”  In _Information Systems_ 108, 2022, pp. 101918  URL: https://doi.org/10.1016/j.is.2021.101918
  * [10] Andreas Lang and Erich Schubert  “BETULA: Numerically Stable CF-Trees for BIRCH Clustering” best paper candidate  In _Proceedings of the 13th International Conference on Similarity Search and Applications SISAP 2020, Copenhagen, Denmark_ , 2020, pp. 281–296  URL: https://doi.org/10.1007/978-3-030-60936-8_22
  * [11] Louis L. McQuitty  “Elementary Linkage Analysis for Isolating Orthogonal and Oblique Types and Typal Relevancies”  In _Educational and Psychological Measurement_ 17.2, 1957, pp. 207–229  URL: https://doi.org/10.1177/001316445701700204
  * [12] S. Miyamoto, Y. Kaizu and Y. Endo  “Hierarchical and Non-Hierarchical Medoid Clustering Using Asymmetric Similarity Measures”  In _SCIS/ISIS_ , 2016, pp. 400–403
  * [13] Fionn Murtagh  “A Survey of Recent Advances in Hierarchical Clustering Algorithms”  In _The Computer Journal_ 26.4, 1983, pp. 354–359  URL: https://doi.org/10.1093/comjnl/26.4.354
  * [14] Fionn Murtagh and Pierre Legendre  “Ward’s Hierarchical Agglomerative Clustering Method: Which Algorithms Implement Ward’s Criterion?”  In _Journal of Classification_ 31.3, 2014, pp. 274–295  URL: https://doi.org/10.1007/s00357-014-9161-z
  * [15] János Podani  “New combinatorial clustering methods”  In _Numerical syntaxonomy_ Dordrecht: Springer Netherlands, 1989, pp. 61–77
  * [16] Erich Schubert  “HACAM: Hierarchical Agglomerative Clustering Around Medoids – and its Limitations”  In _Proceedings of the LWDA 2021 Workshops: FGWM, KDML, FGWI-BIA, and FGIR, Online, September 1-3, 2021_ 2993, CEUR Workshop Proceedings  CEUR-WS.org, 2021, pp. 191–204  URL: http://ceur-ws.org/Vol-2993/paper-19.pdf
  * [17] Erich Schubert and Michael Gertz  “Numerically Stable Parallel Computation of (Co-)Variance” SSDBM 2018 best paper award  In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management (SSDBM), Bolzano-Bozen, Italy_ , 2018, pp. 10:1–10:12  URL: https://doi.org/10.1145/3221269.3223036
  * [18] Erich Schubert and Arthur Zimek  “ELKI: A large open-source library for data analysis - ELKI Release 0.7.5 "Heidelberg"”  In _CoRR_ abs/1902.03616, 2019  URL: http://arxiv.org/abs/1902.03616
  * [19] P… Sneath  “The Application of Computers to Taxonomy”  In _Journal of General Microbiology_ 17.1, 1957, pp. 201–226
  * [20] R.R. Sokal and P.H.A. Sneath  “Principles of Numerical Taxonomy”, Books in biology  W. H. Freeman, 1963
  * [21] David Wishart  “256. Note: An Algorithm for Hierarchical Classifications”  In _Biometrics_ 25.1 Wiley, International Biometric Society, 1969, pp. 165–170  URL: http://www.jstor.org/stable/2528688
  * [22] Thian Zhang, Raghu Ramakrishnan and Miron Livny  “Birch: A new data clustering algorithm and its applications”  In _Data Mining and Knowledge Discovery_ 1.2, 1997, pp. 141–182  URL: http://www.ece.nwu.edu/~harsha/Clustering/newkbspaper.ps
  * [23] Tian Zhang, Raghu Ramakrishnan and Miron Livny  “BIRCH: An Efficient Data Clustering Method for Very Large Databases”  In _Proceedings of the 1996 ACM SIGMOD International Conference on Management of Data_ , 1996, pp. 103–114  URL: http://www.ece.nwu.edu/~harsha/Clustering/sigmodpaper.ps


# Vector calculus in two-dimensional space

Marián Fecko
Department of Theoretical Physics
Faculty of Mathematics, Physics and Informatics
Comenius University in Bratislava e-mail<EMAIL_ADDRESS>
_Vector calculus in three-dimensional space is ubiquitous in applications of
mathematics in physics and engineering. Its two-dimensional version is,
however, quite rare. Here we try to provide a pedagogical account of the
subject. It is based on the logic of theory of differential forms. For readers
not familiar with the latter, the results are presented in detail in the
standard language and notations._

###### Contents

  1. 1 Introduction
  2. 2 How it works in three dimensions
  3. 3 How it works in two dimensions
    1. 3.1 Hamiltonian fields
    2. 3.2 Auxiliary third dimension
    3. 3.3 Integral identities and Green’s theorem
    4. 3.4 Perpendicular vector field
    5. 3.5 Poincaré lemma
  4. 4 2D vector calculus in 2D hydrodynamics
    1. 4.1 Incompressible fluid and stream function
    2. 4.2 Vorticity-free flow and its potential
    3. 4.3 Where from complex analysis arises
  5. 5 Conclusion

##  1 Introduction

We live in three-dimensional space. Therefore also mathematics connected with
the three-dimensional space turns out to be especially important as well as
developed.

In particular, it turns out that _vector calculus_ ideally suits for neat and
clear mathematical description of a number of important phenomena around us
(diffusion, heat flow, electricity, magnetism, gravitational field, …; see
e.g. [4] [7], [9], [10], etc.). Useful concepts are introduced in it (like
flux of a vector field for a surface) and useful and non-trivial results (as,
for example, Gauss’ theorem) are derived for them.

Two dimensional version of the vector calculus is, however, considerably less
known. It should play the same role for 2D phenomena as the standard vector
calculus does in 3D. Nevertheless, what and how exactly is to be changed in
mathematical relations while switching from 3D to 2D may not always be quite
evident.

In this text we therefore concentrate on this very question: How actually
_the_ analogy of the three dimensional vector calculus, applicable in _two_
dimensions, looks like?

Several approaches might exist, see e.g. [5] or [8]. Here wee try to be led by
logic of the theory of _differential forms_. For reader unfamiliar with the
theory it might look as an overkill. It is, however, well-known (see e.g. [1],
[2], [11] or $8.5 in [3]), that this very point of view turns out to be
extremely instructive and efficient in  _three_ -dimensional case: For
example, all relevant _differential operators_ do appear automatically as well
as relations between them (differently looking curl, grad and div are just
masked versions of universal _exterior_ derivative of forms). This is also the
case for all _integral theorems_ in which the operators occur (as particular
cases of each time the same _Stokes_ theorem for forms).

In this text we can see that differential forms approach is definitely not a
bad choice also here.

If forms in general (and so also vector calculus in the language of forms in
particular) is virtually unknown to the reader, derivations might be
technically unclear, but:

1\. _Results_ will be clear, since they will be also presented in _elementary_
language, so that just to understand _how it all falls out_ , forms are not
needed.

2\. In addition, rough idea perhaps still might be caught, and consequently
the forms could captivate the reader, resulting in decision to learn more
about them in the future.

##  2 How it works in three dimensions

In vector calculus one often hears phrases like “integrate vector field over a
surface” (resulting in its _flux_ for the surface). In integration theory,
however, we learn (see e.g. [1], [2], [11] or Chapter 7 in [3]), that

\- differential _forms_ alone are integrated

\- $p$-form is integrated over a $p$-dimensional domain.

So if something is integrated

\- along a curve, it is necessarily a 1-form,

\- over a surface, it is necessarily a 2-form,

\- over a volume, it is necessarily a 3-form, respectively.

How should one understand the fact, then, that under surface integrals, where
2-form is to be standing, one sees expression of the structure
$\mathbf{A}\cdot d\mathbf{S}$, i.e. not to see _vector field_ $\mathbf{A}$
there is like even deny what everything someone does? Well, the answer is that
what we _actually_ see there is _the whole_ $\mathbf{A}\cdot d\mathbf{S}$ and
this in fact _is_ a 2-form. It is, however, _uniquely parametrized_ in terms
of the vector field $\mathbf{A}$.

In total, parametrizations of all types of forms in $E^{3}$ (three dimensional
Euclidean space) look as follows (see e.g. section 8.5 in [3] mentioned
above):

There are 0-forms, 1-forms, 2-forms and 3-forms (this is just because of three
dimensions of the space) and we have, at each of these degrees, operation of
_exterior derivative_ $d$, raising the degree in one unit and such that its
square vanishes (this is so in any dimension). One can display the situation
in terms of the diagram

$\Omega^{0}\overset{d}{\to}\Omega^{1}\overset{d}{\to}\Omega^{2}\overset{d}{\to}\Omega^{3}\hskip
56.9055ptdd=0$ (1)

(it is known as the _de Rham complex_ ; the space of $p$-forms in $E^{3}$ is
denoted as $\Omega^{p}$). Since there is also (usual Euclidean) _metric
tensor_ on $E^{3}$, we have in addition the _Hodge operator_ on $p$-forms. It
is, in general, a canonical linear isomorphism (denoted by star) of the linear
space of $p$-forms and $(n-p)$-forms, which squares to plus or minus identity.
(It is just plus on each degree on $E^{3}$. Here $n$ is dimension of the space
under consideration.)

So in _three_ -dimensional space it provides the following two canonical
isomorphisms:

$\Omega^{0}\overset{*}{\leftrightarrow}\Omega^{3}\hskip
42.67912pt\Omega^{1}\overset{*}{\leftrightarrow}\Omega^{2}\hskip
42.67912pt*^{-1}=*$ (2)

They enable us to “identify” 2-forms with 1-forms as well as 3-forms with
0-forms. (If we need somewhere a 2-form $\beta$, we can _parametrize_ it in
terms of a 1-form $\alpha$, i.e. write it as $\beta=*\alpha$ where $\alpha$ is
unique 1-form: $\alpha=*\beta$.) So “actually” we need just 0-forms (i.e.
_functions_ ; we denote as $\mathcal{F}$ the linear space of functions) and
1-forms (the rest may be parametrized in terms of the two).

The metric tensor provides another two important canonical isomorphisms,
namely the (mutually inverse) operations of the _raising and lowering of
indices_ (they are denoted as $\sharp$ and $\flat$, inspiration originating in
musical notation). They turn 1-forms into vector fields ($\sharp$) and vice
versa ($\flat$). If the linear space of vector fields on $E^{3}$ is denoted as
$\mathfrak{X}$, we have

$\Omega^{1}\underset{\flat}{\overset{\sharp}{\rightleftarrows}}\mathfrak{X}\hskip
56.9055pt\sharp^{-1}=\flat\hskip 28.45274pt\flat^{-1}=\sharp$ (3)

This is the reason we can also forget about 1-forms and manage with 111In this
respect functions and vector fields resemble concept of _essential_ amino-
acids in nutrition science: Although there are roughly 20 amino-acids in
total, it is actually enough to take care of the essential ones (roughly half
of them), our body is then able to produce the remaining ones from them. In
three dimensional Euclidean space our body is able to produce _any_
differential form from functions and vector fields. just _functions and vector
fields_! So differential forms in $E^{3}$ become _as if_ completely out of the
game! We can concisely express the situation in terms of the commutative
diagram

$\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}@>{d}>{}>\Omega^{3}\\\
@V{\text{i}d}V{}V@V{}V{\sharp}V@V{}V{\sharp*}V@V{}V{*}V\\\
\mathcal{F}@>{}>{a_{0}}>\mathfrak{X}@>{}>{a_{1}}>\mathfrak{X}@>{}>{a_{2}}>\mathcal{F}\\\
\end{CD}$ (4)

Vertical arrows denote the corresponding canonical isomorphisms of various
degrees of forms (the upper line) onto scalar fields $\mathcal{F}$ and vector
fields $\mathfrak{X}$. When the arrows are reversed, we get equivalent diagram

$\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}@>{d}>{}>\Omega^{3}\\\
@A{\text{i}d}A{}A@A{}A{\flat}A@A{}A{*\flat}A@A{}A{*}A\\\
\mathcal{F}@>{}>{a_{0}}>\mathfrak{X}@>{}>{a_{1}}>\mathfrak{X}@>{}>{a_{2}}>\mathcal{F}\\\
\end{CD}$ (5)

When the (upward directed) arrows are applied onto scalar and vector fields
(on some $f$ and $\mathbf{A}$), we get exactly those standard expressions we
used to see under integral sign (see section 8.5 in [3]):

$f\in\Omega^{0}\hskip 28.45274pt\mathbf{A}\cdot d\mathbf{r}\in\Omega^{1}\hskip
28.45274pt\mathbf{A}\cdot d\mathbf{S}\in\Omega^{2}\hskip
28.45274ptfdV\in\Omega^{3}$ (6)

The arrows $a_{0},a_{1},a_{2}$ in the bottom line of both diagrams are
_effective_ operations (composition of corresponding three arrows - upward, to
the right and downward) on objects sitting in the bottom line, which in a
sense “substitute” operation of the exterior derivative (arrows $d$), which
“really” acts on forms in the upper line. From the diagrams we can read off
that

$a_{0}=\sharp d\hskip 28.45274pta_{1}=\sharp*d\flat\hskip
28.45274pta_{2}=*d*\flat$ (7)

All of them are clearly _first_ order _differential_ operators, since they
contain one $d$. Computation in Cartesian coordinates in $E^{3}$ reveals that
they are exactly notorious operators grad, curl and div so that the diagram
(4) actually reads

$\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}@>{d}>{}>\Omega^{3}\\\
@V{\text{i}d}V{}V@V{}V{\sharp}V@V{}V{\sharp*}V@V{}V{*}V\\\
\mathcal{F}@>{}>{\text{\rm grad\,}}>\mathfrak{X}@>{}>{\text{\rm
curl\,}}>\mathfrak{X}@>{}>{{\text{\rm div\,}}}>\mathcal{F}\\\ \end{CD}$ (8)

From the fact that $dd=0$ (see (1)) and commutativity of the diagram we
immediately get well-known identities

$\text{\rm curl\,}\text{\rm grad\,}=0\hskip 19.91684pt{\text{\rm
div\,}}\text{\rm curl\,}=0$ (9)

(upstairs, composition of neighboring arrows results in zero operator, so the
same must be true downstairs).

From the three neighboring squares of the diagram (8) and the parametrization
(6) one can assemble the following three useful differential relations:

$df=\text{\rm grad\,}f\cdot d\mathbf{r}\hskip 19.91684ptd(\mathbf{A}\cdot
d\mathbf{r})=(\text{\rm curl\,}\mathbf{A})\cdot d\mathbf{S}\hskip
19.91684ptd(\mathbf{A}\cdot d\mathbf{S})=({\text{\rm div\,}}\mathbf{A})dV$
(10)

In order to obtain corresponding integral statements, we can make reference to
general _Stokes theorem_ (see [1], [2], [11] or Section 7.5 in [3]) from
integration theory of differential forms: If $\alpha$ is a $p$-form, $D$ is a
$(p+1)$-dimensional domain and $\partial D$ its $p$-dimensional boundary, then

$\int_{D}d\alpha=\int_{\partial D}\alpha$ (11)

For the three particular expressions $d\alpha$ from (10) we get the three
essential integral theorems of the vector calculus:

gradient theorem $\displaystyle\int_{c}\text{\rm grad\,}f\cdot d\mathbf{r}$
$\displaystyle:=f(B)-f(A)$ (12) Stokes theorem
$\displaystyle\int_{S}(\text{\rm curl\,}\mathbf{A})\cdot d\mathbf{S}$
$\displaystyle:=\oint_{\partial S}\mathbf{A}\cdot d\mathbf{r}$ (13) Gauss’s
theorem $\displaystyle\int_{V}({\text{\rm div\,}}\mathbf{A})dV$
$\displaystyle:=\oint_{\partial V}\mathbf{A}\cdot d\mathbf{S}$ (14)

##  3 How it works in two dimensions

In two-dimensional case, the de Rham complex, i.e. the analogue of (1), just
simplifies to

$\Omega^{0}\overset{d}{\to}\Omega^{1}\overset{d}{\to}\Omega^{2}\hskip
56.9055ptdd=0$ (15)

Key difference is in action of the Hodge star:

$\Omega^{0}\overset{*}{\leftrightarrow}\Omega^{2}\hskip
42.67912pt\Omega^{1}\overset{*}{\leftrightarrow}\Omega^{1}$ (16)

The left expression is a natural analogue of the left expression in (2), it
identifies the edge degrees of forms; explicitly

$*f=fdS\hskip 28.45274pt*(fdS)=f\hskip 42.67912ptdS\equiv dx\wedge dy=\
\text{area 2-form}$ (17)

This enables us to forget about 2-forms and express them in terms of 0-forms,
i.e. in terms of functions (scalar fields).

The right expression is, however, completely different: While in (2) it is an
isomorphism of _two different_ spaces, in (16) it is an isomorphism of a
_single_ space (the space of 1-forms) _on itself_ (differing from the
identity). Explicitly, in usual Cartesian coordinates $(x,y)$ in the plane,

$*dx=dy\hskip 42.67912pt*dy=-dx$ (18)

This does not mean that we cannot forget about 1-forms. Rather, it means that
in 2D there are as many as _two canonical_ ways how 1-forms may be replaced by
vector fields! One of them is the same like it was in 3D, i.e. via the
operation $\sharp$ (raising of index). It reads

$\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}\\\
@V{\text{i}d}V{}V@V{}V{\sharp}V@V{}V{*}V\\\
\mathcal{F}@>{}>{a_{0}}>\mathfrak{X}@>{}>{a_{1}}>\mathcal{F}\\\ \end{CD}$ (19)

When the arrows (directed upwards) are applied on scalar and vector fields (on
$f$ and $\mathbf{A}$) we again get standard expressions we used to see under
integral sign:

$f\in\Omega^{0}\hskip 28.45274pt\mathbf{A}\cdot d\mathbf{r}\equiv
A_{x}dx+A_{y}dy\in\Omega^{1}\hskip 28.45274ptfdS\in\Omega^{2}$ (20)

Another one is, however, available, now - we first apply the star operator
(after which we still remain within 1-forms) and _only then_ we raise the
index. So we have _two different_ analogues of the diagram (4):

$\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}\\\
@V{\text{i}d}V{}V@V{}V{\sharp}V@V{}V{*}V\\\
\mathcal{F}@>{}>{a_{0}}>\mathfrak{X}@>{}>{a_{1}}>\mathcal{F}\\\ \end{CD}\hskip
42.67912pt\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}\\\
@V{\text{i}d}V{}V@V{}V{\sharp*}V@V{}V{*}V\\\
\mathcal{F}@>{}>{b_{0}}>\mathfrak{X}@>{}>{b_{1}}>\mathcal{F}\\\ \end{CD}$ (21)

We see that also in 2D-vector calculus we make do with _vector and scalar_
fields (bottom lines). From the diagrams one can express explicitly the bottom
(effective) arrows and get

$a_{0}=\sharp d\hskip 28.45274pta_{1}=*d\flat\hskip
28.45274ptb_{0}=\sharp*d\hskip 28.45274ptb_{1}=*d*^{-1}\flat$ (22)

When the (differential) operators are computed in (Cartesian) coordinates
$(x,y)$, we learn that two of them are natural analogues of the situation in
3D (gradient and divergence), the remaining two are “new”, specific for 2D:

$\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}\\\
@V{\text{i}d}V{}V@V{}V{\sharp}V@V{}V{*}V\\\ \mathcal{F}@>{}>{\text{\rm
grad\,}}>\mathfrak{X}@>{}>{\text{\rm curl\,}_{3}}>\mathcal{F}\\\
\end{CD}\hskip
42.67912pt\begin{CD}\Omega^{0}@>{d}>{}>\Omega^{1}@>{d}>{}>\Omega^{2}\\\
@V{\text{i}d}V{}V@V{}V{\sharp*}V@V{}V{*}V\\\ \mathcal{F}@>{}>{\text{\rm
Ham\,}}>\mathfrak{X}@>{}>{-{\text{\rm div\,}}}>\mathcal{F}\\\ \end{CD}$ (23)

(Notation $b_{0}=\text{\rm Ham\,}$ is justified in section 3.1 and for
$a_{1}=\text{\rm curl\,}_{3}$ in section 3.2.) So, abstractly we have

$\text{\rm grad\,}=\sharp d\hskip 28.45274pt\text{\rm
curl\,}_{3}=*d\flat\hskip 28.45274pt\text{\rm Ham\,}=\sharp*d\hskip
28.45274pt{\text{\rm div\,}}=-*d*^{-1}\flat$ (24)

and their actions, in Cartesian coordinates $(x,y)$, read:

$\displaystyle\text{\rm grad\,}:$ $\displaystyle f$
$\displaystyle\mapsto(\partial_{x}f,\partial_{y}f)$ (25)
$\displaystyle\text{\rm curl\,}_{3}:$ $\displaystyle(A_{x},A_{y})$
$\displaystyle\mapsto(\partial_{x}A_{y}-\partial_{y}A_{x})$ (26)
$\displaystyle\text{\rm Ham\,}:$ $\displaystyle f$
$\displaystyle\mapsto(-\partial_{y}f,\partial_{x}f)$ (27)
$\displaystyle{\text{\rm div\,}}:$ $\displaystyle(A_{x},A_{y})$
$\displaystyle\mapsto(\partial_{x}A_{x}+\partial_{y}A_{y})$ (28)

One can easily check vanishing of composition of the two arrows in bottom
lines (in both diagrams):

$\text{\rm curl\,}_{3}\circ\text{\rm grad\,}=0\hskip 28.45274pt{\text{\rm
div\,}}\circ\text{\rm Ham\,}=0$ (29)

Indeed,

$\displaystyle\text{\rm curl\,}_{3}\circ\text{\rm grad\,}:$ $\displaystyle f$
$\displaystyle\mapsto(\partial_{x}f,\partial_{y}f)$
$\displaystyle\mapsto(\partial_{y}\partial_{x}f-\partial_{y}\partial_{x}f)$
$\displaystyle=0$ (30) $\displaystyle{\text{\rm div\,}}\circ\text{\rm Ham\,}:$
$\displaystyle f$ $\displaystyle\mapsto(-\partial_{y}f,\partial_{x}f)$
$\displaystyle\mapsto(-\partial_{x}\partial_{y}f,\partial_{y}\partial_{x}f)$
$\displaystyle=0$ (31)

This is the counterpart of (9). Notice that there are also two identities,
here. However, not because we put to use $dd=0$ on different degrees in a
single diagram, but rather on a single degree in two different diagrams.

It is also worth noticing that when two arrows from different diagrams are
composed, we get (for both possible cases) another well-known operator, the
_Laplace_ operator $\triangle$:

${\text{\rm div\,}}\circ\text{\rm grad\,}=\triangle\hskip 28.45274pt\text{\rm
curl\,}_{3}\circ\text{\rm Ham\,}=\triangle$ (32)

Indeed,

$\displaystyle{\text{\rm div\,}}\circ\text{\rm grad\,}:$ $\displaystyle f$
$\displaystyle\mapsto(\partial_{x}f,\partial_{y}f)$
$\displaystyle\mapsto(\partial^{2}_{x}+\partial^{2}_{y})f$
$\displaystyle\equiv\triangle f$ (33) $\displaystyle\text{\rm
curl\,}_{3}\circ\text{\rm Ham\,}:$ $\displaystyle f$
$\displaystyle\mapsto(-\partial_{y}f,\partial_{x}f)$
$\displaystyle\mapsto(\partial^{2}_{x}+\partial^{2}_{y})f$
$\displaystyle\equiv\triangle f$ (34)

###  3.1 Hamiltonian fields

Notation $\text{\rm Ham\,}f$ in (23) and (27) is abbreviation for _Hamiltonian
field_ generated by function $f$. It is key concept in theory of Hamiltonian
systems (for more details see, e.g., [2], [11] or Chapter 14 in [3]). How
could it occur here?

Well, it turns out that our _surface_ form $\omega\equiv dS$ mentioned in (17)
happens to be, at the same time, _symplectic_ form (it satisfies corresponding
definition; in general it is to be “closed and non-degenerate 2-form”). And
whenever symplectic form is available, a rule for construction of Hamiltonian
(vector) fields is available as well:

$f\mapsto\text{\rm Ham\,}f\hskip 28.45274pti_{\text{\rm Ham\,}f}\omega:=-df$
(35)

Now, when we compute how (35) works here, what we get is exactly (27).

This also sheds a new light onto the second result in (29). The fact, that
divergence of Hamiltonian field (generated by any function) vanishes is
equivalent to well-known _Liouville theorem_ from classical mechanics (see
14.3.7 in [3]). It says that, for Hamiltonian systems, _volume_ (here area) in
_phase_ space (here our 2D space) is conserved w.r.t. time evolution.

###  3.2 Auxiliary third dimension

One can easily check that:

1\. If, from a function $f(x,y)$ in 2D plane, one constructs the following
auxiliary vector field in 3D space

$\mathbf{u}=(0,0,-f(x,y))$ (36)

(try to think how it looks like), then its curl reads

$\text{\rm curl\,}\mathbf{u}=(-\partial_{y}f,\partial_{x}f,0)\equiv(\text{\rm
Ham\,}f,0)$ (37)

2\. If, from a vector field $\mathbf{A}$ in 2D plane, one constructs the
following auxiliary vector field in 3D space

$\boldsymbol{\mathcal{A}}=(\mathbf{A},0)\equiv(A_{x}(x,y),A_{y}(x,y),0)$ (38)

(try to think how it looks like), then its curl reads

$\text{\rm
curl\,}\boldsymbol{\mathcal{A}}=(0,0,\partial_{x}A_{y}-\partial_{y}A_{x})\equiv(0,0,\text{\rm
curl\,}_{3}\mathbf{A})$ (39)

What these two simple computations do reveal?

First, that our two “new” operations in 2D vector calculus,
$a_{1}\equiv\text{\rm curl\,}_{3}$ and $b_{0}\equiv\text{\rm Ham\,}$, may also
be discovered as hidden at special places of outputs of specially chosen
inputs of standard 3D vector calculus. The approach treated in this paper
finds their form and properties in “intrinsic” way, with no reference to
auxiliary additional dimensions.

And, second, we see motivation for notation of the operation $\text{\rm
curl\,}_{3}$. Well, mainly for the index 3 (in particular, that $\text{\rm
curl\,}_{3}\mathbf{A}=(\text{\rm curl\,}\boldsymbol{\mathcal{A}})_{3}$).
Motivation for the notation _curl_ itself (which should be related to kind of
_rotation_ of something) is discussed already in standard 3D vector calculus
(it stems for example from _vortex_ -like motion of fluid flow; see a few more
words on this in Section 4.2).

###  3.3 Integral identities and Green’s theorem

Integral theorems for 2D-vector calculus may be again derived from universal
Stokes theorem (11) for forms. Corresponding technical procedure just mimics
the one used in the 3D case at the end of Section 2.

Since there are altogether as many as _four_ basic squares (with upper arrow
$d$) in two diagrams in (23), four integral theorems are expected.

First, we assemble the corresponding four differential identities (analogues
of expressions (10)). From the individual squares we get

$\displaystyle df$ $\displaystyle=\text{\rm grad\,}f\cdot d\mathbf{r}$
$\displaystyle df$ $\displaystyle=-*(\text{\rm Ham\,}f\cdot d\mathbf{r})$ (40)
$\displaystyle d(\mathbf{A}\cdot d\mathbf{r})$ $\displaystyle=(\text{\rm
curl\,}_{3}\mathbf{A})dS$ $\displaystyle d*(\mathbf{A}\cdot d\mathbf{r})$
$\displaystyle=({\text{\rm div\,}}\mathbf{A})dS$ (41)

Their integration and application of Stokes theorem (11) leads to

$\displaystyle\int_{C}\text{\rm grad\,}f\cdot d\mathbf{r}$
$\displaystyle=f(B)-f(A)$ $\displaystyle\int_{C}*(\text{\rm Ham\,}f\cdot
d\mathbf{r})$ $\displaystyle=f(A)-f(B)$ (42) $\displaystyle\int_{S}(\text{\rm
curl\,}_{3}\mathbf{A})dS$ $\displaystyle=\oint_{\partial S}\mathbf{A}\cdot
d\mathbf{r}$ $\displaystyle\int_{S}({\text{\rm div\,}}\mathbf{A})dS$
$\displaystyle=\oint*(\mathbf{A}\cdot d\mathbf{r})$ (43)

Now, when we explicitly write down expressions under integral signs (with the
help of (18) and (25) - (28)), we discover that both identities in (42) say
the same thing and, similarly, the same is true for both identities in (43).
So we get _just two_ mutually different integral identities. When appropriate
notations are used, they read as follows:

gradient theorem $\displaystyle\int_{c}(\partial_{x}f)dx+(\partial_{y}f)dy$
$\displaystyle:=f(B)-f(A)$ (44) Green’s theorem
$\displaystyle\int_{S}(\partial_{x}g-\partial_{y}f)dxdy$
$\displaystyle:=\oint_{\partial S}fdx+gdy$ (45)

The first one is a 2D version of the gradient theorem. This is well known and
holds in any dimension. It relates an integral along a curve $c$ to an
“integral” over its boundary $\partial c$ (which reduces, here, to just two
points, $A$, its beginning and $B$, its end).

The second one is Green’s theorem. This is well-known, again, and is specific
for two dimensional space. It relates an integral over a 2D-domain $S$ to an
integral over its boundary (being a closed circuit $\partial S$).

###  3.4 Perpendicular vector field

As it was already mentioned in Section 3, in two dimensions we encounter a
specific situation that the Hodge star maps 1-forms on 1-forms again (see
(16)). The latter are, however, in bijection with vector fields (via $\sharp$
and $\flat$). So, effectively, the Hodge star induces a canonical isomorphism
of _vector fields_ on themselves

$\sharp*\flat:\mathfrak{X}\to\mathfrak{X}$ (46)

A computation gives

$\sharp*\flat:(A_{x},A_{y})\mapsto(-A_{y},A_{x})\hskip
28.45274pt\text{i.e.}\hskip 28.45274pt\mathbf{A}\mapsto\mathbf{A}_{\pi/2}$
(47)

We denote the result as $\mathbf{A}_{\pi/2}$, since it is evident from
components that the new vector is given, at each point, by _rotation_ of the
vector of the original vector field by $\pi/2$ in positive sense, i.e. in
counter-clock-wise direction. (This is compatible with the fact that, on
1-forms, the _square_ of the star is the _minus_ identity, see (18)).

The mapping (47) is equivalent to a handy formula

$*(\mathbf{A}\cdot d\mathbf{r})=:\mathbf{A}_{\pi/2}\cdot d\mathbf{r}$ (48)

Then, when combined with (40), we get the following useful relation of the
gradient field and the Hamiltonian one:

$\text{\rm Ham\,}f=(\text{\rm grad\,}f)_{\pi/2}$ (49)

This is also evident from their expressions in (25) and (27). If $f(x,y)$
describes height of a hill somewhere in a landscape, we know that the vector
field $\text{\rm grad\,}f$ shows, at any point, the direction of the steepest
ascent (and $-\text{\rm grad\,}f$ the direction of the steepest descent). Then
the vector field $\text{\rm Ham\,}f$ shows, at any point, the direction of
_no_ ascent, i.e. the direction _along contour lines_.

###  3.5 Poincaré lemma

Recall, first, what this useful lemma states.

The fact $dd=0$ says that if a form $\alpha$ is exact (i.e. if
$\alpha=d\beta$), then it is necessarily closed ($d\alpha=0$). It turns out
that the opposite implication does not, in general, hold. Poincaré lemma,
however, guarantees that on a domain which is _contractible to a point_ (for
example on a coordinate patch) the opposite implication still does hold.

In 3D vector calculus this leads frequently used and useful statements
(conversions of implications from (9))

$\text{\rm curl\,}\mathbf{a}=0\ \Rightarrow\ \mathbf{a}=\text{\rm
grad\,}f\hskip 28.45274pt{\text{\rm div\,}}\mathbf{a}=0\ \Rightarrow\
\mathbf{a}=\text{\rm curl\,}\mathbf{b}$ (50)

When expressed in terms of the diagram (8), it says that if some arrow in the
bottom line gives zero, the input is necessarily an output of the previous
arrow.

And what exactly the deduction gives in 2D vector calculus, i.e. for diagrams
(23)? This:

$\text{\rm curl\,}_{3}\mathbf{a}=0\ \Rightarrow\ \mathbf{a}=\text{\rm
grad\,}f\hskip 28.45274pt{\text{\rm div\,}}\mathbf{a}=0\ \Rightarrow\
\mathbf{a}=\text{\rm Ham\,}f$ (51)

We can see an application of these facts in Section 4.

##  4 2D vector calculus in 2D hydrodynamics

2D vector calculus may be useful, as an example, in description of 2D flows in
hydrodynamics. Such flows are described in terms of _velocity field_
$\mathbf{v}=(v_{x},v_{y})$. It results from continuity equation (which encodes
conservation of mass under the flow) that if the mass density $\rho$ is
constant, the velocity field is divergence-free:

${\text{\rm div\,}}\mathbf{v}=0\hskip 56.9055pt\text{\emph{incompressible}
fluid}$ (52)

###  4.1 Incompressible fluid and stream function

Compare the second implications in (50) and (51). We see that if a vector
field in 2D happens to be divergence-free, it is not the curl of an arbitrary
vector field, as we are accustomed to in 3D, but rather it is _Hamiltonian_
field generated by an arbitrary function $f(x,y)$.

${\text{\rm div\,}}\mathbf{v}=0\ \Rightarrow\ \mathbf{v}=\text{\rm
Ham\,}f\hskip 28.45274pt\text{i.e.}\hskip
28.45274pt(v_{x},v_{y})=(-\partial_{y}f,\partial_{x}f)$ (53)

One can say that the velocity field is _potential_ in the sense that
components of the field may be computed in terms of derivatives of some
quantity, namely of a function (potential) $f$, here. The field is, however,
not computed as the usual gradient of the potential (as it is the case, for
example, for electric field in electrostatics), but rather other combinations
of partial derivatives are needed. In particular what we found is that one is
to construct Hamiltonian field from $f$.

Now, what is the physical meaning of the function $f$?

First, one easily checks that directional derivative of the function $f$ along
_streamlines_ of the flow vanishes:

$\dot{f}\equiv\frac{d}{dt}f(\mathbf{r}(t))=\dot{x}(\partial_{x}f)+\dot{y}(\partial_{y}f)=\dot{x}v_{y}-\dot{y}v_{x}=0$
(54)

since $\mathbf{v}=(\dot{x},\dot{y})$ on streamline
$\mathbf{r}(t)\equiv(x(t),y(t))$.

So the function $f$ is _constant_ on streamlines. If we were able to find $f$,
we could determine the _shape of streamlines_ , i.e. the pattern of our 2D
flow 222The _direction_ of the flow as well as the _magnitude of the velocity_
of the flow cannot be detected in this way. The picture shows, at the same
time, _contour lines_ of the hill with height given by $f(x,y)$, mentioned at
the end of Section 3.4. If the stream function were used in the role of the
height of a fictitious hill, the fluid would flow, on the corresponding
tourist map, along contour lines. , from the equation

$f(x,y)=\ \text{const.}$ (55)

That’s why $f$ is known as the _stream function_.

Second, we should realize the _value_ itself of the function $f$ at a point
$A$ cannot carry any direct physical meaning since it is evident that there is
a freedom in additive constant for $f$. What can carry a real physical
meaning, however, is the _difference_ of values at two points $A$ and $B$,
i.e. $f(B)-f(A)$. In electrostatics, where the (electric) field is (minus) the
gradient of the potential, we get _voltage_ between the two points in this
way. What we get here, where the velocity field turns out to be Hamiltonian
field corresponding to this “potential”?

It turns out that it gives net _area flux_ of the fluid per unit time through
a path connecting the two points. So if we draw two streamlines which pass
through the two points, it represents the net area flux under a bridge over
the “river”, which runs between the two streamlines.

It may be also seen on a picture (see Fig.1) and then computed “on fingers”.

Figure 1: Streamline $a$ passes through point $A$, streamline $b$ passes
through point $B$. Streamlines in between them form a “river”. A bridge over
the troubled water connects the point $A$ with the point $B$. The area of the
rhomboid is the area flux (per unit time) of the water underneath the small
piece $(dx,dy)$ of the bridge.

Indeed, the second identity in (40) gives

$df=-*(\mathbf{v}\cdot d\mathbf{r})=-*(v_{x}dx+v_{y}dy)=v_{y}dx-v_{x}dy$ (56)

where we used (18). So if we step forth (along the path connecting $A$ and
$B$) a small vector $(dx,dy)$, the value of the function $f$ changes by
$df=v_{y}dx-v_{x}dy$. Now the expression on the r.h.s. is nothing but the
_area of the rhomboid_ spanned by edges $(dx,dy)$ and $(v_{x},v_{y})$. And
this is exactly the area flux of a fluid with velocity $(v_{x},v_{y})$ through
a small piece $(dx,dy)$ of the connecting line, i.e. the _area_ , which flows
through the piece per unit time. (In 3D situation it would be _volume flux_ ,
i.e. the _volume_ of the fluid which flows through the small surface
$d\mathbf{S}$ and the corresponding expression were $\mathbf{v}\cdot
d\mathbf{S}$.) And the _net change_ of the value of $f$ going from $A$ to $B$
is then corresponding _integral_ along the connecting path which gives the
_net area flux_ for the entire path.

###  4.2 Vorticity-free flow and its potential

Now let us turn our attention to the first implication in (51). We see that if
a vector field $\mathbf{a}$ in 2D has vanishing $\text{\rm
curl\,}_{3}\mathbf{a}$, it is necessarily a _gradient_ of some function
$g(x,y)$. So for the velocity field $\mathbf{v}$ it holds

$\text{\rm curl\,}_{3}\mathbf{v}=0\ \Rightarrow\ \mathbf{v}=\text{\rm
grad\,}g\hskip 28.45274pt\text{i.e.}\hskip
28.45274pt(v_{x},v_{y})=(\partial_{x}g,\partial_{y}g)$ (57)

But what is the _physical_ meaning of the fact $\text{\rm
curl\,}_{3}\mathbf{v}=0$?

In 3D case, _vector_ field $\text{\rm curl\,}\mathbf{v}$ is known as the
_vorticity_ field. It turns out that, in a given point, it represents twice
the vector of the angular velocity, by which the “droplet” centered in the
point rotates.

The _scalar_ function $\text{\rm curl\,}_{3}\mathbf{v}$ is the 2D version of
the vorticity of the flow. (It is called vorticity as well.) If we placed a
small body made of corc somewhere on the surface of the 2D flow, it would
rotate with angular velocity $2\ \text{\rm curl\,}_{3}\mathbf{v}$.

So the condition $\text{\rm curl\,}_{3}\mathbf{v}=0$ describes a _vorticity-
free_ flow. As we see from (57), such flow is also “potential” one, moreover
in the standard sense, now (i.e. that the vector field is computed as the
gradient of the potential).

###  4.3 Where from complex analysis arises

Consider a 2D flow which happens to be “incompressible” and _at the same time_
vorticity-free. Then, according to (53) and (57) it holds

$\mathbf{v}=\text{\rm Ham\,}f=\text{\rm grad\,}g\hskip
28.45274pt\text{i.e.}\hskip
28.45274pt(v_{x},v_{y})=(-\partial_{y}f,\partial_{x}f)=(\partial_{x}g,\partial_{y}g)$
(58)

The last equality sign in (58) expresses, however, exactly the _Cauchy-Riemann
equations_ ; they say that (complex) function of complex variable

$h(z)\hskip 28.45274pth=f+ig\hskip 28.45274ptz=x+iy$ (59)

is analytic (holomorphic). We can easily check that velocity field is hidden
in its derivative

$h^{\prime}(z)=v_{y}+iv_{x}$ (60)

Indeed,

$2\partial_{z}h(z)=(\partial_{x}-i\partial_{y})(f+ig)=2(v_{y}+iv_{x})$ (61)

One can learn much more on this in standard textbooks on hydrodynamics, e.g.
see [6].

##  5 Conclusion

In this paper the 2D analogue of the standard 3D vector calculus is discussed.
The approach is based on using of differential forms. The standard logic,
which helps so much for understanding 3D vector calculus, is repeated. The
approach is completely “intrinsic”, it does not use any embedding of the 2D
space into an auxiliary ambient 3D space. We show what differential operators
occur here (analogues of grad, curl and div from 3D), how they are related and
in which integral identities they may be found. All results are also presented
in standard language (i.e. with no forms whatsoever).

## References

  * [1] P. Bamberg, S. Sternberg: A course in mathematics for students of physics 2,
CUP, Cambridge, 1990

  * [2] M. Crampin, F.A.E. Pirani: Applicable differential geometry,
CUP, Cambridge, 1986

  * [3] M. Fecko: Differential geometry and Lie groups for physicists,
CUP, Cambridge, 2006, 2011

  * [4] D. Fleisch: A Student’s Guide to Maxwell’s Equations, CUP, Cambridge, 2008
  * [5] Khan Academy: Formal definition of curl in two dimensions,
https://www.khanacademy.org/math/multivariable-calculus/greens-theorem-and-
stokes-theorem/formal-definitions-of-divergence-and-curl/a/defining-curl

  * [6] L.D.Landau, E.M.Lifshitz: Fluid Mechanics, Pergamon Press
(Second Edition), 1987

  * [7] J. E. Marsden: Vector Calculus, W. H. Freeman & Company, 1976
  * [8] P. Olver: Vector Calculus in Two Dimensions,
https://www-users.math.umn.edu/~olver/ln_/vc2.pdf

  * [9] H. M. Schey: Div, Grad, Curl, and All That: An Informal Text on Vector Calculus, W. W. Norton & Company, 2004.
  * [10] B. Spain: Vector Analysis, D. Van Nostrand Company, 1975
  * [11] B. Schutz: Geometrical methods of mathematical physics,
CUP, Cambridge, 1980

The text is the author’s translation into English of a paper _M.Fecko_ :
_Vektorová analýza v dvoch rozmeroch_ ,
_Kvaternion, 1-2, 19-30, (2021)_ originally published in Slovak in journal
_Kvaternion_
(Institute of Mathematics, Faculty of Mechanical Engineering, Brno University
of Technology, Czech Republic),
see
http://kvaternion.fme.vutbr.cz/index.html
http://kvaternion.fme.vutbr.cz/2021/kv21_1-2_fecko_web.pdf