When 2-1 RBM is learning, clearly, parameter $(a,b)$ is adapting. But, only
when $(a,b)$ cross region, processing changes. Before crossing, change of
parameters is just for preparation for crossing (perhaps many parameter
changes are just wasted). Learning is moving from one region to another. Or,
equivalently, learning is from one X-form to another. Such view is crucial.
Now, we are clear, on surface, learning on 2-1 RBM is a dynamics on parameter
space $\mathbb{R}^{2}$, but real learning dynamics is on 6 regions (or
X-forms). Such indirectness causes a lot of problem.

3-1 RBM
Just increase input dimension 1, we have 3-1 RBM. To discuss it, we can gain
some insights for general RBM. For 3-1 RBM, still we can write: for any input
$(i_{1},i_{3},i_{3})\in\mathbb{B}^{3}$, output $o\in\mathbb{B}$ is:

$o=p(i_{1},i_{2},i_{3})=\text{Sign}(ai_{1}+bi_{2}+ci_{3}),\text{where}\
(a,b,c)\in\mathbb{R}^{3},\
\text{Sign}(x)=\left\\{\begin{array}[]{ll}1&\mbox{if }x\geq 0\\\ 0&\mbox{if
}x<0\end{array}\right.$

However, while we can easily write down all possible processing of 2-1 RBM, it
would be hard to do so for 3-1 RBM. For 3-1 IPU, we know that the number of
all possible processing is $2^{2^{3}}=2^{8}=256$. Since only considering such
processing $p$: $p(0,0,0)=0$, the number becomes $256/2=128$. We expect 3-1
RBM has less processing. But, how many possible processing of 3-1 RBM could
have?

Following the guidance that 2-1 RBM gives to us, i.e. to consider the
hyperplane generated by nonlinearity that cuts parameter spaces, we examine
parameter space $(a,b,c)\in\mathbb{R}^{3}$, and following planes:
$a=0,b=0,c=0,a+b=0,a+c=0,b+c=0,a+b+c=0$. These planes are naturally obtained.
For example, if we consider the input $(1,0,0)$, it is easy to see plane $a=0$
is where cut the value of output: 1 or 0. So, the above planes are associated
with following inputs:
$(1,0,0),(0,1,0),(0,0,1),(1,1,0),(1,0,1),(0,1,1),(1,1,1)$

We can clearly see that in one region that is cut out by above 7 planes, the
output values are same. Therefore, one region actually is representing one
processing: in the region, processing is same. So, question of how many
possible processing becomes how many possible regions cut out by the 7 planes.
We do counting for the regions below.

First, $a=0$ cuts parameter space into 2 pieces: $R_{1}^{1}$, $R_{2}^{1}$.
Second, $b=0$ perpendicular to $a=0$, so, it cuts each region $R_{1}^{1}$,
$R_{2}^{1}$ into 2 pieces, we then have 4 regions: $R_{1}^{2}$,
$R_{2}^{2}$.$R_{3}^{2}$, $R_{4}^{2}$. Then, $c=0$ perpendicular to $a=0$ and
$b=0$, so, we have 8 regions: $R_{j}^{3},j=1,\ldots,8$. Then, consider
$a+b=0$. This plane no longer could be perpendicular to all $a=0,b=0,c=0$. We
will not have $2*8=16$ regions. We only have $1.5*8=12$ regions. Following the
same argument, we have: For $a+c=0$, $1.5*12=18$ regions. For $b+c=0$,
$1.5*18=27$ regions. For $a+b+c=0$, $1.5*27<41$ regions.

So, for 3-1 RBM, there are at most 41 possible processing, comparing to 128
possible processing of full 3-1 IPU. However, there are possibility that the
number of processing is even less than 41, since among those regions, it is
possible that 2 different regions give same processing. We do not consider
these details here.

Since regions can be represented by X-form, each processing 3-1 RBM can be
represented by at least one X-form.
$b_{1}=(1,0,0),b_{2}=(0,1,1),b_{3}=(0,0,1),\ldots,b_{7}=(1,1,1)$ are X-form
for all base patterns. Examples, X-form $b_{1}+b_{2}$ is in 3-1 RBM. But,
$b_{1}\cdot b_{2}$ is not in 3-1 RBM. There are a lot of such X-form that is
not in 3-1 RBM.

Learning dynamics on 3-1 RBM is also in such way: on surface, it is dynamics
on $\mathbb{R}^{3}$, but real learning dynamics is on 41 regions (or X-forms).

$N$-1 RBM
The argument for 3-1 RBM can be extended to $N$-1 RBM (See details in
[paper2]). We consider hyperplanes and regions cut off by these hyperplanes.
The number of these regions is less than: $2^{N}1.5^{2^{N}-N-1}$. Compare to
the number of all processing of $N$-1 IPU, which is $2^{2^{N}-1}$, easy to
see, $N$-1 RBM has much less processing. This means that $N$-1 RBM could not
express many processing.

For $N$-1 RBM, still we can write: for any input
$(i_{1},\ldots,i_{N})\in\mathbb{B}^{N}$, output $o\in\mathbb{B}$ is:

$o=p(i_{1},\ldots,i_{3})=\text{Sign}(a_{1}i_{1}+a_{2}i_{2}+\ldots+a_{N}i_{3}),\text{where}\
(a_{1},\ldots,a_{N})\in\mathbb{R}^{N},\
\text{Sign}(x)=\left\\{\begin{array}[]{ll}1&\mbox{if }x\geq 0\\\ 0&\mbox{if
}x<0\end{array}\right.$

$a_{1}=0,\ldots,a_{1}+a_{2}=0,\ldots,\ a_{1}+a_{2}+a_{3}=0\ldots,\ \ldots,\
a_{1}+a_{2}+a_{3}+\ldots=0,\ldots$ (2)

There are ${N\choose 1}$ hyperplanes such as $a_{1}=0$; ${N\choose 2}$
hyperplanes such as $a_{1}+a_{2}=0$; …. We also have this: First $N$
hyperplanes will cut parameter space into $2^{N}$ regions. Then, later each
hyperplanes will cut more regions by the rate of multiplying factor $1.5$.
Thus, we can see the number of regions are:

$2^{N}*1.5^{K_{2}}*1.5^{K_{3}}*\ldots*1.5^{K_{N}}$

where ${K_{2}}={N\choose 2}$ is the number of hyperplanes such as $a+b=0$,
etc.

And, we have the equation:

$2^{N}={N\choose 0}+{N\choose 1}+{N\choose 2}+\ldots+{N\choose N}$ (3)

So,

$K_{2}+K_{3}+\ldots+K_{N}={N\choose 2}+{N\choose 3}+\ldots+{N\choose
N}=2^{N}-{N\choose 1}-{N\choose 0}=2^{N}-N-1$ (4)

Thus, the number of regions are

$2^{N}*1.5^{2^{N}-N-1}=2^{N}*({\frac{3}{2}})^{2^{N}-N-1}$

This is a very big number. Yet, compare to the total possible processing of
full IPU, it is quite small. See their quotient:

$\frac{2^{2^{N}}}{2^{N}*({\frac{3}{2}})^{2^{N}-N-1}}=2*(4/3)^{2^{N}-N-1}$

It tells that full IPU has $f=2*(4/3)^{2^{N}-N-1}$ folds more processing
comparing to RBM. This is huge difference. Say, just for $N=10$, $f$ is more
than 120 digits, i.e. the number of processing of full IPU would has more 120
digits at the end.

Also, each region can be expressed by at least one X-form. For examples,
$b_{1}+b_{N}$, $b_{1}+b_{3}+b_{5}$, etc. Learning dynamics on $N$-1 RBM is in
such way: on surface, it is dynamics on $\mathbb{R}^{N}$, but real learning
dynamics is on those $2^{N}1.5^{2^{N}-N-1}$ regions (or X-forms).

$N$-$M$ RBM
Suppose $\mathcal{R}_{i},i=1,\ldots,M$ are $M$ $N$-1 RBMs, we can form a
$N$-$M$ RBM, denote as $\mathcal{R}=(\mathcal{R}_{1},\ldots.\mathcal{R}_{M})$,
whose processing are $p=(p_{1},p_{2},\ldots,p_{M})$, where
$p_{i},i=1,\ldots,M$ are processing of $\mathcal{R}_{i}$. So, $\mathcal{R}$ is
Cartesian product of $\mathcal{R}_{i},i=1,\ldots,M$.

Since all $\mathcal{R}_{i}$ are cut into regions, and in each region,
processing is same, we can see $\mathcal{R}$ is also cut into regions, and
each region is a Cartesian product of regions of $\mathcal{R}_{i}$:
$R=R_{1}\times R_{2}\times\ldots\times R_{M}$, where $R_{i}$ is one region
from i-th RBM $\mathcal{R}_{i}$. Thus, the number of all possible regions of
$\mathcal{R}$ is $(2^{N}1.5^{2^{N}-N-1})^{M}=2^{NM}1.5^{M(2^{N}-N-1)}$. This
is a much smaller number than $2^{M2^{N}}$, which is the number of total
possible processing for $N$-$M$ IPU.

X-form for each region of $\mathcal{R}$, are actually Cartesian product of
X-form for those regions of $\mathcal{R}_{i}$. Suppose $R=R_{1}\times
R_{2}\times\ldots\times R_{M}$, and $f_{i}$ are X-forms for region $R_{i}$ in
$\mathcal{R}_{i}$, $i=1,\ldots,M$, then X-form for $R$ is
$f=(f_{1},\ldots,f_{M})$. For example, $(b_{1},b_{1}+b_{3},\ldots,b_{2}\cdot
b_{4})$ is one X-form of $\mathcal{R}$.

Learning dynamics on $N$-$M$ RBM is in such way: on surface, it is dynamics on
parameter space $\mathbb{R}^{N}M$, but real learning dynamics is on those
$2^{NM}1.5^{M(2^{N}-N-1)}$ regions (or X-forms).

Stacking RBMs
Consider a $N$-$M$ RBM $\mathcal{R}_{1}$, and a $M$-$L$ RBM $\mathcal{R}_{2}$,
stacking them together, we get one $N$-$L$ IPU $\mathcal{R}$: A processing $p$
of $\mathcal{R}$ are composition of processing $p_{1},p_{2}$ of
$\mathcal{R}_{1},\mathcal{R}_{2}$:
$p(i_{1},i_{2},\ldots,i_{N})=p_{2}(p_{1}(i_{1},i_{2},\ldots,i_{N}))$. And we
denote as: $\mathcal{R}=\mathcal{R}_{1}\otimes\mathcal{R}$.

The parameter space of $\mathcal{R}$ clearly is
$\mathbb{R}^{NM}\times\mathbb{R}^{ML}$. We know $\mathbb{R}^{NM}$ is cut into
some regions, in each region processing is same. So does $\mathbb{R}^{ML}$.
Thus, $\mathbb{R}^{NM+ML}$ is cut into some regions, in each region processing
is same, and these regions are Cartesian product of regions in
$\mathbb{R}^{NM}$ and $\mathbb{R}^{ML}$. So, we know number of total possible
processing $\mathcal{R}$ equals total possible processing of $\mathcal{R}_{1}$
times $\mathcal{R}_{2}$, i.e. $2^{NM}1.5^{M(2^{N}-N-1)}\times
2^{ML}1.5^{L(2^{M}-M-1)}=2^{NM+ML}1.5^{M(2^{N}-N-1)+L(2^{M}-M-1)}$.

We can easily see if $M$ is large enough, the above number will become greater
than $2^{L2^{N}}$, which is total possible processing of $\mathcal{R}$. We can
see, at least potentially, $\mathcal{R}$ has enough ability to become a
$N$-$L$ full IPU. But, we will not consider here. In fact, it is very closely
related to the so called Universal Approximation Theorem. Indeed, stacking RBM
together is powerful.

X-form can be expressed as composition as well. For example, consider 3 2-1
RBM $\mathcal{R}_{1}$, $\mathcal{R}_{2}$, and $\mathcal{R}_{3}$. Using
$\mathcal{R}_{1}$ and $\mathcal{R}_{2}$ to form a 2-2 RBM, and using
$\mathcal{R}_{3}$ to stack on it, we get a 2-1 IPU $\mathcal{R}$:
$\mathcal{R}=\mathcal{R}_{3}\otimes(\mathcal{R}_{1},\mathcal{R}_{2})$. If for
this case, $\mathcal{R}_{1}$ has X-form $b_{1}$, and $\mathcal{R}_{2}$ has
X-form $b_{2}$, and $\mathcal{R}_{3}$ has X-form $b_{1}+b_{2}+b_{3}$, them,
$\mathcal{R}$ has X-form $(b_{1}+b_{2}+b_{3})(b_{1},b_{2})$. Easy to see this
X-form is processing $P_{5}$ (XOR gate), which is not expressible by one 2-1
RBM. So, putting 3 2-1 RBMs together, more X-form can be expressed.

Deep Learning and Learning Dynamics
Following idea of ”putting RBM together, then more expressible”, by stacking
more RBMs, deep learning is formed. Suppose $\mathcal{R}_{j}$, are
$N_{j}$-$N_{j+1}$ RBM, $j=1,\ldots,J$, where $N_{1},\ldots,N_{J},N_{J+1}$ are
sequence of integers. So, we can stack these RBM together to form one
$N_{1}$-$N_{J+1}$ IPU, which has processing:
$p(i_{1},i_{2},\ldots,i_{N_{1}})=p_{J}(\ldots
p_{2}(p_{1}(i_{1},i_{2},\ldots,i_{N_{1}}))$ where each $p_{j}$ is processing
of $\mathcal{R}_{j}$. We denote this IPU as
$\mathcal{R}=\mathcal{R}_{1}\otimes\ldots\otimes\mathcal{R}_{J}$.

Deep learning is conduct on IPU $\mathcal{R}$. How is learning dynamics? As we
have seen from simplest RBM to deep learning, we know that the parameter space
is cut into regions, and each region is for one processing, and learning is
moving from one region to another. In another words, on surface, learning
dynamics is going on the huge parameter space
$\mathcal{R}^{N_{1}N_{2}+\ldots+N_{J}N_{J+1}}$, but is actually on those
regions. The number of regions are huge:
$2^{N_{1}N_{2}}1.5^{N_{2}(2^{N_{1}}-N_{1}-1)}\times\ldots$.

Thus, as learning, huge number of parameters are adapting. But only when
parameters cross region, processing changes. Before crossing, processing
remains same, parameter changes at most can be thought as the preparation for
crossing (perhaps many parameter changes are just wasted). We can say,
learning dynamics is to move from one region to another. We also know each
region is represented by one X-form, thus, learning dynamics is to move from
one X-form to another X-form.

Deep learning structure is formed by human intervene. Once it is formed, if no
further human intervene, it is mechanical learning. But, once it is formed,
the structure, such as how many RBMs, how to stack, how to do Cartesian
product, etc, are fixed. Thus, regions are fixed. Thus, available X-forms for
learning are fixed. Then learning is conducted on the available X-forms. In
other words, learning dynamics is to find a good X-form among those available
X-forms. There are quite a variety methods of learning, i.e. how to find the
good X-form. But, most essential methods are 2: contrastive divergence (CD),
and stochastic gradient descendant (SGD).

We can see one example. $\mathcal{R}_{1}$, $\mathcal{R}_{2}$,
$\mathcal{R}_{3}$ are 3 2-1 RBMs. We put them like this:
$\mathcal{R}=\mathcal{R}_{3}\otimes(\mathcal{R}_{1},\mathcal{R}_{2})$. We have
3 parameter space $(a,b),(c,d),(e,f)$. We have 6 regions for each parameter
space. Put them together, we have 6x6x6 = 216 regions. $\mathcal{R}$ is one
2-1 IPU. So, $\mathcal{R}$ at most has 8 processing. Thus, among those 216
regions some different regions will have same processing. But, each region
will have one X-form. That is to say, for one processing, there could have
several X-form associate with it. For example, consider this region:
$R^{3}_{1}\times(R^{1}_{3},R^{2}_{5})$. This gives processing $P_{5}$ (XOR
gate). Normally, for this processing, we can use X-form $b_{1}+b_{2}$ for it.
But, for the region, naturally, the X-form is:
$(b_{1}+b_{2}+b_{3})\otimes(b_{1},b_{2})$. That is to say, this X-form will
generate the same processing as $b_{1}+b_{2}$. Another region:
$R^{3}_{2}\times(R^{1}_{2},R^{2}_{6})$ will give the same processing. And, the
X-form is: $(b_{1}+b_{3})\otimes(b_{1}+b_{3},b_{2}+b_{3})$.

So, for deep learning, we can say that all X-forms form the internal
representation space. But, for deep learning, this internal representation
space could not be seen directly, it is embedded into huge parameter space
$\mathbb{R}^{N_{1}N_{2}+\ldots+N_{J}N_{J+1}}$, each X-form equivalent to one
region in this parameter space, which is a Cartesian product of regions of
$\mathcal{R}_{j},j=1,\ldots,J$.

So, we can see deep learning is doing: 1) to form a set of available X-forms
and embed those X-forms into parameter space, this is done at the time to set
up the learning structure and this is done by human; 2) to use some learning
methods (e.g. CD+SGD) to form dynamics on parameter space, and use a big
amount of data to drive the dynamics, 3) hope to reach a good X-form among the
set. This is what we described in section 5, Strategy 1. In fact, the loss
function used in SGD is exactly the function in the equation (5) in section 5.
This is what happens inside a deep learning.

