OFFSET
0,4
COMMENTS
The first decrease from a(4) = 3 to a(5) = 2 occurs when the radius squared increases from an arbitrary position between 1 and 2 (when 3 squares are on the edge) to exactly 2 (when only 2 squares are on the edge because the circle of square radius 2 passes through the upper right corner on the y=x line). Similar decreases occur when the circle passes through other upper right corners. At least some (if not all) adjacent duplicates occur when the square radius corresponds to a perfect square, that is a corner which is only a lower right corner, i.e., on the y = 0 line. For example, a(6)=a(7)=3 occurs when, for n = 6 , a(n) corresponding to the interval between 2 and 4; and, for n=7, a(n) corresponding to the exact square radius of 4. Some of the confusion may come from the fact that for odd n, there is a unique circle corresponding to elements of a(n) (passing through the corner of specific square(s) on the grid), while for even n, there is a set of circles with a range of radii (which do not pass through corners) corresponding to the elements of a(n). It seems easier to organize the concept in terms of intervals and corners for the sake of consistency.
a(n) is even when the radius squared corresponds to an element of A024517.
LINKS
Rajan Murthy, Table of n, a(n) for n = 0..4999
FORMULA
EXAMPLE
At radius 0, there are no partially filled squares. At radius >1 but < sqrt(2), there are 3 partially filled squares along the edge of the circle. At radius = sqrt(2), there are 2 partially filled squares along the edge of the circle.
PROG
(Scilab)
function index = n_edgeindex (N)
if N < 1 then
N = 1
end
N = floor(N)
i = 0:ceil(N/2)
i = i^2
index = i
for j = 1:length(i)
index = [index i+ i(j).*ones(i)]
end
index = unique(index)
index = index(1:ceil(N))
d = diff(index)/2
d = d + index(1:length(d))
index = gsort([index d], "g", "i")
index = index(1:N)
endfunction
function l = n_edge_n (i)
l=0
h=0
while (i > (2*h^2))
h=h+1
end
if i < (2*h^2) then
l = l+1
end
if i >1 then
t=[0 1]
while (i>max(t))
t = [t (sqrt(max(t))+1)^2]
end
for j = 1:h
b=t
t=[2*(j)^2 (j+1)^2 + (j)^2]
while (i>max(t))
t = [t (sqrt(max(t)-(j)^2)+1)^2 + (j)^2]
end
l = l+ 2*(length(b)-length(t))
if max(t) == i then
l = l-2
end
end
end
endfunction
function a =n_edge (N)
if N <1 then
N =1
end
N = floor(N)
a= []
index = n_edgeindex(N)
for i = index
a = [a n_edge_n(i)]
end
endfunction
CROSSREFS
Cf. A001481 (corresponds to the square radius of alternate entries), A232499 (number of completely encircled squares when the radii are indexed by A000404), A235141 (first differences), A024517.
KEYWORD
nonn
AUTHOR
Rajan Murthy, Dec 22 2013
STATUS
approved