Ordering: Difference between revisions

From David's Wiki
Line 15: Line 15:


This is a bijection to Figure 2 where y is shifted by x and the matrix is flipped upside down:   
This is a bijection to Figure 2 where y is shifted by x and the matrix is flipped upside down:   
Figure 2:
<math>
<math>
\begin{bmatrix}
\begin{bmatrix}

Revision as of 18:26, 26 May 2020

Related to counting, countabiliy

Diagonal

The goal is to get formulas for the following:

Figure 1: \(\displaystyle \begin{bmatrix} 0 & 2& 5& 9&\\ 1 & 4& 8& &\\ 3 & 7& & &\\ 6 & & & &\\ \end{bmatrix} \)

This is a bijection to Figure 2 where y is shifted by x and the matrix is flipped upside down:

Figure 2: \(\displaystyle \begin{bmatrix} & & & &\\ & & 5& &\\ & 2& 4& &\\ 0 & 1 & 3& ... &\\ \end{bmatrix} \)

The is a 1-1 mapping \(\displaystyle \mathbb{Z}^2 \to \mathbb{Z}\).

We first derive the function from \(\displaystyle \mathbb{Z}^2\) to \(\displaystyle \mathbb{z}\) as shown in Figure 2. Let \(\displaystyle (x,y)\) be the coordinates in \(\displaystyle \{(0,0), (1, 0), (1,1), ...\}\) which will map to \(\displaystyle \({0, 1, 2, ...\}\).
First note that \(\displaystyle \sum_{0}^{k}i = \frac{(k)(k+1)}{2}\). Thus the number of elements in columns \(\displaystyle 0, ..., x-1\) is \(\displaystyle (x)(x+1)/2\).
Thus our formula is \(\displaystyle z = \frac{x(x+1)}{2} + y\)

To calculate the inverse formula:
Given an integer \(\displaystyle z\), we want to find \(\displaystyle (x, y)\)

The formula is figure 1 is as follows: