0
$\begingroup$

Let's say that I have a variable $j$ defined by the following formula: $j=\frac{n(n+2) + m}{2}$ where $n$ and $m$ are two parameters, both integers, that satisfy the following conditions:

  1. $n\in \left[0,1,2,...\right]$
  2. $m\in\left[-n,n\right]$
  3. $\left(n-m\right)$ even

We know that, subject to the above conditions, there exists a bijection between $j$ and the tuples $\left(m,n\right)$.

  • Is there a way of expressing $m$ and $n$ as (hopefully compact) explicit functions of (only) $j$?
  • How would one proceed to find such a formula?

2 Answers 2

2

Since $2j$ depends quadratically on $n$, you basically need the square root of $2j$ to get $n$. To get the limits exactly right, I'd try $n=\lfloor \sqrt{2j+a}+b\rfloor$ and then determine $a$ and $b$ so that everything comes out right. Once you have $n$, it's easy to get $m$.

Update: You can systematically determine $a$ and $b$ by looking at what happens at the boundaries. You need

$\lfloor \sqrt{n(n+2)-n+a}+b\rfloor=n$

but

$\lfloor \sqrt{(n-1)((n-1)+2)+(n-1)+a}+b\rfloor=n-1\;.$

The difference between the two arguments of the square root is $2$. To avoid rounding problems you can choose $a$ and $b$ such that the argument of the floor function is the integer $n$ when the argument of the square root is in the middle between the two:

$\sqrt{n^2+n-1 + a} + b = n\;,$

$n^2+n-1+a=(n-b)^2\;,$

$n-1+a=-2bn+b^2\;.$

To make this true for all $n$, you can equate the constant terms and the coefficients of $n$:

$1=-2b\;,$ $-1+a=b^2\;.$

That yields $a=\frac{5}{4}$ and $b=-\frac{1}{2}$, so the formula for $n$ is

$n=\lfloor \sqrt{2j+\frac{5}{4}}-\frac{1}{2}\rfloor\;.$

1

You can take $2j = n(n+2)+m = (n+1)^2 + (m-1)$.

Consider $k^2$ and $(k+1)^2$. The difference between them is $2k+1$; if you allow yourself to add at most $k$ to $k^2$, you "get" all the way to $k^2+k$. If you allow yourself to subtract at most $k$ from $(k+1)^2$, you can "get down" all the way to $k^2+k+1$. So that is why the map $(m,n)\mapsto n(n+1)+m$ is bijective under the given conditions (the parity condition is just to ensure that this number is even).

So look at $k = \lfloor \sqrt{2j}\rfloor$. This is either $n+1$ or $n$, depending on whether $m$ is positive or negative, and once you determine if $k=n$ or if $k=n+1$, you can compute $m$ from $m = 2j - n(n+2)$.

Well, since $k=n$ or $k=n+1$, either $2j-k(k+2)$ will lie between $-k$ and $k$ or not. If it does, then $k=n$ and $m=2j-k(k+2)$. If it does not lie between $-k$ and $k$, then $k=n+1$, so $m = 2j-(k-1)(k+1)$.