Pairing function

Last updated

In mathematics, a pairing function is a process to uniquely encode two natural numbers into a single natural number. [1]

Contents

Any pairing function can be used in set theory to prove that integers and rational numbers have the same cardinality as natural numbers. [1]

Definition

A pairing function is a bijection [ verification needed ]

[1]

More generally, a pairing function on a set A is a function that maps each pair of elements from A into an element of A, such that any two pairs of elements of A are associated with different elements of A, [2] or a bijection from to A. [3]

Hopcroft and Ullman pairing function

Hopcroft and Ullman (1979) define the following pairing function: , where . [1] This is the same as the Cantor pairing function below, shifted to exclude 0 (i.e., , , and ).

Cantor pairing function

The Cantor pairing function assigns one natural number to each pair of natural numbers Cantor's Pairing Function.svg
The Cantor pairing function assigns one natural number to each pair of natural numbers
Graph of the Cantor pairing function Cantor's Pairing Function Plot.svg
Graph of the Cantor pairing function

The Cantor pairing function is a primitive recursive pairing function

defined by

[1] [ verification needed ]

where . [1]

It can also be expressed as . [2]

It is also strictly monotonic w.r.t. each argument, that is, for all , if , then ; similarly, if , then .[ citation needed ]

The statement that this is the only quadratic pairing function is known as the Fueter–Pólya theorem. [1] [ verification needed ] Whether this is the only polynomial pairing function is still an open question. When we apply the pairing function to k1 and k2 we often denote the resulting number as k1, k2.[ citation needed ]

This definition can be inductively generalized to the Cantor tuple function[ citation needed ]

for as

with the base case defined above for a pair: [1]

Inverting the Cantor pairing function

Let be an arbitrary natural number. We will show that there exist unique values such that

and hence that the function π(x, y) is invertible. It is helpful to define some intermediate values in the calculation:

where t is the triangle number of w. If we solve the quadratic equation

for w as a function of t, we get

which is a strictly increasing and continuous function when t is non-negative real. Since

we get that

and thus

where ⌊ ⌋ is the floor function. So to calculate x and y from z, we do:

Since the Cantor pairing function is invertible, it must be one-to-one and onto. [2] [ additional citation(s) needed ]

Examples

To calculate π(47, 32):

47 + 32 = 79,
79 + 1 = 80,
79 × 80 = 6320,
6320 ÷ 2 = 3160,
3160 + 32 = 3192,

so π(47, 32) = 3192.

To find x and y such that π(x, y) = 1432:

8 × 1432 = 11456,
11456 + 1 = 11457,
11457 = 107.037,
107.037 − 1 = 106.037,
106.037 ÷ 2 = 53.019,
⌊53.019⌋ = 53,

so w = 53;

53 + 1 = 54,
53 × 54 = 2862,
2862 ÷ 2 = 1431,

so t = 1431;

1432 − 1431 = 1,

so y = 1;

53 − 1 = 52,

so x = 52; thus π(52, 1) = 1432.[ citation needed ]

Derivation

A diagonally incrementing "snaking" function, from same principles as Cantor's pairing function, is often used to demonstrate the countability of the rational numbers. Diagonal argument.svg
A diagonally incrementing "snaking" function, from same principles as Cantor's pairing function, is often used to demonstrate the countability of the rational numbers.

The graphical shape of Cantor's pairing function, a diagonal progression, is a standard trick in working with infinite sequences and countability. [lower-alpha 1] The algebraic rules of this diagonal-shaped function can verify its validity for a range of polynomials, of which a quadratic will turn out to be the simplest, using the method of induction. Indeed, this same technique can also be followed to try and derive any number of other functions for any variety of schemes for enumerating the plane.

A pairing function can usually be defined inductively – that is, given the nth pair, what is the (n+1)th pair? The way Cantor's function progresses diagonally across the plane can be expressed as

.

The function must also define what to do when it hits the boundaries of the 1st quadrant – Cantor's pairing function resets back to the x-axis to resume its diagonal progression one step further out, or algebraically:

.

Also we need to define the starting point, what will be the initial step in our induction method: π(0, 0) = 0.

Assume that there is a quadratic 2-dimensional polynomial that can fit these conditions (if there were not, one could just repeat by trying a higher-degree polynomial). The general form is then

.

Plug in our initial and boundary conditions to get f = 0 and:

,

so we can match our k terms to get

b = a
d = 1-a
e = 1+a.

So every parameter can be written in terms of a except for c, and we have a final equation, our diagonal step, that will relate them:

Expand and match terms again to get fixed values for a and c, and thus all parameters:

