# Find Pattern of Numbers

I need some help figuring out a pattern. I have a set of numbers that are dependent on four variables i,j,k, and l. The combination of variables in one set leads to different values in another set. The pattern is shown below.

Rows change in old:

  Old     New
(1,1) = (1,1) i = 1, j = 1 , k = 1, l = 1
(2,1) = (1,3) i = 1, j = 1 , k = 1, l = 2
(3,1) = (1,5) i = 1, j = 1 , k = 1, l = 3
(4,1) = (1,7) i = 1, j = 1 , k = 1, l = 4
(5,1) = (1,9) i = 1, j = 1 , k = 1, l = 5


Columns change in old:

  Old     New
(1,1) = (1,1) i = 1, j = 1 , k = 1, l = 1
(1,2) = (1,2) i = 1, j = 1 , k = 2, l = 1
(1,3) = (2,1) i = 1, j = 2 , k = 1, l = 1
(1,4) = (2,2) i = 1, j = 2 , k = 2, l = 1
(1,5) = (3,1) i = 2, j = 1 , k = 1, l = 1
(1,6) = (3,2) i = 2, j = 1 , k = 2, l = 1
(1,7) = (4,1) i = 2, j = 2 , k = 1, l = 1
(1,8) = (4,2) i = 2, j = 2 , k = 2, l = 1


The old set is determined as (l,2(j+2*i-3) + k).

What I need to know is if Old(a,b) = New(a',b'), then what is a',b' in terms of i,j,k,and l? Thanks.

The application of this is I'm forming a matrix. It started out as,

                              Columns
i = 1  i = 1  i = 1  i = 1  i = 2  i = 2  i = 2  i = 2 ...
j = 1  j = 1  j = 2  j = 2  j = 1  j = 1  j = 2  j = 2 ...
k = 1  k = 2  k = 1  k = 2  k = 1  k = 2  k = 1  k = 2 ...
l = 1
l = 2
.
.
.


Now I need to change it to this,

                               Columns
l = 1  l = 1  l = 2  l = 2  l = 1  l = 1  l = 2  l = 2 ...
k = 1  k = 2  k = 1  k = 2  k = 1  k = 2  k = 1  k = 2 ...
i = 1  j = 1
i = 1  j = 2
i = 2  j = 1
i = 2  j = 2
.
.
.


In the first case 'Rows change in old' we observe : $$(l,1)\mapsto (1,2\,l-1)\quad \text{for}\ i=j=k=1$$ While for 'Columns change in old' we may have :

$$(1,\,2(2\,i+j-3) + k)\mapsto (2\,i+j-2,\;k)$$

Combining these you may (for example) have :

$$(l,\,2(2\,i+j-3) + k)\mapsto (2\,i+j-2,\;2\,l-2+k)$$ (more information may be useful !)

An easier way to see this : consider $(i,j,k)$ as $3$ bits $\,e:=4i+2j+k-7\,$ then : $$(l,\,e+1)\mapsto (e/2+1,\;2\,l-1+(e\bmod 2))$$ so that if old is $(a,b)=(l,e+1)$ we get (with $x/2$ the integer quotient i.e. 'right shift') : $$(a,\,b)\mapsto ((b+1)/2,\,2\,a-1+((b-1)\bmod 2))$$ ($a=l,\; b= 4i+2j+k-6\$ I think...)

• I added the application of this to my post. This is to have an idea of what I'm trying to do. – Grady F. Mathews Iv Aug 5 '13 at 19:02
• @GradyF.MathewsIv: I updated my answer with $(a,b)$. Can you verify this? – Raymond Manzoni Aug 5 '13 at 19:11
• I think the answer is New(2*(i-1)+j,2*l+k-1) = Old(l,2*(j+2*i-3)+k), and I'm working to verify this. I'll compare with your answer. – Grady F. Mathews Iv Aug 5 '13 at 19:15
• @GradyF.MathewsIv: this corresponds to my third (combined) line except the $b$ of New (your $2*l+k-1$ compared to my $2l-2+k$). – Raymond Manzoni Aug 5 '13 at 19:26
• Yeah I just noticed that, it should be -2. – Grady F. Mathews Iv Aug 5 '13 at 19:29

## Hint

Assume your map $\phi : (a,b,i,j,k,l) \mapsto (a',b')$ is componentwise linear in $a,b,i,j,k$ and $l$ i.e. $$\phi_{a'} : (a,b,i,j,k,l) \mapsto a' = \alpha_1a +\alpha_2b+\alpha_3i+\alpha_4j+\alpha_5k$$ $$\phi_{b'} : (a,b,i,j,k,l) \mapsto b' = \beta_1a +\beta_2b+\beta_3i+\beta_4j+\beta_5k$$ now form an equation system of $\geq 10$ equations and solve for $\alpha_i, \beta_i\ i=1..5$.

Hint: Assuming your original dimensions are 5x8 in matrix notation (only requirement is even number of columns). You represent each 1x2 block as a cell, making your structure 5x4 of these cells. You're taking the transpose of this structure and resulting in 4x5 cells. Unfolding the cells you'll get 4x10 matrix.