Related to this question concerning number spirals I have another one, more specific.
While it is rather easy to arrange the natural numbers along an Archimedean spiral by
$$x(n) = \sqrt{n}\cos(2\pi\sqrt{n})$$ $$y(n) = \sqrt{n}\sin(2\pi\sqrt{n})$$
it's much more difficult to arrange them along a square spiral by a closed formula. It's very easy to construct the square spiral algorithmically ("go along straight lines and always turn to the right if possible") but I'm totally stuck how the functions $x(n),y(n)$ would look like as formulaic expressions. The only thing I'm quite sure about is that they will make use of the square root function - but how are the "radii" and the turns coded?
This is how the two spirals look like (the Archimedean spiral being appropriately scaled and rotated to align the square numbers):
And here you can see them being morphed into each other.
Can anyone give me a hint (or the solution)?





I am not sure if this answers the question. We can note that the squares of even numbers are on the diagonal of the second quadrant, so if we set: $$\hat n=\max\{2k\mid (2k)^2\leqslant n\},$$ or in other words: $$\hat n=\left\{ \begin{array}{cl} \lfloor \sqrt n\rfloor & \mbox{if $\lfloor \sqrt n\rfloor$ is even}\\ \lfloor \sqrt n\rfloor-1 & \mbox{if $\lfloor \sqrt n\rfloor$ is odd} \end{array} \right.,$$ then we can easily arrange numbers in the integer lattice by the rule: $$(x(n),y(n))= \left\{ \begin{array}{cl} (-\frac{\hat n}{2}+n-\hat n^2,\frac{\hat n}{2}) & \mbox{if $\hat n^2\leqslant n\leqslant\hat n^2+\hat n$}\\ (\frac{\hat n}{2},\frac{\hat n}{2}-n+\hat n^2+\hat n) & \mbox{if $\hat n^2+\hat n< n\leqslant\hat n^2+2\hat n+1$}\\ (\frac{\hat n}{2}-n+\hat n^2+2\hat n+1,-\frac{\hat n}{2}-1) & \mbox{if $\hat n^2+2\hat n+1< n\leqslant\hat n^2+3\hat n+2$}\\ (-\frac{\hat n}{2}-1,-\frac{\hat n}{2}-1+n-\hat n^2-3\hat n-2) & \mbox{if $\hat n^2+3\hat n+2< n\leqslant\hat n^2+4\hat n+3$} \end{array} \right..$$