Now, we have a clear picture on what deep learning is doing and why it is
working well: It conducts learning by using Strategy 1 – Embed X-forms into
Parameter Space. Also, the data sufficiency that we defined actually lay down
a framework for understanding what kind of data and what amount of data are
sufficient to drive a successful learning. This is very important. We will no
longer be blind about big data. We can calculate if data is sufficient for one
task. This a huge contribution from our descriptions on mechanical learning to
deep learning.

Disadvantages of Deep Learning
Finally, we want to point out: deep learning might not be best mechanical
learning. We list some its disadvantages below:

  1. 1.

It is acting on huge parameter space, but, actual learning dynamics is on a
fixed set of regions (which is equivalent to a set of X-forms). This
indirectness makes every aspects of learning harder, especially, it is near
impossible to know what is exactly happening in learning dynamics.

  2. 2.

As theorem 7 in section 5 shows, successful learning needs data sufficient to
support and to bound. This requirement is very costly.

  3. 3.

The structure of learning is setup by human. Once setup, structure (how many
layers, how big a layer is, how layers fitting together, how to do
convolution, etc) is not be able to change. This means that learning is
restricted on a fixed group of regions, equivalent a fixed group of X-forms.
If best X-form is not in this set, deep learning has no way to reach best
X-form, no matter how big data are and how hard to try. Consequently, it is
not universal learning machine.

  4. 4.

It is very costly to embed X-forms into a huge parameter space. Perhaps, among
all computing spend on learning, only a very small fraction is used on
critical part, i.e. on moving X-form, and most are just wasted.

  5. 5.

Since there is no clear and reachable internal representation (due to the
embedding), it will be very hard to do advanced learning, such as to unite all
5 learning methods together (see [2]).

  6. 6.

Since there is no clear internal representation space, it is hard to define
initial X-form, which is very essential to efficiency improving and several
stages of learning.

Knowing the disadvantages is good, we can find some better way to turn
disadvantages to advantages.


theorem white

# A formula for the linking number in terms of isometry invariants of straight
line segments

Matt Bright  Olga Anosova  Vitaliy Kurlin
Computer Science and Materials Innovation Factory  University of Liverpool
<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>
###### Abstract

In 1833 Gauss defined the _linking number_ of two disjoint curves in 3-space.
For open curves this double integral over the parameterised curves is real-
valued and invariant modulo rigid motions or isometries that preserve
distances between points, and has been recently used in the elucidation of
molecular structures. In 1976 Banchoff geometrically interpreted the linking
number between two line segments. An explicit analytic formula based on this
interpretation was given in 2000 without proof in terms of six isometry
invariants: the distance and angle between the segments and four coordinates
specifying their relative positions. We give a detailed proof of this formula
and describe its asymptotic behaviour that wasn’t previously studied.

##  1 The Gauss integral for the linking number of curves

This extended version of the conference paper bright2020proof  includes all
previously skipped proofs. For any vectors
$\vec{u},\vec{v},\vec{w}\in\mathbb{R}^{3}$, the _triple_ product is
$(\vec{u},\vec{v},\vec{w})=(\vec{u}\times\vec{v})\cdot\vec{w}$.

######  Definition 1 (Gauss integral for the linking number)

For piecewise-smooth curves $\gamma_{1},\gamma_{2}:[0,1]\to\mathbb{R}^{3}$,
the _linking number_ can be defined as the Gauss integral gauss1833integral

$\mathrm{lk}(\gamma_{1},\gamma_{2})=\dfrac{1}{4\pi}\int\limits_{0}^{1}\int\limits_{0}^{1}\dfrac{(\dot{\gamma}_{1}(t),\dot{\gamma}_{2}(s),\gamma_{1}(t)-\gamma_{2}(s))}{|\gamma_{1}(t)-\gamma_{2}(s)|^{3}}dtds,$
$None$

where $\dot{\gamma}_{1}(t),\dot{\gamma}_{2}(s)$ are the vector derivatives of
the 1-variable functions $\gamma_{1}(t),\gamma_{2}(s)$.

The formula in Definition 1 gives an integer number for any closed disjoint
curves $\gamma_{1},\gamma_{2}$ due to its interpretation as the _degree_ of
the _Gauss map_
$\Gamma(t,s)=\dfrac{\gamma_{1}(t)-\gamma_{2}(s)}{|\gamma_{1}(t)-\gamma_{2}(s)|}:S^{1}\times
S^{1}\to S^{2}$, i.e. $\deg\Gamma=\dfrac{\mathrm{area}(\Gamma(S^{1}\times
S^{1}))}{\mathrm{area}(S^{2})}$, where the area of the unit sphere is
$\mathrm{area}(S^{2})=4\pi$. This integer degree is the _linking number_ of
the 2-component link $\gamma_{1}\sqcup\gamma_{2}\subset\mathbb{R}^{3}$ formed
by the two closed curves. Invariance modulo continuous deformation of
$\mathbb{R}^{3}$ follows easily for closed curves - indeed, the function under
the Gauss integral in (1), and hence the integral itself, varies continuously
under perturbations of the curves $\gamma_{1},\gamma_{2}$. This should keep
any integer value constant.

For open curves $\gamma_{1},\gamma_{2}$, the Gauss integral gives a real but
not necessarily integral value, which remains invariant under rigid motions or
orientation-preserving isometries (see Theorem 2). In $\mathbb{R}^{3}$ with
the Euclidean metric isometries consist of rotations, translations and
reflections. Isometry invariance of the real-valued linking number for open
curves has found applications in the study of molecules
ahmad2020characterization .

Any smooth curve can be well-approximated by a polygonal line, so the
computation of the linking number reduces to a sum over pairs of straight line
segments $L_{1},L_{2}$. In 1976 Banchoff banchoff1976self  has expressed the
linking number $\mathrm{lk}(L_{1},L_{2})$ in terms of the endpoints of each
segment, see details of this and other past work in Section 3.

In 2000 Klenin and Langowski klenin2000computation  proposed a formula for the
linking number $\mathrm{lk}(L_{1},L_{2})$ of two straight line segments in
terms of six isometry invariants of $L_{1},L_{2}$, referring to a previous
paper Vologodskii1974 , which used the formula without any detailed proof. The
paper klenin2000computation  also skipped all details of the invariant-based
formula’s derivation.

The usefulness of the invariant-based formula can be seen by considering the
analogy with the simpler concept of the scalar (dot) product of vectors. The
algebraic or _coordinate-based_ formula expresses the scalar product of two
vectors $\vec{u}=(x_{1},y_{1},z_{1})$ and $\vec{v}=(x_{2},y_{2},z_{2})$ as
$\vec{u}\cdot\vec{v}=x_{1}x_{2}+y_{1}y_{2}+z_{1}z_{2}$, which in turn depend
on the co-ordinates of their endpoints. However, the scalar product for high-
dimensional vectors $\vec{u},\vec{v}\in\mathbb{R}^{n}$ can also expressed in
terms of only 3 parameters
$\vec{u}\cdot\vec{v}=|\vec{u}|\cdot|\vec{v}|\cos\angle(\vec{u},\vec{v})$. The
two lengths $|\vec{u}|,|\vec{v}|$ and the angle $\angle(\vec{u},\vec{v})$ are
isometry invariants of the vectors $\vec{u},\vec{v}$. This second geometric or
_invariant-based_ formula makes it clear that $\vec{u}\cdot\vec{v}$ is an
isometry invariant, while it is harder to show that
$\vec{u}\cdot\vec{v}=x_{1}x_{2}+y_{1}y_{2}+z_{1}z_{2}$ is invariant under
rotations. It also provides other geometric insights that are hard to extract
from the coordinate-based formula - for example, $\vec{u}\cdot\vec{v}$
oscillates as a cosine wave when the lengths $|\vec{u}|,|\vec{v}|$ are fixed,
but the angle $\angle(\vec{u},\vec{v})$ is varying.

