Looking far a formula giving the coordinates $(x,y)$ at a given instant of a point traversing $\mathbb{N}^2$ in a layered way

67 Views Asked by At

We are observing a point in a two-dimensional Cartesian coordinate system which, at the initial time, is at the origin (0,0) ; one second later, the point moves to coordinate (0,1), and another second later, the point moves to coordinate (1,1), etc. The dataset that describes this movement is as follows:

instant 0: (0,0)
instant 1: (0,1)
instant 2: (1,1)
instant 3: (1,0)
instant 4: (2,0)
instant 5: (2,1)
instant 6: (2,2)
instant 7: (1,2)
instant 8: (0,2)
instant 9: (0,3)
instant 10: (1,3)
instant 11: (2,3)
instant 12: (3,3)
instant 13: (3,2)
instant 14: (3,1)
instant 15: (3,0)
instant 16: (4,0)
instant 17: (4,1)
instant 18: (4,2)
instant 19: (4,3)
instant 20: (4,4)
instant 21: (3,4)
instant 22: (2,4)
instant 23: (1,4)
instant 24: (0,4)
instant 25: (0,5)
instant 26: (1,5)
instant 27: (2,5)
instant 28: (3,5)
instant 29: (4,5)
...

and so on. According to the dataset, could someone help find me an equation that gives coordinates for a given instant

I know I can solve this with the following graph

enter image description here

layer1: 1+1+1 = 3
layer2: 2+2+1+3 = 8
layer3: 3+3+1+8 = 15
layer4: 4+4+1+15 = 24
layer5: 5+5+1+24 = 35
layer6: 6+6+1+35 = 48
layer7: 7+7+1+48 = 63

How can I describe the problem and solution in a professional way?

1

There are 1 best solutions below

0
On BEST ANSWER

enter image description here

In order that this question doesn't remain without answer, here is a Matlab program implementing formula $(x,y)\mapsto $t=t_{x,y}$.

$$t_{x,y}=m(m+1)+(y-x)(-1)^{\operatorname{mod}(m,2)} \ \text{where} \ m=\max(x,y)$$

that one can find in the OEIS item A319514 mentionned by @peterwhy :

 clear all;close all;hold on;axis off equal
 n=12;T=zeros(n);
 for x=0:n
    for y=0:n
       m=max(x,y);
       u=m*(m+1)+(y-x)*(-1)^(mod(m,2));
       T(x+1,y+1)=u;
       text(x+1,y+1,num2str(u),...
       'horizontalalignment','center'),
    end
  end

The reciprocal function, $t \mapsto (x,y)$ given by @durianice here can be implemented like this :

 clear all;close all;hold on;
 f=@(x)([(-1-x)/2,(-1+x)/2]);
 for t=1:99
    k=floor(sqrt(t));
    s=t-k*(k+1);
    v=f(sign(s)*(1-2*mod(k,2)));
    nP=[k,k]+abs(s)*v;
    text(P(1),P(2),num2str(t))
 end;