a = 1/2 = b = d
c = 1
e = 3/2
f = 0.

Therefore

is the Cantor pairing function, and we also demonstrated through the derivation that this satisfies all the conditions of induction.[ citation needed ]

Other pairing functions

The function is a pairing function.

In 1990, Regan proposed the first known pairing function that is computable in linear time and with constant space (as the previously known examples can only be computed in linear time iff multiplication can be too, which is doubtful). [4] In fact, both this pairing function and its inverse can be computed with finite-state transducers that run in real time. [4] [ clarification needed ] In the same paper, the author proposed two more monotone pairing functions that can be computed online in linear time and with logarithmic space; the first can also be computed offline with zero space. [4] [ clarification needed ]

In 2001, Pigeon proposed a pairing function based on bit-interleaving, defined recursively as:

where and are the least significant bits of i and j respectively. [1] [ verification needed ]

In 2006, Szudzik proposed a "more elegant" pairing function defined by the expression:

Which can be unpaired using the expression:

(Qualitatively, it assigns consecutive numbers to pairs along the edges of squares.) This pairing function orders SK combinator calculus expressions by depth. [2] [ clarification needed ] This method is the mere application to of the idea, found in most textbooks on Set Theory, [5] used to establish for any infinite cardinal in ZFC. Define on the binary relation