In this paper, we provide a detailed proof of the invariant-based formula for
the linking number in Theorem 8 and new corollaries in Section 6 formally
investigating the asymptotic behaviour of the linking number, which wasn’t
previously studied.

Our own interest in the asymptotic behaviour is motivated by the _periodic
linking number_ by Panagiotou panagiotou2015linking  as an invariant of
crystalline networks cui2019mining  that are infinitely periodic in three
directions, by calculating the infinite sum of the linking number between one
line segment and all translated copies of another such segment. In
panagiotou2015linking  there is a complex proof that this sum is convergent
for a cubical lattice. The convergence of the periodic linking numbers remains
open for arbitrary lattices.

##  2 Outline of the invariant-based formula and consequences

Folklore Theorem 2 lists key properties of
$\mathrm{lk}(\gamma_{1},\gamma_{2})$, which will be used later.

######  Theorem 2 (properties of the linking number)

The linking number defined by the Gauss integral in Definition 1 for smooth
curves $\gamma_{1},\gamma_{2}$ has the following properties:

(2a) the linking number is symmetric:
$\mathrm{lk}(\gamma_{1},\gamma_{2})=\mathrm{lk}(\gamma_{2},\gamma_{1})$;

(2b) $\mathrm{lk}(\gamma_{1},\gamma_{2})=0$ for any curves
$\gamma_{1},\gamma_{2}$ that belong to the same plane;

(2c) $\mathrm{lk}(\gamma_{1},\gamma_{2})$ is independent of orientation-
preserving parameterisations of the open curves $\gamma_{1},\gamma_{2}$ with
fixed endpoints;

(2d)
$\mathrm{lk}(-\gamma_{1},\gamma_{2})=-\mathrm{lk}(\gamma_{1},\gamma_{2})$,
where $-\gamma_{1}$ has the reversed orientation of $\gamma_{1}$;

(2e) the linking number $\mathrm{lk}(\gamma_{1},\gamma_{2})$ is invariant
under any scaling $\vec{v}\to\lambda\vec{v}$ for $\lambda>0$;

(2f) $\mathrm{lk}(\gamma_{1},\gamma_{2})$ is multiplied by $\det M$ under any
orthogonal map $\vec{v}\mapsto M\vec{v}$.

###### Proof

