An Archimedean spiral means each loop is a constant distance from the preceding, in this case 1 unit. The polar coordinates are

R = sqrt(N)
theta = sqrt(N) * 2pi

which comes out roughly as

18
19 11 10 17
5
20 12 6 2
0 1 4 9 16 25
3
21 13 7 8
15 24
14
22 23

The X,Y positions returned are fractional, except for the perfect squares on the positive X axis at X=0,1,2,3,etc. The perfect squares are the closest points, at 1 unit apart. Other points are a little further apart.

The arms going to the right like N=5,10,17,etc or N=8,15,24,etc are constant offsets from the perfect squares, ie. d^2 + c for positive or negative integer c. To the left the central arm N=2,6,12,20,etc is the pronic numbers d^2 + d = d*(d+1), half way between the successive perfect squares. Other arms going to the left are offsets from that, ie. d*(d+1) + c for integer c.

Euler's quadratic d^2+d+41 is one such arm going left. Low values loop around a few times before straightening out at about y=-127. This quadratic has relatively many primes and in a plot of primes on the spiral it can be seen standing out from its surrounds.

Plotting various quadratic sequences of points can form attractive patterns. For example the triangular numbers k*(k+1)/2 come out as spiral arcs going clockwise and anti-clockwise.

See examples/sacks-xpm.pl for a complete program plotting the spiral points to an XPM image.

The accuracy could be improved here by taking into account the polar angle of the corners which are candidates for the maximum radius. On the X axis the stripes of N are from X-0.5 to X+0.5, but up on the Y axis it's 0.25 further out at Y-0.25 to Y+0.75. The stripe the corner falls in can thus be biased by theta expressed as a fraction 0 to 1 around the plane.

An exact theta 0 to 1 would require an arctan, but approximations 0, 0.25, 0.5, 0.75 from the quadrants, or eighths of the plane by X>Y etc diagonals. As noted for the Theodorus spiral the over-estimate from ignoring the angle is at worst R many points, which corresponds to a full loop here. Using the angle would reduce that to 1/4 or 1/8 etc of a loop.

Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-PlanePath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.