1

$\underline{\text{Motivation}:-}$

This is a sort of sub-question of my previous question

In that question I asked about finding the formula for the ulam spiral. Answering the question I will ask here, will help get closer to the answer for the original question (Atleast in my approach).

$\underline{\text{Why am I asking this separately}?}$

I think this question is not a duplicate of the question I linked because in the original question, i asked about the ulam spiral along with the questions about my approach to solve it (Is my approach correct? And what would be a better approach?). While here I am asking this specific question in it's own right and I do think that this question is interesting in it's own right.

If that is the case then why did I linked the original one? Well because people reading this question might be curious that why I ask such a random question out of nowhere, so I thought giving the motivation might be a good idea.

$\underline{\text{Details}:-}$

Let,

$\begin{align}&L_1=\{L^2-L,\cdots,L^2-1\}\\&L_2=\{L^2,\cdots,L^2+L-1\}\end{align}$

For $L\in\mathbb{N}$

For example,

$1_1=\{0\}$

$1_2=\{1\}$

$2_1=\{2,3\}$

$2_2=\{4,5\}$

$3_1=\{6,7,8\}$

$3_2=\{9,10,11\}$

$4_1=\{12,13,14,15\}$

$\vdots$

It's clear that $\bigcup_{L\in\mathbb{N}}(L_1\cup L_2)=\mathbb{N}$

I want to find a method which finds $L$ for a given natural number $n$.

To do that, it seems that I need to solve for $L$ in the equation

$L^2+k=n$

where, $n\in\mathbb{N}$ and $L\leq n$ and $k$ is an integer with $-L\leq k\leq L-1$

And if we solve for $k$ too then we can also say whether $n\in L_1$ or $n\in L_2$

Since, $L=n$ only when $n=1$

So we have to solve for $L$ and $k$ in

$\begin{cases}L^2+k=n\\-L\leq k\leq L-1\\1<L<n\end{cases}$

$\underline{\text{My Question}:-}$

To clear off what I am really asking-

How to solve for $L$ and $k$ in

$\begin{cases}L^2+k=n\\-L\leq k\leq L-1\\1<L<n\end{cases}$

(I feel really bad for not being able to find a solution to an equation only involving perfect squares, but to be honest I really don't know how to approach this question. I have been trying to solve this question for the last few days without any particular success. So I would request the mathematician folks out there to help me)

Eric Wofsey
  • 330,363

1 Answers1

1

You want to find $L$ such that $$ L^2-L \le n \le L^2+L-1, $$ or equivalently, the largest $L$ such that $L^2-L \le n$.

This is just a quadratic inequality you can solve: $$ \frac{1-\sqrt{1+4n}}{2} \le L \le \frac{1+\sqrt{1+4n}}{2}. $$ We wanted the largest integer $L$ satifying the above, so $$ L = \left\lfloor\frac{1+\sqrt{1+4n}}{2}\right\rfloor. $$ And then just $$ k = n - L^2 = n - \left\lfloor\frac{1+\sqrt{1+4n}}{2}\right\rfloor^2 .$$


Why did we want $\max\{L:L^2-L\le n\}$? I trust you're already convinced that the intervals partition $\mathbb N_0$ ito disjoint sets: $$ [0,1], [2,5], [6,11], \ldots, [L^2-L, L^2+L-1], \ldots $$ This means that for any $n$, we know there is a unique solution for $L$. We just need to find the interval that contains $n$. So we let $L$ grow, and once the lower endpoint is $>n$, we know we've gone too far. The interval right before that characterized by having the largest $L$ such that $L^2-L$ is not too large yet. Does that make sense? Otherwise think of a concrete example (say $n=10$). That should convince you.

By the way, the formulas would get a lot simpler if you group the intervals differently: $$ 0=\{0\},\ 1_1=\{1\},\ 1_2=\{2,3\},\ 2_1=\{4,5\},\ 2_2=\{6,7,8\}, $$ and so on. This way $L$ is just $\lfloor\sqrt n\rfloor$.

Milten
  • 7,031
  • Can you elaborate that why the grouping you did will make $L=\lfloor\sqrt{n}\rfloor$? – Rounak Sarkar Jul 17 '21 at 15:15
  • @RanjitKumarSarkar Because the groups begin at the square numbers. Group $3$ starts at $9=3^2$ and so on. – Milten Jul 17 '21 at 19:58
  • @RanjitKumarSarkar Each group is still split in two parts though, like in your own version, so you’ll need to find the splitting point. Shouldn’t be too difficult. – Milten Jul 17 '21 at 19:59