(2a) We note that the Euclidean distance is symmetric, and that since the
triple product is anti-symmetric and
$\gamma_{2}(s)-\gamma_{1}(t)=-(\gamma_{1}(t)-\gamma_{2}(s)$, the symmetry
follows from

$\displaystyle(\dot{\gamma}_{1}(s),\dot{\gamma}_{2}(t),\gamma_{2}(s)-\gamma_{2}(t))$
$\displaystyle=-(\dot{\gamma}_{1}(t),\dot{\gamma}_{2}(s),\gamma_{2}(s)-\gamma_{1}(t))$
$\displaystyle=-(\dot{\gamma}_{1}(t),\dot{\gamma}_{2}(s),-(\gamma_{1}(t)-\gamma_{2}(s)))$
$\displaystyle=(\dot{\gamma}_{1}(t),\dot{\gamma}_{2}(s),\gamma_{1}(t)-\gamma_{2}(s)).$

(2b) is obvious from the coplanarity of the normal vectors.

(2c) is simply a consequence of the path-independence of the integrals over
$s,t$.

(2d) follows from $\dot{\gamma}_{1}(-t)=-\dot{\gamma}(t)$ since the reverse
orientation of $\gamma_{1}(t)$ is $\gamma_{1}(-t)$.

(2e) Any scaling $\vec{v}\mapsto\lambda\vec{v}$ will result in a change of
parameterisation $\gamma_{i}(t)\mapsto\gamma_{i}(\lambda
t)=\lambda(\gamma_{I})(t)$. Since
$\dot{\lambda\gamma}_{i}(t)=\lambda\dot{\gamma}_{i}(t)$, the result follows
below

$\displaystyle\mathrm{lk}(\gamma_{1}(\lambda t),\gamma_{2}(\lambda s))$
$\displaystyle=\dfrac{1}{4\pi}\int\limits_{0}^{1}\int\limits_{0}^{1}\dfrac{(\lambda\dot{\gamma}_{1}(t),\lambda\dot{\gamma}_{2}(s),\lambda(\gamma_{1}(t)-\gamma_{2}(s)))}{|\lambda(\gamma_{1}(t)-\gamma_{2}(s))|^{3}}dtds$
$\displaystyle=\dfrac{1}{4\pi}\int\limits_{0}^{1}\int\limits_{0}^{1}\dfrac{\lambda^{3}(\dot{\gamma}_{1}(t),\dot{\gamma}_{2}(s),\gamma_{1}(t)-\gamma_{2}(s))}{\lambda^{3}|\gamma_{1}(t)-\gamma_{2}(s)|^{3}}dtds$
$\displaystyle=\mathrm{lk}(\gamma_{1}(t),\gamma_{2}(s)),$

(2f) For an orthogonal transformation $M$, we have $M\vec{u}\times
M\vec{v}=(\det M)M(\vec{u}\times\vec{v})$, while $M\vec{u}\cdot
M\vec{v}=\vec{u}\cdot\vec{v}$. Therefore
$|M\vec{v}-M\vec{u}|=|\vec{v}-\vec{u}|$, $(M\vec{u},M\vec{v},M\vec{w})=\det
M(\vec{u},\vec{v},\vec{w})$ and
$\mathrm{lk}(M\gamma_{1},M\gamma_{2})=(\det{M})(\mathrm{lk}(\gamma_{1},\gamma_{2}))$,
so the linking number is multiplied by $\det{M}$. $\blacksquare$

Our main Theorem 8 will prove an analytic formula for the linking number of
any line segments $L_{1},L_{2}$ in terms of 6 isometry invariants of
$L_{1},L_{2}$, which are introduced in 5. Simpler 3 expresses
$\mathrm{lk}(L_{1},L_{2})$ for any _simple_ orthogonal oriented segments
$L_{1},L_{2}$ defined by their lengths $l_{1},l_{2}>0$ and initial endpoints
$O_{1},O_{2}$, respectively, with the Euclidean distance $d(O_{1},O_{2})=d>0$,
so that $\vec{L}_{1},\vec{L}_{2},\overrightarrow{O_{1}O_{2}}$ form a
positively oriented orthogonal basis whose signed volume
$(\vec{L}_{1},\vec{L}_{2},\overrightarrow{O_{1}O_{2}})=l_{1}l_{2}d$ is the
product of the lengths, see the first picture in Fig. 1.

######  Corollary 3 (linking number for simple orthogonal segments)

For any simple orthogonal oriented line segments
$L_{1},L_{2}\subset\mathbb{R}^{3}$ with lengths $l_{1},l_{2}$ and a distance
$d$ as defined above, the linking number is
$\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\arctan\left(\dfrac{l_{1}l_{2}}{d\sqrt{l_{1}^{2}+l_{2}^{2}+d^{2}}}\right)$.

The above expression is a special case of general formula (8) for
$a_{1}=a_{2}=0$ and $\alpha=\dfrac{\pi}{2}$. If $l_{1}=l_{2}=l$, the linking
number in 3 becomes
$\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\arctan\dfrac{l^{2}}{d\sqrt{2l^{2}+d^{2}}}$.
If $l_{1}=l_{2}=d$, then
$\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\arctan\dfrac{1}{\sqrt{3}}=-\dfrac{1}{24}$.

3 implies that the linking number is in the range $(-\frac{1}{8},0)$ for any
simple orthogonal segments with $d>0$, which wasn’t obvious from Definition 1.
If $L_{1},L_{2}$ move away from each other, then
$\lim\limits_{d\to+\infty}\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\arctan
0=0$. Alternatively, if segments with $l_{1}=l_{2}=l$ become infinitely short,
the limit is again zero: $\lim\limits_{l\to 0}\mathrm{lk}(L_{1},L_{2})=0$ for
any fixed $d$. The limit $\lim\limits_{x\to+\infty}\arctan x=\dfrac{\pi}{2}$
implies that if segments with $l_{1}=l_{2}=l$ become infinitely long for a
fixed distance $d$,
$\lim\limits_{l\to+\infty}\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\arctan\dfrac{l^{2}}{d\sqrt{2l^{2}+d^{2}}}=-\dfrac{1}{8}$.
If we push segments $L_{1},L_{2}$ of fixed (possibly different) lengths
$l_{1},l_{2}$ towards each other, the same limit similarly emerges:
$\lim\limits_{d\to 0}\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{8}$. See more general
corollaries in section 6.

##  3 Past results about the Gauss integral for the linking number

The survey ricca2011gauss  reviews the history of the Gauss integral, its use
in Maxwell’s description of electromagnetic fields maxwell1873treatise , and
its interpretation as the degree of a map from the torus to the sphere. In
classical knot theory $\mathrm{lk}(\gamma_{1},\gamma_{2})$ is a topological
invariant of a link consisting of closed curves $\gamma_{1}\sqcup\gamma_{2}$,
whose equivalence relation is ambient isotopy. This relation is too flexible
for open curves which can be isotopically unwound, and hence doesn’t preserve
the Gauss integral for open curves $\gamma_{1},\gamma_{2}$.

Computing the value of the Gauss integral directly from the parametric
equation of two generic curves is only possible by approximation, but this
problem is simplified when we consider simply straight lines. The first form
of the linking number between two straight line segments in terms of their
geometry is described by Banchoff banchoff1976self . Banchoff considers the
projection of segments on to a plane orthogonal to some vector $\xi\in S^{2}$.
The Gauss integral is interpreted as the fraction of the unit sphere covered
by those directions of $\xi$ for which the projection will have a crossing.

This interpretation was the foundation of a closed form developed by Arai
arai2013rigorous , using van Oosterom and Strackee’s closed formula for the
solid angle subtended by a tetrahedron given by the origin of a sphere and
three points on its surface. An efficient implementation of the solid angle
approach to the linking number is discussed in bertolazzi2019efficient .

An alternative calculation for this solid angle is given in panagiotou2020knot
as a starting point for calculating further invariants of open entangled
curves. This form does not employ geometric invariants, but was used in
klenin2000computation  to claim a formula (without a proof) similar to Theorem
8, which is proved in this paper with more corollaries in section 6.

Figure 1: Each line segment $L_{i}$ is in the plane
$\\{z=(-1)^{i}\frac{d}{2}\\}$, $i=1,2$. Left: signed distance $d>0$, the
endpoint coordinates $a_{1}=0$, $b_{1}=1$ and $a_{2}=0$, $b_{2}=1$, the
lengths $l_{1}=l_{2}=1$. Right: signed distance $d<0$, the endpoint
coordinates $a_{1}=-1$, $b_{1}=1$ and $a_{2}=-1$, $b_{2}=1$, so
$l_{1}=l_{2}=2$. In both middle pictures $\alpha=\frac{\pi}{2}$ is the angle
from $\mathrm{pr}_{xy}(L_{1})$ to $\mathrm{pr}_{xy}(L_{2})$ with $x$-axis as
the bisector.

##  4 Six isometry invariants of skew line segments in 3-space

This section introduces six isometry invariants, which uniquely determine
positions of any line segments $L_{1},L_{2}\subset\mathbb{R}^{3}$ modulo
isometries of $\mathbb{R}^{3}$, see 5.

It suffices to consider only _skew_ line segments that do not belong to the
same 2-dimensional plane. If $L_{1},L_{2}$ are in the same plane $\Pi$, for
example if they are parallel, then $\dot{L}_{1}(t)\times\dot{L}_{2}(s)$ is
orthogonal to any vector $L_{1}(t)-L_{2}(s)$ in the plane $\Pi$, hence
$\mathrm{lk}(L_{1},L_{2})=0$. We denote by
$\bar{L}_{1},\bar{L}_{2}\subset\mathbb{R}^{3}$ the infinite oriented lines
through the given line segments $L_{1},L_{2}$, respectively. In a plane with
fixed coordinates $x,y$, all angles are measured anticlockwise from the
positive $x$-axis.

######  Definition 4 (invariants of line segments)

Let $\alpha\in[0,\pi]$ be the angle between oriented line segments
$L_{1},L_{2}\subset\mathbb{R}^{3}$. Assuming that $L_{1},L_{2}$ are not
parallel, there is a unique pair of parallel planes $\Pi_{i}$, $i=1,2$, each
containing the infinite line $\bar{L}_{i}$ through the line segment $L_{i}$.
We choose orthogonal coordinates $x,y,z$ in $\mathbb{R}^{3}$ so that

(4a) the horizontal plane $\\{z=0\\}$ is in the middle between
$\Pi_{1},\Pi_{2}$, see Fig. 1;

(4b) $(0,0,0)$ is the intersection of the projections
$\mathrm{pr}_{xy}(\bar{L}_{1}),\mathrm{pr}_{xy}(\bar{L}_{2})$ to $\\{z=0\\}$;

(4c) the $x$-axis bisects the angle $\alpha$ from
$\mathrm{pr}_{xy}(\bar{L}_{1})$ to $\mathrm{pr}_{xy}(\bar{L}_{2})$, the
$y$-axis is chosen so that $\alpha$ is anticlockwisely measured from the
$x$-axis to the $y$-axis in $\\{z=0\\}$;

(4d) the $z$-axis is chosen so that $x,y,z$ are oriented in the right hand
way, then $d$ is the _signed_ distance from $\Pi_{1}$ to $\Pi_{2}$; the
distance $d$ is negative if the vector $\overrightarrow{O_{1}O_{2}}$ is
opposite to the positively oriented $z$-axis in Fig. 1.

Let $a_{i},b_{i}$ be the coordinates of the initial and final endpoints of the
segments $L_{i}$ in the infinite line $\bar{L}_{i}$ whose origin is
$O_{i}=\Pi_{i}\cap(z\text{-axis})=(0,0,(-1)^{i}\frac{d}{2})$, $i=1,2$.

The case of segments $L_{1},L_{2}$ lying in the same plane
$\Pi\subset\mathbb{R}^{3}$ can be formally covered by Definition 4 if we allow
the signed distance $d$ from $\Pi_{1}$ to $\Pi_{2}$ to be 0.

######  Lemma 5 (parameterisation)

Any oriented line segments $L_{1},L_{2}\subset\mathbb{R}^{3}$ are uniquely
determined modulo a rigid motion by their isometry invariants
$\alpha\in[0,\pi]$ and $d$, $a_{1}$, $b_{1}$, $a_{2}$, $b_{2}\in\mathbb{R}$
from Definition 4. For $l_{i}=b_{i}-a_{i}$, $i=1,2$, each line segment $L_{i}$
is

$L_{i}(t)=\Big{(}\;(a_{i}+l_{i}t)\cos\frac{\alpha}{2},\;(-1)^{i}(a_{i}+l_{i}t)\sin\frac{\alpha}{2},\;(-1)^{i}\frac{d}{2}\;\Big{)},\;t\in[0,1].$
$None$

###### Proof

Any line segments $L_{1},L_{2}\subset\mathbb{R}^{3}$ that are not in the same
plane are contained in distinct parallel planes. For $i=1,2$, the plane
$\Pi_{i}$ is spanned by $L_{i}$ and the line parallel to $L_{3-i}$ and passing
through an endpoint of $L_{i}$. Let $L^{\prime}_{i}$ be the orthogonal
projection of the line segment $L_{i}$ to the plane $\Pi_{3-i}$. The non-
parallel lines through the segments $L_{i}$ and $L^{\prime}_{3-i}$ in the
plane $\Pi_{i}$ intersect at a point, say $O_{i}$. Then the line segment
$O_{1}O_{2}$ is orthogonal to both planes $\Pi_{i}$, hence to both $L_{i}$ for
$i=1,2$.

By Theorem 2, to compute $\mathrm{lk}(L_{1},L_{2})$, one can apply a rigid
motion to move the mid-point of the line segment $O_{1}O_{2}$ to the origin
$O=(0,0,0)\in\mathbb{R}^{2}$ and make $O_{1}O_{2}$ vertical, i.e. lying within
the $z$-axis. The signed distance $d$ can be defined as the difference between
the coordinates of $O_{2}=\Pi_{2}\cap(z\text{-axis})$ and
$O_{1}=\Pi_{1}\cap(z\text{-axis})$ along the $z$-axis. Then $L_{i}$ lies in
the horizontal plane $\Pi_{i}=\\{z=(-1)^{i}\frac{d}{2}\\}$, $i=1,2$.

An extra rotation around the $z$-axis guarantees that the $x$-axis in the
horizontal plane $\Pi=\\{z=0\\}$ is the bisector of the angle
$\alpha\in[0,\pi]$ from $\mathrm{pr}_{xy}(\bar{L}_{1})$ to
$\mathrm{pr}_{xy}(\bar{L}_{2})$, where $\mathrm{pr}_{xy}:\mathbb{R}^{3}\to\Pi$
is the orthogonal projection. Then the infinite lines $\bar{L}_{i}$ through
$L_{i}$ have the parametric form
$(x,y,z)=(t\cos\frac{\alpha}{2},(-1)^{i}t\sin\frac{\alpha}{2},(-1)^{i}\frac{d}{2})$
with $s\in\mathbb{R}$.

The point $O_{i}$ can be considered as the origin of the oriented infinite
line $\bar{L}_{i}$. Let the line segment $L_{i}$ have a length $l_{i}>0$ and
its initial point have the coordinate $a_{i}\in\mathbb{R}$ in the oriented
line $\bar{L}_{i}$. Then the final endpoint of $L_{i}$ has the coordinate
$b_{i}=a_{i}+l_{i}$. To cover only the segment $L_{i}$, the parameter $t$
should be replaced by $a_{i}+l_{i}t$, $t\in[0,1]$. $\blacksquare$

If $t\in\mathbb{R}$ in 5, the corresponding point $L_{i}(t)$ moves along the
line $\bar{L}_{i}$.

######  Lemma 6 (formulae for invariants)

Let $L_{1},L_{2}\subset\mathbb{R}^{3}$ be any skewed oriented line segments
given by their initial and final endpoints $A_{i},B_{i}\in\mathbb{R}^{3}$ so
that $\vec{L}_{i}=\overrightarrow{A_{i}B_{i}}$, $i=1,2$. Then the isometry
invariants of $L_{1},L_{2}$ in 5 are computed as follows:

the lengths $l_{i}=|\overrightarrow{A_{i}B_{i}}|$, the signed distance
$d=\dfrac{[\vec{L}_{1},\vec{L}_{2},\overrightarrow{A_{1}A_{2}}]}{|\vec{L}_{1}\times\vec{L}_{2}|}$,
the angle $\alpha=\arccos\dfrac{\vec{L}_{1}\cdot\vec{L}_{2}}{l_{1}l_{2}}$,
$a_{1}=\left(\dfrac{\vec{L}_{2}}{l_{2}}\cos\alpha-\dfrac{\vec{L}_{1}}{l_{1}}\right)\cdot\dfrac{\overrightarrow{A_{1}A_{2}}}{\sin^{2}\alpha}$,
$\;a_{2}=\left(\dfrac{\vec{L}_{2}}{l_{2}}-\dfrac{\vec{L}_{1}}{l_{1}}\cos\alpha\right)\cdot\dfrac{\overrightarrow{A_{1}A_{2}}}{\sin^{2}\alpha}$,
$\;b_{i}=a_{i}+l_{i}$, $i=1,2$.

###### Proof

The vectors along the segments are $\vec{L}_{i}=\vec{v}_{i}-\vec{u}_{i}$,
hence the lengths are $l_{i}=|\vec{L}_{i}|=|\overrightarrow{A_{i}B_{i}}|$,
$i=1,2$. The angle $\alpha\in[0,\pi]$ between $\vec{L}_{1},\vec{L}_{2}$ can be
found from the scalar product
$\vec{L}_{1}\cdot\vec{L}_{2}=|\vec{L}_{1}|\cdot|\vec{L}_{2}|\cos\alpha$ as
$\alpha=\arccos\dfrac{\vec{L}_{1}\cdot\vec{L}_{2}}{l_{1}l_{2}}$, because the
function $\arccos x:[-1,1]\to[0,\pi]$ is bijective.

Since the vectors $\vec{L}_{1},\vec{L}_{2}$ are not proportional to each
other, the normalised vector product
$\vec{e}_{3}=\dfrac{\vec{L}_{1}\times\vec{L}_{2}}{|\vec{L}_{1}\times\vec{L}_{2}|}$
is well-defined and orthogonal to both $\vec{L}_{1},\vec{L}_{2}$. Then
$\vec{e}_{1}=\dfrac{\vec{L}_{1}}{|\vec{L}_{1}|}$,
$\vec{e}_{2}=\dfrac{\vec{L}_{2}}{|\vec{L}_{2}|}$ and $\vec{e}_{3}$ have
lengths 1 and form a linear basis of $\mathbb{R}^{3}$, where the last vector
is orthogonal to the first two.

Let $O$ be any fixed point of $\mathbb{R}^{3}$, which can be assume to be the
origin $(0,0,0)$ in the coordinates of 5, though its position relative to
$\overrightarrow{A_{i}B_{i}}$ is not yet determined. First we express the
points $O_{i}=(0,0,(-1)^{i}\frac{d}{2})\in\bar{L}_{i}$ from Fig. 1 in terms of
given vectors $\overrightarrow{A_{i}B_{i}}$. If the initial endpoint $A_{i}$
has a coordinate $a_{i}$ in the line $\bar{L}_{i}$ through $L_{i}$, then
$\overrightarrow{O_{i}A_{i}}=a_{i}\vec{e}_{i}$ and

$\overrightarrow{O_{1}O_{2}}=\overrightarrow{OO_{2}}-\overrightarrow{OO_{1}}=(\overrightarrow{OA_{2}}-\overrightarrow{O_{2}A_{2}})-(\overrightarrow{OA_{1}}-\overrightarrow{O_{1}A_{1}})=\overrightarrow{A_{1}A_{2}}+a_{1}\vec{e}_{1}-a_{2}\vec{e}_{2}.$

By Definition 4, $\overrightarrow{O_{1}O_{2}}$ is orthogonal to the line
$\bar{L}_{i}$ going through the vector
$\vec{e}_{i}=\dfrac{\vec{L}_{i}}{|\vec{L}_{i}|}$ for $i=1,2$. Then the product
$[\vec{e}_{1},\vec{e}_{2},\overrightarrow{O_{1}O_{2}}]=(\vec{e}_{1}\times\vec{e}_{2})\cdot\overrightarrow{O_{1}O_{2}}$
equals $|\vec{e}_{1}\times\vec{e}_{2}|d$, where $\overrightarrow{O_{1}O_{2}}$
is in the $z$-axis, the signed distance $d$ is the $z$-coordinate of $O_{2}$
minus the $z$-coordinates $O_{1}$.

The product
$[\vec{e}_{1},\vec{e}_{2},\overrightarrow{O_{1}O_{2}}]=(\vec{e}_{1}\times\vec{e}_{2})\cdot(\overrightarrow{A_{1}A_{2}}+a_{1}\vec{e}_{1}-a_{2}\vec{e}_{2})=(\vec{e}_{1}\times\vec{e}_{2})\cdot\overrightarrow{A_{1}A_{2}}$
doesn’t depend on $a_{1},a_{2}$, because $\vec{e}_{1}\times\vec{e}_{2}$ is
orthogonal to both $\vec{e}_{1},\vec{e}_{2}$. Hence the signed distance is
$d=\dfrac{[\vec{e}_{1},\vec{e}_{2},\overrightarrow{A_{1}A_{2}}]}{|\vec{e}_{1}\times\vec{e}_{2}|}=\dfrac{[\vec{L}_{1},\vec{L}_{2},\overrightarrow{A_{1}A_{2}}]}{|\vec{L}_{1}\times\vec{L}_{2}|}$,
which can be positive or negative, see Fig. 1.

It remains to find the coordinate $a_{i}$ of the initial endpoint of $L_{i}$
relative to the origin $O_{i}\in\bar{L}_{i}$, $i=1,2$. The vector
$\overrightarrow{O_{1}O_{2}}=\overrightarrow{A_{1}A_{2}}+a_{1}\vec{e}_{1}-a_{2}\vec{e}_{2}$
is orthogonal to both $\vec{e}_{i}$ if and only if the scalar products vanish:
$\overrightarrow{O_{1}O_{2}}\cdot\vec{e}_{i}=0$. Due to
$|\vec{e}_{1}|=1=|\vec{e}_{2}|$ and $\vec{e}_{1}\cdot\vec{e}_{2}=\cos\alpha$,
we get

$\left\\{\begin{array}[]{l}\vec{e}_{1}\cdot\overrightarrow{A_{1}A_{2}}+a_{1}-a_{2}(\vec{e}_{1}\cdot\vec{e}_{2})=0,\\\
\vec{e}_{2}\cdot\overrightarrow{A_{1}A_{2}}+a_{1}(\vec{e}_{1}\cdot\vec{e}_{2})-a_{2}=0,\\\
\end{array}\right.\qquad\left(\begin{array}[]{cc}1&-\cos\alpha\\\
\cos\alpha&-1\end{array}\right)\left(\begin{array}[]{c}a_{1}\\\
a_{2}\end{array}\right)=-\left(\begin{array}[]{c}\vec{e}_{1}\cdot\overrightarrow{A_{1}A_{2}}\\\
\vec{e}_{2}\cdot\overrightarrow{A_{1}A_{2}}\end{array}\right).$

The determinant of the $2\times 2$ matrix is
$\cos^{2}\alpha-1=-\sin^{2}\alpha\neq 0$, because $L_{1},L_{2}$ are not
parallel. Then $\left(\begin{array}[]{c}a_{1}\\\
a_{2}\end{array}\right)=\dfrac{1}{\sin^{2}\alpha}\left(\begin{array}[]{cc}-1&\cos\alpha\\\
-\cos\alpha&1\end{array}\right)\left(\begin{array}[]{c}\vec{e}_{1}\cdot\overrightarrow{A_{1}A_{2}}\\\
\vec{e}_{2}\cdot\overrightarrow{A_{1}A_{2}}\end{array}\right)$.

$a_{1}=\dfrac{-\vec{e}_{1}\cdot\overrightarrow{A_{1}A_{2}}+\cos\alpha(\vec{e}_{2}\cdot\overrightarrow{A_{1}A_{2}})}{\sin^{2}\alpha}=\dfrac{(\vec{e}_{2}\cos\alpha-\vec{e}_{1})\cdot\overrightarrow{A_{1}A_{2}}}{\sin^{2}\alpha}=\left(\dfrac{\vec{L}_{2}}{l_{2}}\cos\alpha-\dfrac{\vec{L}_{1}}{l_{1}}\right)\cdot\dfrac{\overrightarrow{A_{1}A_{2}}}{\sin^{2}\alpha},$
$a_{2}=\dfrac{\cos\alpha(\vec{e}_{1}\cdot\overrightarrow{A_{1}A_{2}})-\vec{e}_{1}\cdot\overrightarrow{A_{1}A_{2}}}{\sin^{2}\alpha}=\dfrac{(\vec{e}_{2}-\vec{e}_{1}\cos\alpha)\cdot\overrightarrow{A_{1}A_{2}}}{\sin^{2}\alpha}=\left(\dfrac{\vec{L}_{2}}{l_{2}}-\dfrac{\vec{L}_{1}}{l_{1}}\cos\alpha\right)\cdot\dfrac{\overrightarrow{A_{1}A_{2}}}{\sin^{2}\alpha}.$

The coordinates of the final endpoints are obtained as $b_{i}=a_{i}+l_{i}$,
$i=1,2$. $\blacksquare$

7 guarantees that the linking number behaves symmetrically in $d$, meaning
that we may confine any particular analysis to cases where $d>0$ or $d<0$.

######  Lemma 7 (symmetry)

Let $L_{1},L_{2}\subset\mathbb{R}^{3}$ be parameterised as in 5. Under the
central symmetry $\mathrm{CS}:(x,y,z)\mapsto(-x,-y,-z)$ with respect to the
origin $(0,0,0)\in\mathbb{R}^{3}$, the line segments keep their invariants
$\alpha,a_{1},b_{1},a_{2},b_{2}$. The signed distance $d$ and the linking
number change their signs:
$\mathrm{lk}(\mathrm{CS}(L_{1}),\mathrm{CS}(L_{2}))=-\mathrm{lk}(L_{1},L_{2})$.

######  Proof (7)

Under the central symmetry $\mathrm{CS}$, in the notation of 6 the vectors
$\vec{L}_{1},\vec{L}_{2},\overrightarrow{A_{1}A_{2}}$ change their signs. Then
the formulae for $\alpha,a_{1},b_{1},a_{2},b_{2}$ gives the same expression,
but the triple product $[\vec{L}_{1},\vec{L}_{2},\overrightarrow{A_{1}A_{2}}]$
and $d$ change their signs.

Since the central symmetry $\mathrm{CS}$ is an orthogonal map $M$ with $\det
M=-1$, the new linking number changes its sign as follows:
$\mathrm{lk}(\mathrm{CS}(L_{1}),\mathrm{CS}(L_{2}))=\mathrm{lk}(\mathrm{CS}(L_{2}),\mathrm{CS}(L_{1}))=-\mathrm{lk}(L_{1},L_{2})$,
where we also make use of the invariance of the linking number under exchange
of the segments from Theorem 2(f). $\blacksquare$

##  5 Invariant-based formula for the linking number of segments

This section proves main Theorem 8, which expresses the linking number of any
line segments in terms of their 6 isometry invariants from Definition 4. In
2000 Klenin and Langowski claimed a similar formula klenin2000computation ,
but gave no proof, which requires substantial lemmas below. One of their 6
invariants differs from the signed distance $d$.

######  Theorem 8 (invariant-based formula)

For any line segments $L_{1},L_{2}\subset\mathbb{R}^{3}$ with invariants
$\alpha\in(0,\pi)$, $a_{1},b_{1},a_{2},b_{2},d\in\mathbb{R}$ from Definition
4, we have $\mathrm{lk}(L_{1},L_{2})=$

$\dfrac{\and(a_{1},b_{2};d,\alpha)+\and(b_{1},a_{2};d,\alpha)-\and(a_{1},a_{2};d,\alpha)-\and(b_{1},b_{2};d,\alpha)}{4\pi},$
$None$

where
$\and(a,b;d,\alpha)=\arctan\left(\dfrac{ab\sin\alpha+d^{2}\cot\alpha}{d\sqrt{a^{2}+b^{2}-2ab\cos\alpha+d^{2}}}\right)$.
For $\alpha=0$ or $\alpha=\pi$, we set
$\and(a,b;d,\alpha)=\mathrm{sign}(d)\dfrac{\pi}{2}$. We also set
$\mathrm{lk}(L_{1},L_{2})=0$ when $d=0$.

$a^{2}+b^{2}-2ab\cos\alpha$ gives the squared third side of the triangle with
the first two sides $a,b$ and the angle $\alpha$ between them, hence is always
non-negative. Also $a^{2}+b^{2}-2ab\cos\alpha=0$ only when the triangle
degenerates for $a=\pm b$ and $\cos\alpha=\pm 1$. For $\alpha=0$ or
$\alpha=\pi$ when $L_{1},L_{2}$ are parallel, $\mathrm{lk}(L_{1},L_{2})=0$ is
guaranteed by $\and(a,b;d,\alpha)=\mathrm{sign}(d)\dfrac{\pi}{2}=0$ when $d=0$
holds in addition to $\alpha=0$ or $\alpha=\pi$.

The symmetry of the $\and$ function in $a,b$, i.e.
$\and(a,b;d,\alpha)=\and(b,a;d,\alpha)$ implies that
$\mathrm{lk}(L_{1},L_{2})=\mathrm{lk}(L_{2},L_{1})$ by Theorem 8. Since the
$\and$ function is odd in $d$, i.e. $\and(a,b;-d,\alpha)=-\and(b,a;d,\alpha)$,
7 is also respected.

######  Proof (of 3)

By definition any simple orthogonal line segments $L_{1},L_{2}$ have the angle
$\alpha=\dfrac{\pi}{2}$ and initial endpoints $a_{1}=0=a_{2}$, hence
$b_{1}=l_{1}$, $b_{2}=l_{2}$. Substituting the values above into (8) gives
$\and(0,l_{2};d,\frac{\pi}{2})=0$, $\and(l_{1},0;d,\frac{\pi}{2})=0$,
$\and(0,0;d,\frac{\pi}{2})=0$. Then
$\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\and(l_{1},l_{2};d,\alpha)=-\dfrac{1}{4\pi}\arctan\left(\dfrac{l_{1}l_{2}}{d\sqrt{l_{1}^{2}+l_{2}^{2}+d^{2}}}\right)$.
$\blacksquare$

Figure 2 shows how the function $\and(a,b;d,\alpha)$ from Theorem 8 depends on
2 of 4 parameters when others are fixed. For example, if
$\alpha=\dfrac{\pi}{2}$, then
$\and(a,b;d,\frac{\pi}{2})=\arctan\left(\dfrac{ab}{d\sqrt{a^{2}+b^{2}+d^{2}}}\right)$.
If also $a=b$, the surface
$\and(a,a;d,\frac{\pi}{2})=\arctan\left(\dfrac{a^{2}}{d\sqrt{2a^{2}+d^{2}}}\right)$
in the first picture of Figure 2 has the horizontal ridge
$\and(0,0;d,\frac{\pi}{2})=0$ and $\lim\limits_{d\to
0}\and(a,a;d,\frac{\pi}{2})=\mathrm{sign}(d)\dfrac{\pi}{2}$ for $a\neq 0$. If
$d,\alpha$ are free, but $a=0$, then
$\and(0,0;d,\alpha)=\arctan\left(\dfrac{d^{2}\cot\alpha}{d\sqrt{d^{2}}}\right)=\mathrm{sign}(d)\arctan(\cot\alpha)=\mathrm{sign}(d)(\frac{\pi}{2}-\alpha).$
Similarly,
$\lim\limits_{d\to\infty}\and(0,0;d,\alpha)=\mathrm{sign}(d)(\frac{\pi}{2}-\alpha)$,
see the lines $\and=\frac{\pi}{2}-\alpha$ on the boundaries of the AT surfaces
in the middle pictures of Figure 2.

Figure 2: The graph of
$\and(a,b;d,\alpha)=\arctan\left(\dfrac{ab\sin\alpha+d^{2}\cot\alpha}{d\sqrt{a^{2}+b^{2}-2ab\cos\alpha+d^{2}}}\right)$,
where 2 of 4 parameters are fixed. Top left: $l=b-a=0$,
$\alpha=\dfrac{\pi}{2}$. Top right: $l=d=-1$. Middle left: $a=0$, $d=1$.
Middle right: $a=0$, $l=1$. Bottom left: $a=1$, $\alpha=\dfrac{\pi}{2}$.
Bottom right: $d=-1$, $\alpha=\dfrac{\pi}{2}$.

######  Lemma 9 ($\mathrm{lk}(L_{1},L_{2})$ is an integral in $p,q$)

In the notations of Definition 4 we have
$\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\int\limits_{a_{1}/d}^{b_{1}/d}\;\int\limits_{a_{2}/d}^{b_{2}/d}\dfrac{\sin\alpha\;dp\;dq}{(1+p^{2}+q^{2}-2pq\cos\alpha)^{3/2}}$
for $d>0$.

######  Proof (9)

The following computations assume that $a_{1},a_{2},l_{1},l_{2},\alpha$ are
given and $t,s\in[0,1]$.

$L_{1}(t)=((a_{1}+l_{1}t)\cos\frac{\alpha}{2},-(a_{1}+l_{1}t)\sin\alpha,-\frac{d}{2})$,
$L_{2}(s)=((a_{2}+l_{2}s)\cos\frac{\alpha}{2},(a_{2}+l_{2}s)\sin\alpha,\frac{d}{2})$,
$\dot{L}_{1}(t)=(l_{1}\cos\frac{\alpha}{2},-l_{1}\sin\frac{\alpha}{2},0)$,
$\dot{L}_{2}(s)=(l_{2}\cos\frac{\alpha}{2},l_{2}\sin\frac{\alpha}{2},0)$,
$\dot{L}_{1}(t)\times\dot{L}_{2}(s)=(0,0,2l_{1}l_{2}\sin\frac{\alpha}{2}\cos\frac{\alpha}{2})=(0,0,l_{1}l_{2}\sin\alpha)$,
$L_{1}(t)-L_{2}(s)=((a_{1}-a_{2}+l_{1}t-l_{2}s)\cos\alpha,-(a_{1}+a_{2}+l_{1}t+l_{2}s)\sin\alpha,-d)$,
$(\dot{L}_{1}(t),\dot{L}_{2}(s),L_{1}(t)-L_{2}(s))=-dl_{1}l_{2}\sin\alpha$,

$\mathrm{lk}(L_{1},L_{2})=\dfrac{1}{4\pi}\int\limits_{0}^{1}\int\limits_{0}^{1}\dfrac{(\dot{L}_{1}(t),\dot{L}_{2}(s),L_{1}(t)-L_{2}(s))}{|L_{1}(t)-L_{2}(s)|^{3}}dtds=$
$=\dfrac{1}{4\pi}\int\limits_{0}^{1}\int\limits_{0}^{1}\dfrac{-dl_{1}l_{2}\sin\alpha\;dtds}{(d^{2}+(a_{1}-a_{2}+l_{1}t-l_{2}s)^{2}\cos^{2}\frac{\alpha}{2}+(a_{1}+a_{2}+l_{1}t+l_{2}s)^{2}\sin^{2}\frac{\alpha}{2})^{3/2}}$
$=-\dfrac{dl_{1}l_{2}\sin\alpha}{4\pi}\int\limits_{0}^{1}\int\limits_{0}^{1}\dfrac{dtds}{(d^{2}+(a_{1}-a_{2}+l_{1}t-l_{2}s)^{2}\cos^{2}\frac{\alpha}{2}+(a_{1}+a_{2}+l_{1}t+l_{2}s)^{2}\sin^{2}\frac{\alpha}{2})^{3/2}}$.

To simplify the last integral, introduce the variables
$p=\dfrac{a_{1}+l_{1}t}{d}$ and $q=\dfrac{a_{2}+l_{2}s}{d}$. In the new
variables $p,q$ the expression under the power $\dfrac{3}{2}$ in the
denominator becomes

$d^{2}+(pd-
qd)^{2}\cos^{2}\frac{\alpha}{2}+(pd+qd)^{2}\sin^{2}\frac{\alpha}{2}=$
$=d^{2}\left(1+(p^{2}-2pq+q^{2})\cos^{2}\frac{\alpha}{2}+(p^{2}-2pq+q^{2})\cos^{2}\frac{\alpha}{2}\right)=$
$=d^{2}\left(1+p^{2}\Big{(}\cos^{2}\frac{\alpha}{2}+\sin^{2}\frac{\alpha}{2}\Big{)}+q^{2}-2pq\Big{(}\cos^{2}\frac{\alpha}{2}-\sin^{2}\frac{\alpha}{2}\Big{)}\right)=d^{2}(1+p^{2}+q^{2}-2pq\cos\alpha).$

The old variables are expressed as $t=\dfrac{pd-a_{1}}{l_{1}}$, $ts=\dfrac{pd-
a_{2}}{l_{2}}$ and have the differentials $dt=\dfrac{d}{l_{1}}dp$,
$ds=\dfrac{d}{l_{2}}dq$. Since $t,s\in[0,1]$, the new variables $p,q$ have the
ranges $[\frac{a_{1}}{d},\frac{b_{1}}{d}]$ and
$[\frac{a_{2}}{d},\frac{b_{2}}{d}]$, respectively. Then the linking number has
the required expression in the lemmama:

$\mathrm{lk}(L_{1},L_{2})=-\dfrac{dl_{1}l_{2}\sin\alpha}{4\pi}\int\limits_{a_{1}/d}^{b_{1}/d}\;\int\limits_{a_{2}/d}^{b_{2}/d}\dfrac{d^{2}}{l_{1}l_{2}}\dfrac{dp\;dq}{d^{3}(1+p^{2}+q^{2}-2pq\cos\alpha)^{3/2}}=$
$=-\dfrac{1}{4\pi}\int\limits_{a_{1}/d}^{b_{1}/d}\;\int\limits_{a_{2}/d}^{b_{2}/d}\dfrac{\sin\alpha\;dp\;dq}{(1+p^{2}+q^{2}-2pq\cos\alpha)^{3/2}}.$

Due to 7, the above computations assume that the signed distance $d>0$.
$\blacksquare$

######  Lemma 10 (the linking number as a single integral)

In the notations of Definition 4 we have
$\mathrm{lk}(L_{1},L_{2})=\dfrac{I(a_{2}/d)-I(b_{2}/d)}{4\pi}$, where the
function $I(r)$ is defined as the single integral
$I(r)=\int\limits_{a_{1}/d}^{b_{1}/d}\dfrac{\sin\alpha(r-p\cos\alpha)dp}{(1+p^{2}\sin^{2}\alpha)\sqrt{1+p^{2}+r^{2}-2pr\cos\alpha}}$
for $d>0$.

######  Proof (10)

Complete the square in the expression under power $\dfrac{3}{2}$ in 9:

$1+p^{2}+q^{2}-2pq\cos\alpha=1+p^{2}\sin^{2}\alpha+(q-p\cos\alpha)^{2}.$

The substitution $(q-p\cos\alpha)=(1+p^{2}\sin^{2}\alpha)\tan^{2}\psi$ for the
new variable $\psi$ simplifies the sum of squares to
$1+\tan^{2}\psi=\dfrac{1}{\cos^{2}\psi}$. Since $q$ varies within
$[\frac{a_{2}}{d},\frac{b_{2}}{d}]$, for any fixed
$p\in[\frac{a_{1}}{d},\frac{b_{1}}{d}]$, the range $[\psi_{0},\psi_{1}]$ of
$\psi$ satisfies
$\tan\psi_{0}=\dfrac{\frac{a_{2}}{d}-p\cos\alpha}{\sqrt{1+p^{2}\sin^{2}\alpha}}$
and
$\tan\psi_{1}=\dfrac{\frac{b_{2}}{d}-p\cos\alpha}{\sqrt{1+p^{2}\sin^{2}\alpha}}$.
Since we treat $p,\psi$ as independent variables, the Jacobian of the
substitution $(p,q)\mapsto(p,\psi)$ equals

$\dfrac{\partial
q}{\partial\psi}=\dfrac{\partial}{\partial\psi}\left(p\cos\alpha+\tan\psi\sqrt{1+p^{2}\sin^{2}\alpha}\right)=\dfrac{\sqrt{1+p^{2}\sin^{2}\alpha}}{\cos^{2}\psi}.$

In the variables $p,\psi$ the expression under the double integral of 9
becomes

$\dfrac{\sin\alpha\;dp\;dq}{(1+p^{2}+q^{2}-2pq\cos\alpha)^{3/2}}=\dfrac{\sin\alpha\;dp}{((1+p^{2}\sin^{2}\alpha)+(1+p^{2}\sin^{2}\alpha)\tan^{2}\psi)^{3/2}}\dfrac{\partial
q}{\partial\psi}d\psi$
$=\dfrac{\sin\alpha\;dp}{(1+p^{2}\sin^{2}\alpha)^{3/2}(1+\tan^{2}\psi)^{3/2}}\dfrac{d\psi\sqrt{1+p^{2}\sin^{2}\alpha}}{\cos^{2}\psi}=\dfrac{\sin\alpha\;dp\cos\psi\;d\psi}{1+p^{2}\sin^{2}\alpha}.$
$\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\int\limits_{a_{1}/d}^{b_{1}/d}\dfrac{\sin\alpha\;dp}{1+p^{2}\sin^{2}\alpha}\int\limits_{\psi_{0}}^{\psi_{1}}\cos\psi\;d\psi=\dfrac{1}{4\pi}\int\limits_{a_{1}/d}^{b_{1}/d}\dfrac{\sin\alpha\;dp}{1+p^{2}\sin^{2}\alpha}(\sin\psi_{0}-\sin\psi_{1}).$

Express the sin functions for the bounds $\psi_{0},\psi_{1}$ in terms of tan
as $\sin\psi_{0}=\dfrac{\tan\psi_{0}}{\sqrt{1+\tan^{2}\psi_{0}}}$. Using
$\tan\psi_{0}=\dfrac{\frac{a_{2}}{d}-p\cos\alpha}{\sqrt{1+p^{2}\sin^{2}\alpha}}$
obtained above, we get

$\sqrt{1+\tan^{2}\psi_{0}}=\sqrt{\dfrac{(1+p^{2}\sin^{2}\alpha)+(\frac{a_{2}}{d}-p\cos\alpha)^{2}}{1+p^{2}\sin^{2}\alpha}}=\sqrt{\dfrac{1+p^{2}+(\frac{a_{2}}{d})^{2}-2\frac{a_{2}}{d}p\cos\alpha}{1+p^{2}\sin^{2}\alpha}}.$
$\sin\psi_{0}=\dfrac{\frac{a_{2}}{d}-p\cos\alpha}{\sqrt{1+p^{2}\sin^{2}\alpha}}\sqrt{\dfrac{1+p^{2}\sin^{2}\alpha}{1+p^{2}+(\frac{a_{2}}{d})^{2}-2\frac{a_{2}}{d}p\cos\alpha}}=\dfrac{\frac{a_{2}}{d}-p\cos\alpha}{\sqrt{1+p^{2}+(\frac{a_{2}}{d})^{2}-2\frac{a_{2}}{d}p\cos\alpha}}.$

Then $\sin\psi_{1}$ has the same expression with $a_{2}$ replaced by $b_{2}$.
After substituting these expressions in the previous formula for the linking
number, we get $\mathrm{lk}(L_{1},L_{2})=$

$\dfrac{1}{4\pi}\int\limits_{a_{1}/d}^{b_{1}/d}\dfrac{\sin\alpha\;dp}{1+p^{2}\sin^{2}\alpha}\left(\dfrac{\frac{a_{2}}{d}-p\cos\alpha}{\sqrt{1+p^{2}+(\frac{a_{2}}{d})^{2}-2\frac{a_{2}}{d}p\cos\alpha}}-\dfrac{\frac{b_{2}}{d}-p\cos\alpha}{\sqrt{1+p^{2}+(\frac{b_{2}}{d})^{2}-2\frac{b_{2}}{d}p\cos\alpha}}\right)$

$=\dfrac{S(a_{2}/d)-S(b_{2}/d)}{4\pi}$, where
$I(r)=\int\limits_{a_{1}/d}^{b_{1}/d}\dfrac{\sin\alpha(r-p\cos\alpha)dp}{(1+p^{2}\sin^{2}\alpha)\sqrt{1+p^{2}+r^{2}-2pr\cos\alpha}}$.
$\blacksquare$

######  Lemma 11 ($I(r)$ via arctan)

The integral $I(r)$ in 10 can be found as

$\int\dfrac{\sin\alpha(r-p\cos\alpha)dp}{(1+p^{2}\sin^{2}\alpha)\sqrt{1+p^{2}+r^{2}-2pr\cos\alpha}}=\arctan\dfrac{pr\sin\alpha+\cot\alpha}{\sqrt{1+p^{2}+r^{2}-2pr\cos\alpha}}+C.$

###### Proof

The easy way is to differentiate $\arctan\omega$ for
$\omega=\dfrac{pr\sin^{2}\alpha+\cos\alpha}{\sin\alpha\sqrt{1+p^{2}+r^{2}-2pr\cos\alpha}}$
with respect to the variable $p$ remembering that $r,\alpha$ are fixed
parameters. For notational clarity, we use an auxiliary symbol for the
expression under the square root: $R=1+p^{2}+r^{2}-2pr\cos\alpha$. Then
$\omega=\dfrac{pr\sin^{2}\alpha+\cos\alpha}{\sin\alpha\sqrt{R}}$ and

$\dfrac{d\omega}{dp}=\dfrac{1}{R\sin\alpha}\left(r\sin^{2}\alpha\sqrt{R}-(rp\sin^{2}\alpha+\cos\alpha)\dfrac{2p-2r\cos\alpha}{2\sqrt{R}}\right)=$
$=\dfrac{1}{R\sqrt{R}\sin\alpha}\Big{(}r\sin^{2}\alpha(1+p^{2}+r^{2}-2pr\cos\alpha)-(rp\sin^{2}\alpha+\cos\alpha)(p-r\cos\alpha)\Big{)}=$
$\dfrac{rp^{2}\sin^{2}\alpha+r^{3}\sin^{2}\alpha-2pr^{2}\cos\alpha\sin^{2}\alpha-
rp^{2}\sin^{2}\alpha+pr^{2}\cos\alpha\sin^{2}\alpha-p\cos\alpha+r}{R\sqrt{R}\sin\alpha}$
$=\dfrac{r^{3}\sin^{2}\alpha-
pr^{2}\cos\alpha\sin^{2}\alpha-p\cos\alpha+r}{R\sqrt{R}\sin\alpha}=\dfrac{(r-p\cos\alpha)(1+r^{2}\sin^{2}\alpha)}{R\sqrt{R}\sin\alpha}.$
$\dfrac{d}{dp}\arctan\omega=\dfrac{1}{1+\omega^{2}}\cdot\dfrac{d\omega}{dp}=\dfrac{(\sin\alpha\sqrt{R})^{2}}{(\sin\alpha\sqrt{R})^{2}+(pr\sin^{2}\alpha+\cos\alpha)^{2}}\cdot\dfrac{d\omega}{dp}=$
$=\dfrac{R\sin^{2}\alpha}{R\sin^{2}\alpha+(p^{2}r^{2}\sin^{4}\alpha+2pr\sin^{2}\alpha\cos\alpha+\cos^{2}\alpha)}\cdot\dfrac{(r-p\cos\alpha)(1+r^{2}\sin^{2}\alpha)}{R\sqrt{R}\sin\alpha}=$
$=\dfrac{\sin\alpha}{\sqrt{R}}\cdot\dfrac{(r-p\cos\alpha)(1+r^{2}\sin^{2}\alpha)}{\sin^{2}\alpha(1+p^{2}+r^{2}-2pr\cos\alpha)+(p^{2}r^{2}\sin^{4}\alpha+2pr\sin^{2}\alpha\cos\alpha+\cos^{2}\alpha)}=$
$=\dfrac{\sin\alpha(r-p\cos\alpha)(1+r^{2}\sin^{2}\alpha)}{(1+p^{2}\sin^{2}\alpha+r^{2}\sin^{2}\alpha+p^{2}r^{2}\sin^{4}\alpha)\sqrt{R}}=\dfrac{\sin\alpha(r-p\cos\alpha)(1+r^{2}\sin^{2}\alpha)}{(1+p^{2}\sin^{2}\alpha)(1+r^{2}\sin^{2}\alpha)\sqrt{R}}=$
$=\dfrac{\sin\alpha(r-p\cos\alpha)}{(1+p^{2}\sin^{2}\alpha)\sqrt{R}}=\dfrac{\sin\alpha(r-p\cos\alpha)}{(1+p^{2}\sin^{2}\alpha)\sqrt{1+p^{2}+q^{2}-2pq\cos\alpha}}.$

Since we got the required expression under the integral $I(r)$, 11 is proved.
$\blacksquare$

######  Proof (Theorem 8)

Consider the right hand side of the equation in 11 as the 3-variable function
$F(p,r;\alpha)=\arctan\left(\dfrac{pr\sin^{2}\alpha+\cos\alpha}{\sqrt{1+p^{2}+r^{2}-2pr\cos\alpha}}\right)$.
The function in 10 is $I(r)=F(b_{1}/d,r;\alpha)-F(a_{1}/d,r;\alpha)$. By 10
$\mathrm{lk}(L_{1},L_{2})=$

$\dfrac{\Big{(}F(b_{1}/d,a_{2}/d;\alpha)-F(a_{1}/d,a_{2}/d;\alpha)\Big{)}-\Big{(}F(b_{1}/d,b_{2}/d;\alpha)-F(a_{1}/d,b_{2}/d;\alpha)\Big{)}}{4\pi}.$

Rewrite a typical function from the numerator above as follows:
$F\left(a/d,b/d;\alpha\right)=$

$\arctan\dfrac{(ab/d^{2})\sin^{2}\alpha+\cos\alpha}{\sqrt{1+(a/d)^{2}+(b/d)^{2}-2(ab/d^{2})\cos\alpha}}=\arctan\dfrac{ab\sin\alpha+d^{2}\cot\alpha}{d\sqrt{a^{2}+b^{2}-2ab\cos\alpha+d^{2}}}.$

If we denote the last expression as $\and(a,b;d,\alpha)$, required formula (8)
follows.

In 9, 10 and above we have used that the signed distance $d$ is positive. By 7
the signed distance $d$ and $\mathrm{lk}(L_{1},L_{2})$ simultaneously change
their signs under a central symmetry, while all other invariants remain the
same. Since $\and(a,b;-d,\alpha)=-\and(a,b;d,\alpha)$ due to the arcsin
function being odd, formula (8) holds for $d<0$. The formula remains valid
even for $d=0$, when $L_{1},L_{2}$ are in the same plane. The expected value
$\mathrm{lk}(L_{1},L_{2})=0$ needs an explicit setting, see the discussion of
the linking number discontinuity around $d=0$ in 14. $\blacksquare$

##  6 The asymptotic behaviour of the linking number of segments

This section discusses how the linking number $\mathrm{lk}(L_{1},L_{2})$ in
Theorem 8 behaves with respect to the six parameters of line segments
$L_{1},L_{2}$. Figure 3 shows how the linking number between two equal line
segments varies with different pairs of parameters.

Figure 3: The linking number $\mathrm{lk}(a,a+l;a,a+l;d,\alpha)$ from formula
(8), where 2 of 4 parameters are fixed. Top left: $l=1$,
$\alpha=\dfrac{\pi}{2}$. Top right: $l=1,d=-1$. Middle left: $a=0$, $d=1$.
Middle right: $a=0$, $l=1$. Bottom left: $a=0$, $\alpha=\dfrac{\pi}{2}$.
Bottom right: $d=-1$, $\alpha=\dfrac{\pi}{2}$.

######  Corollary 12 (bounds of the linking number)

For any line segments $L_{1},L_{2}\subset\mathbb{R}^{3}$, the linking number
$\mathrm{lk}(L_{1},L_{2})$ is between $\pm\dfrac{1}{2}$.

######  Proof (12)

By Theorem 8 $\mathrm{lk}(L_{1},L_{2})$ is a sum of 4 arctan functions divided
by $4\pi$. Since each arctan is strictly between $\pm\dfrac{\pi}{2}$, the
linking number is between $\pm\dfrac{1}{2}$. $\blacksquare$

######  Corollary 13 (sign of the linking number)

In the notation of Definition 4, we have $\lim\limits_{\alpha\to
0}\mathrm{lk}(L_{1},L_{2})=0=\lim\limits_{\alpha\to\pi}\mathrm{lk}(L_{1},L_{2})$.
Any non-parallel $L_{1},L_{2}$ have
$\mathrm{sign}(\mathrm{lk}(L_{1},L_{2}))=-\mathrm{sign}(d)$. So
$\mathrm{lk}(L_{1},L_{2})=0$ if and only if $d=0$ or $\alpha=0$ or
$\alpha=\pi$.

######  Proof (13)

If $\alpha=0$ or $\alpha=\pi$, then $\cot\alpha$ is undefined, so Theorem 8
sets $\and(a,b;d,\alpha)=\mathrm{sign}(d)\dfrac{\pi}{2}$. Then
$\mathrm{lk}(L_{1},L_{2})=\mathrm{sign}(d)\dfrac{\pi}{2}(1+1-1-1)=0$.

Theorem 8 also specifies that $\mathrm{lk}(L_{1},L_{2})=0$ for $d=0$. If
$d\neq 0$ and $\alpha\to 0$ within $[0,\pi]$ while all other parameters remain
fixed, then $d^{2}\cot\alpha\to+\infty$. Hence each of the 4 arctan functions
in Theorem 8 approaches $\dfrac{\pi}{2}$, so $\mathrm{lk}(L_{1},L_{2})\to 0$.
The same conclusion similarly follows in the case $\alpha\to\pi$ when
$d^{2}\cot\alpha\to-\infty$.

If $L_{1},L_{2}$ are not parallel, the angle $\alpha$ between them belongs to
$(0,\pi)$. In $d>0$, 9 says that
$\mathrm{lk}(L_{1},L_{2})=-\dfrac{1}{4\pi}\int\limits_{a_{1}/d}^{b_{1}/d}\;\int\limits_{a_{2}/d}^{b_{2}/d}\dfrac{\sin\alpha\;dp\;dq}{(1+p^{2}+q^{2}-2pq\cos\alpha)^{3/2}}$.
Since the function under the integral is strictly positive,
$\mathrm{lk}(L_{1},L_{2})<0$. By 7 both $\mathrm{lk}(L_{1},L_{2})$
simultaneously change their signs under a central symmetry. Hence the formula
$\mathrm{sign}(\mathrm{lk}(L_{1},L_{2}))=-\mathrm{sign}(d)$ holds for all $d$
including $d=0$ above. $\blacksquare$

######  Corollary 14 (lk for $d\to 0$)

If $d\to 0$ and $L_{1},L_{2}$ remain disjoint, formula (8) is continuous and
$\lim\limits_{d\to 0}\mathrm{lk}(L_{1},L_{2})=0$. If $d\to 0$ and
$L_{1},L_{2}$ intersect each other in the limit case $d=0$, then
$\lim\limits_{d\to 0}\mathrm{lk}(L_{1},L_{2})=-\dfrac{\mathrm{sign}(d)}{2}$,
where $d\to 0$ keeps its sign.

######  Proof (14)

Recall that $\lim\limits_{x\to\pm\infty}\arctan x=\pm\dfrac{\pi}{2}$. By 13
assume that $\alpha\neq 0,\alpha\neq\pi$, so $\alpha\in(0,\pi)$. Then
$\sin\alpha>0$, $a^{2}+b^{2}-2ab\cos\alpha>(a-b)^{2}\geq 0$ and

$\lim\limits_{d\to 0}\and(a,b;d,\alpha)=\lim\limits_{d\to
0}\arctan\left(\dfrac{ab\sin\alpha+d^{2}\cot\alpha}{d\sqrt{a^{2}+b^{2}-2ab\cos\alpha+d^{2}}}\right)=$
$=\mathrm{sign}(a)\mathrm{sign}(b)\mathrm{sign}(d)\dfrac{\pi}{2},\text{so
\lx@cref{creftypecap~refnum}{theorem:lk_arctan} gives }$ $\lim\limits_{d\to
0}\mathrm{lk}(L_{1},L_{2})=\dfrac{\mathrm{sign}(d)}{8}(\mathrm{sign}(a_{1})-\mathrm{sign}(b_{1}))(\mathrm{sign}(b_{2})-\mathrm{sign}(a_{2})).$

In the limit case $d=0$, the line segments $L_{1},L_{2}\subset\\{z=0\\}$
remain disjoint in the same plane if and only if both endpoint coordinates
$a_{i},b_{i}$ have the same sign for at least one of $i=1,2$, which is
equivalent to $\mathrm{sign}(a_{i})-\mathrm{sign}(b_{i})=0$, i.e.
$\lim\limits_{d\to 0}\mathrm{lk}(L_{1},L_{2})=0$ from the product above. Hence
formula (8) is continuous under $d\to 0$ for any non-crossing segments. Any
segments that intersect in the plane $\\{z=0\\}$ when $d=0$ have endpoint
coordinates $a_{i}<0<b_{i}$ for both $i=1,2$ and have the limit
$\lim\limits_{d\to
0}\mathrm{lk}(L_{1},L_{2})=\dfrac{\mathrm{sign}(d)}{8}(-1-1)(1-(-1))=-\dfrac{\mathrm{sign}(d)}{2}$
as required. $\blacksquare$

######  Corollary 15 (lk for $d\to\pm\infty$)

If the distance $d\to\pm\infty$, then $\mathrm{lk}(L_{1},L_{2})\to 0$.

######  Proof (15)

If $d\to\pm\infty$, while other parameters of $L_{1},L_{2}$ remain fixed, then
the function
$\and(a,b;d,\alpha)=\arctan\left(\dfrac{ab\sin\alpha+d^{2}\cot\alpha}{d\sqrt{a^{2}+b^{2}-2ab\cos\alpha+d^{2}}}\right)$
from Theorem 8 has the limit
$\arctan(\mathrm{sign}(d)\cot\alpha)=\mathrm{sign}(d)\left(\dfrac{\pi}{2}-\alpha\right)$.
Since the four AT functions in Theorem 8 include the same $d,\alpha$, their
limits cancel, so $\mathrm{lk}(L_{1},L_{2})\to 0$. $\blacksquare$

######  Corollary 16 (lk for $a_{i},b_{i}\to\infty$)

If the invariants $d,\alpha$ of line segments
$L_{1},L_{2}\subset\mathbb{R}^{3}$ remain fixed, but $a_{i}\to+\infty$ or
$b_{i}\to-\infty$ for each $i=1,2$, then $\mathrm{lk}(L_{1},L_{2})\to 0$.

######  Proof (16)

If $a_{i}\to+\infty$, then $a_{i}\leq b_{i}\to+\infty$, $i=1,2$. If
$b_{i}\to-\infty$, then $b_{i}\geq a_{i}\to-\infty$, $i=1,2$. Consider the
former case $a_{i}\to+\infty$, the latter is similar.

Since $d,\alpha$ are fixed,
$a^{2}+b^{2}-2ab\cos\alpha+d^{2}\leq(a+b)^{2}+d^{2}\leq 5b^{2}$ for large
enough $b$. Since $\arctan(x)$ increases,
$\and(a,b;d,\alpha)\geq\arctan\left(\dfrac{ab\sin\alpha+d^{2}\cot\alpha}{db\sqrt{5}}\right)\to\mathrm{sign}(d)\dfrac{\pi}{2}$
as $b\geq a\to+\infty$. Since the four AT functions in Theorem 8 have the same
limit when their first two arguments tend to $+\infty$, these 4 limits cancel,
so $\mathrm{lk}(L_{1},L_{2})\to 0$. $\blacksquare$

######  Corollary 17 (lk for $a_{i}\to b_{i}$)

If one of segments $L_{1},L_{2}\subset\mathbb{R}^{3}$ becomes infinitely short
so that its final endpoint tends to the fixed initial endpoint (or vice
versa), while all other invariants of $L_{1},L_{2}$ from Definition 4 remain
fixed, then $\mathrm{lk}(L_{1},L_{2})\to 0$.

######  Proof (17)

$\mathrm{lk}(L_{1},L_{2})=0$ for $d=0$. It’s enough to consider the case
$d\neq 0$. Then
$\and(a,b;d,\alpha)=\arctan\left(\dfrac{ab\sin\alpha+d^{2}\cot\alpha}{d\sqrt{a^{2}+b^{2}-2ab\cos\alpha+d^{2}}}\right)$
is continuous. Let (say for $i=1$) $a_{1}\to b_{1}$, the case $b_{1}\to a_{1}$
is similar. The continuity of $\and$ implies that
$\and(a_{1},b_{2};d,\alpha)\to\and(b_{1},b_{2};d,\alpha)$ and
$\and(a_{1},a_{2};d,\alpha)\to\and(b_{1},a_{2};d,\alpha)$. In the limit all
terms in Theorem 8 cancel, hence $\mathrm{lk}(L_{1},L_{2})\to 0$.
$\blacksquare$

##  7 Example computations of the linking number and a discussion

If curves $\gamma_{1},\gamma_{2}\subset\mathbb{R}^{3}$ consist of straight
line segments, then $\mathrm{lk}(\gamma_{1},\gamma_{2})$ can be computed as
the sum of $\mathrm{lk}(L_{1},L_{2})$ over all line segments
$L_{1}\subset\gamma_{1}$ and $L_{2}\subset\gamma_{2}$.

Figure 4: 1st: The Hopf link as two square cycles has $\mathrm{lk}=-1$ and
vertices with coordinates $L_{1}=(-2,0,2),(2,0,-2),(2,0,2),(-2,0,2)$,
$L_{2}=(-1,-2,0),(-1,2,0),(1,2,0),(1,-2,0)$ 2nd: The Hopf link of triangular
cycles has $\mathrm{lk}=+1$, $L_{1}=(-1,0,-1),(-1,0,1),(1,0,0)$ and
$L_{2}=(0,0,0),(2,1,0),(2,-1,0)$. 3rd: Solomon’s link has $\mathrm{lk}=+2$,
$L_{1}=(-1,1,1),(-1,-1,1),(3,-1,1),(3,1,-1),(1,1,-1),(1,1,1)$ and
$L_{2}=(-1,-2,0),(-1,2,0),(1,2,0),(1,-2,0)$. 4th: Whitehead’s link has
$\mathrm{lk}=0$, $L_{1}=$
$(-3,-2,-1),(0,-2,-1),(0,2,1),(0,0,1),(0,0,0),(3,0,0),(3,1,0),(-3,1,0),(-3,1,-1)$
and $L_{2}=(-1,0,-3),(-1,0,3),(1,0,3),(-1,0,3)$.

Figure 4 shows polygonal links whose linking numbers were computed by our
Python code implementing formula (8) at
https://github.com/MattB-242/Closed_Lk_Form. For all links in in Fig 4 formula
8 calculates the linking number between the two components correctly (as equal
to $-1$ and $+1$ respectively in the orientations given in Fig 4), with a
computation error of less than $10^{-12}$.

The asymptotic linking number introduced by Arnold converges for infinitely
long curves vogel2003asymptotic , while our initial motivation was a
computation of geometric and topology invariants to classify periodic
structures such as textiles bright2020encoding  and crystals cui2019mining .

Theorem 8 allows us to compute the _periodic_ linking number between a segment
$J$ and a growing finite lattice $L_{n}$ whose unit cell consists of $n$
copies of two oppositely oriented segments orthogonal to $J$. This periodic
linking number is computed for increasing $n$ in a lattice extending
periodically in one, two and three directions, see Figure 5. As $n$ increases,
the $\mathrm{lk}$ function asymptotically approaches an approximate value of
$0.30$ for 1- and 3-periodic lattice and $0.29$ for the 2-periodic lattice.

The invariant-based formula has allowed us to prove new asymptotic results of
the linking number in Corollaries 12-17 of section 6. Since the periodic
linking number is a real-valued invariant modulo isometries, it can be used to
continuously quantify similarities between periodic crystalline networks
cui2019mining . One next possible step is to use formula (8) to prove
asymptotic convergence of the periodic linking number for arbitrary lattices,
so that we can show that the limit of the infinite sum is a general invariant
that can be used to develop descriptors of crystal structures.

The Milnor invariants generalise the linking number to invariants of links
with more than two components. An integral for the three component Milnor
invariant deturck2011  may be possible to compute in a closed form similarly
to Theorem 8. The interesting open problem is to extend the isometry-based
approach to finer invariants of knots.

The Gauss integral in (1) was extended to the infinite Kontsevich integral
containing all finite-type or Vassiliev’s invariants of knots kontsevich1993 .
The coefficients of this infinite series were explicitly described
kurlin2005compressed  as solutions of exponential equations with non-
commutative variables $x,y$ in a compressed form modulo commutators of
commutators in $x,y$. The underlying metabelian formula for $\ln(e^{x}e^{y})$
has found an easier proof kurlin2007baker  in the form of a generating series
in the variables $x,y$.

In conclusion, we have proved the analytic formula for the linking number
based on 6 isometry invariants that uniquely determine a relative position of
two line segments in $\mathbb{R}^{3}$. Though a similar formula was claimed in
klenin2000computation , no proof was given. Hence this paper fills an
important gap in the literature by completing the proof via 3 non-trivial
lemmas in section 5, see detailed computations in the arxiv version of this
paper.

Figure 5: Left: the line segment $J=(0,0,-1)+t(0,0,2)$ in red and the periodic
lattice $L(n^{k})$ derived from $n$ copies of the ’unit cell’
$L=\\{(-1,-1,0)+t(0,2,0),(-1,1,0)+s(0,-2,0)\\}$, $t,s\in[0,1]$, translated in
$k$ linearly independent directions for increasing $n\in\mathbb{Z}$. Right:
the periodic linking number $\mathrm{lk}(J,L(n^{k}))$ is converging fast for
$n\to+\infty$. Top: $k=1$. Middle: $k=2$. Bottom: $k=3$.

##  8 Acknowledgements

This work was supported by the UK Engineering and Physical Sciences Research
Council under the grant “Application-driven Topological Data Analysis”,
EP/R018472/1. We thank the organisers of NUMGRID2020 for the opportunity to
present the results.

## References

  * (1) Rasool Ahmad, Saptarshi Paul, and Sumit Basu.  Characterization of entanglements in glassy polymeric ensembles using the gaussian linking number.  Phys. Rev. E, 101(2):022503, 2020.
  * (2) Zin Arai.  A rigorous numerical algorithm for computing the linking number of links.  Nonlinear Theory and Its Applications, 4(1):104–110, 2013.
  * (3) T Banchoff.  Self-linking numbers of space polygons.  Indiana U. Math. J, 25:1171–1188, 1976.
  * (4) Enrico Bertolazzi, Riccardo Ghiloni, and Ruben Specogna.  Efficient computation of linking number with certification.  arXiv:1912.13121, 2019.
  * (5) M Bright and V Kurlin.  Encoding and topological computation on textile structures.  Computers and Graphics, 90:51–61, 2020.
  * (6) Matt Bright, Vitaliy Kurlin, and Olga Anosova.  A proof of the invariant based formula for the linking number and its extremal behaviour.  arXiv:2011.04631, 2020.
  * (7) P Cui, D McMahon, P Spackman, B Alston, M Little, G Day, and A Cooper.  Mining predicted crystal structure landscapes with high throughput crystallisation: old molecules, new insights.  Chemical Science, 10:9988–9997, 2019.
  * (8) D. DeTurck, H. Gluck, R. Komendarczyk, P. Melvin, C. Shonkwiler, and D. Vela-Vick.  Pontryagin invariants and integral formulas for milnor’s triple linking number.  arXiv:1101.3374.
  * (9) Carl Friedrich Gauss.  Integral formula for linking number.  Zur mathematischen theorie der electrodynamische wirkungen, Collected Works, 5:605, 1833.
  * (10) Konstantin Klenin and Jörg Langowski.  Computation of writhe in modeling of supercoiled dna.  Biopolymers: Original Research on Biomolecules, 54(5):307–317, 2000\.
  * (11) M. Kontsevich.  Vassiliev’s knot invariants.  Adv. Soviet Mathematics, 16:137 – 150, 1993.
  * (12) V Kurlin.  Compressed Drinfeld associators.  Journal of Algebra, 292:184–242, 2005.
  * (13) V Kurlin.  The Baker-Campbell-Hausdorff formula in the free metabelian lie algebra.  Journal of Lie Theory, 17(3):525–538, 2007.
  * (14) James Clerk Maxwell.  A treatise on electricity and magnetism.  I, 1873.
  * (15) E Panagiotou.  The linking number in systems with periodic boundary conditions.  J Computational Physics, 300:533–573, 2015.
  * (16) Eleni Panagiotou and Louis H Kauffman.  Knot polynomials of open and closed curves.  Proceedings Royal Society A. 476: 20200124, arxiv:2001.01303, 2020\.
  * (17) Renzo L Ricca and Bernardo Nipoti.  Gauss’ linking number revisited.  Journal of Knot Theory and Its Ramifications, 20(10):1325–1343, 2011.
  * (18) T Vogel.  On the asymptotic linking number.  Proc.Amer. Math. Soc., 131:2289–2297, 2003.
  * (19) A.V. Vologodskii, V. V. Anshelevich, A.V. Lukashin, and M. D. Frank-Kamenetskii.  Statistical mechanics of supercoils and the torsional stiffness of the dna double helix.  Nature, 280(5720):294–298, 1974.