article

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

Any pairing function can be used in set theory to prove that integers and rational numbers have the same cardinality as natural numbers. In theoretical computer science they are used to encode a function defined on a vector of natural numbers f:NkN into a new function g:NN.

Definition


A pairing function is a bijective function
\pi:\mathbb{N} \times \mathbb{N} \to \mathbb{N}.

Cantor pairing function


The Cantor pairing function is a pairing function

\pi:\mathbb{N} \times \mathbb{N} \to \mathbb{N}
defined by
\pi(k_1,k_2) := \frac{1}{2}(k_1 + k_2)(k_1 + k_2 + 1)+k_2.

When we apply the pairing function to k_1 and k_2 we often denote the resulting number as \langle k_1, k_2 \rangle

This definition can be inductively generalized to the Cantor tuple function

\pi^{(n)}:\mathbb{N}^n \to \mathbb{N}
as
\pi^{(n)}(k_1, \ldots, k_{n-1}, k_n) := \pi ( \pi^{(n-1)}(k_1, \ldots, k_{n-1}) , k_n)

External link


Set theory

Cantorsche Paarungsfunktion | Funzione coppia | 配对函数

 

This article is licensed under the GNU Free Documentation License. It uses material from the "Pairing function".

Home Pageartsbusinesscomputersgameshealthhospitalshomekids & teensnewsphysiciansrecreationreferenceregionalscienceshoppingsocietysportsworld