is then shown to be a well-ordering such that every element has predecessors, which implies that . It follows that is isomorphic to and the pairing function above is nothing more than the enumeration of integer couples in increasing order. (See also Talk:Tarski's theorem about choice#Proof of the converse.)

Notes

  1. The term "diagonal argument" is sometimes used to refer to this type of enumeration, but it is not directly related to Cantor's diagonal argument.[ citation needed ]

Related Research Articles

<span class="mw-page-title-main">Arithmetic–geometric mean</span> Mathematical function of two positive real arguments

In mathematics, the arithmetic–geometric mean of two positive real numbers x and y is the mutual limit of a sequence of arithmetic means and a sequence of geometric means:

<span class="mw-page-title-main">Floor and ceiling functions</span> Nearest integers from a number

In mathematics, the floor function (or greatest integer function) is the function that takes as input a real number x, and gives as output the greatest integer less than or equal to x, denoted x or floor(x). Similarly, the ceiling function maps x to the smallest integer greater than or equal to x, denoted x or ceil(x).

In mathematics, the Hermite polynomials are a classical orthogonal polynomial sequence.

<span class="mw-page-title-main">Spherical harmonics</span> Special mathematical functions defined on the surface of a sphere

In mathematics and physical science, spherical harmonics are special functions defined on the surface of a sphere. They are often employed in solving partial differential equations in many scientific fields. A list of the spherical harmonics is available in Table of spherical harmonics.

<span class="mw-page-title-main">Prime-counting function</span> Function representing the number of primes less than or equal to a given number

In mathematics, the prime-counting function is the function counting the number of prime numbers less than or equal to some real number x. It is denoted by π(x) (unrelated to the number π).

In probability theory and statistics, the cumulantsκn of a probability distribution are a set of quantities that provide an alternative to the moments of the distribution. Any two probability distributions whose moments are identical will have identical cumulants as well, and vice versa.

<span class="mw-page-title-main">Inverse trigonometric functions</span> Inverse functions of sin, cos, tan, etc.

In mathematics, the inverse trigonometric functions are the inverse functions of the trigonometric functions. Specifically, they are the inverses of the sine, cosine, tangent, cotangent, secant, and cosecant functions, and are used to obtain an angle from any of the angle's trigonometric ratios. Inverse trigonometric functions are widely used in engineering, navigation, physics, and geometry.

<span class="mw-page-title-main">Sign function</span> Mathematical function returning -1, 0 or 1

In mathematics, the sign function or signum function is a function that returns the sign of a real number. In mathematical notation the sign function is often represented as .

<span class="mw-page-title-main">Eisenstein integer</span> Complex number whose mapping on a coordinate plane produces a triangular lattice

In mathematics, the Eisenstein integers, occasionally also known as Eulerian integers, are the complex numbers of the form

Euclid's theorem is a fundamental statement in number theory that asserts that there are infinitely many prime numbers. It was first proven by Euclid in his work Elements. There are several proofs of the theorem.

<span class="mw-page-title-main">Lemniscate elliptic functions</span> Mathematical functions

In mathematics, the lemniscate elliptic functions are elliptic functions related to the arc length of the lemniscate of Bernoulli. They were first studied by Giulio Fagnano in 1718 and later by Leonhard Euler and Carl Friedrich Gauss, among others.

In mathematics, a Beatty sequence is the sequence of integers found by taking the floor of the positive multiples of a positive irrational number. Beatty sequences are named after Samuel Beatty, who wrote about them in 1926.

In the 1760s, Johann Heinrich Lambert was the first to prove that the number π is irrational, meaning it cannot be expressed as a fraction , where and are both integers. In the 19th century, Charles Hermite found a proof that requires no prerequisite knowledge beyond basic calculus. Three simplifications of Hermite's proof are due to Mary Cartwright, Ivan Niven, and Nicolas Bourbaki. Another proof, which is a simplification of Lambert's proof, is due to Miklós Laczkovich. Many of these are proofs by contradiction.

<span class="mw-page-title-main">Conway–Maxwell–Poisson distribution</span> Probability distribution

In probability theory and statistics, the Conway–Maxwell–Poisson distribution is a discrete probability distribution named after Richard W. Conway, William L. Maxwell, and Siméon Denis Poisson that generalizes the Poisson distribution by adding a parameter to model overdispersion and underdispersion. It is a member of the exponential family, has the Poisson distribution and geometric distribution as special cases and the Bernoulli distribution as a limiting case.

<span class="mw-page-title-main">Struve function</span>

In mathematics, the Struve functionsHα(x), are solutions y(x) of the non-homogeneous Bessel's differential equation:

<span class="mw-page-title-main">Wrapped asymmetric Laplace distribution</span>

In probability theory and directional statistics, a wrapped asymmetric Laplace distribution is a wrapped probability distribution that results from the "wrapping" of the asymmetric Laplace distribution around the unit circle. For the symmetric case (asymmetry parameter κ = 1), the distribution becomes a wrapped Laplace distribution. The distribution of the ratio of two circular variates (Z) from two different wrapped exponential distributions will have a wrapped asymmetric Laplace distribution. These distributions find application in stochastic modelling of financial data.

In statistics, the complex Wishart distribution is a complex version of the Wishart distribution. It is the distribution of times the sample Hermitian covariance matrix of zero-mean independent Gaussian random variables. It has support for Hermitian positive definite matrices.

In mathematics, Zolotarev polynomials are polynomials used in approximation theory. They are sometimes used as an alternative to the Chebyshev polynomials where accuracy of approximation near the origin is of less importance. Zolotarev polynomials differ from the Chebyshev polynomials in that two of the coefficients are fixed in advance rather than allowed to take on any value. The Chebyshev polynomials of the first kind are a special case of Zolotarev polynomials. These polynomials were introduced by Russian mathematician Yegor Ivanovich Zolotarev in 1868.

Kaniadakis statistics is a generalization of Boltzmann–Gibbs statistical mechanics, based on a relativistic generalization of the classical Boltzmann–Gibbs–Shannon entropy. Introduced by the Greek Italian physicist Giorgio Kaniadakis in 2001, κ-statistical mechanics preserve the main features of ordinary statistical mechanics and have attracted the interest of many researchers in recent years. The κ-distribution is currently considered one of the most viable candidates for explaining complex physical, natural or artificial systems involving power-law tailed statistical distributions. Kaniadakis statistics have been adopted successfully in the description of a variety of systems in the fields of cosmology, astrophysics, condensed matter, quantum physics, seismology, genomics, economics, epidemiology, and many others.

In algebra, a Landau-Mignotte bound (sometimes only referred to as Mignotte's bound) is one of a family of inequalities concerning a univariate integer polynomial f(x) and one of its factors h(x). A basic version states that the coefficients of h(x) are bounded independently of h(x) by an exponential expression involving only the degree and coefficients of f(x), i.e. only depending on f(x).

References

  1. 1 2 3 4 5 6 7 8 9 Steven Pigeon. "Pairing function". MathWorld . Retrieved 16 August 2021.
  2. 1 2 3 4 Szudzik, Matthew (2006). "An Elegant Pairing Function" (PDF). szudzik.com. Archived (PDF) from the original on 25 November 2011. Retrieved 16 August 2021.
  3. Szudzik, Matthew P. (2017-06-01). "The Rosenberg-Strong Pairing Function". arXiv: 1706.04129 [cs.DM].
  4. 1 2 3 Regan, Kenneth W. (1992-12-01). "Minimum-complexity pairing functions". Journal of Computer and System Sciences. 45 (3): 285–295. doi: 10.1016/0022-0000(92)90027-G . ISSN   0022-0000.
  5. See for instance Thomas, Jech (2006). Set theory: the third millennium edition. Springer Monographs in Mathematics. Springer-Verlag. p. 30. doi:10.1007/3-540-44761-X. ISBN   3-540-44085-2.