A comparison of the output of this above to the actual values:

r= 0: 0 ~ 1

r=1: 2 ~ 5

...

r=10: 310.45 ~317

r=20: 1251.38 ~1257

r=30: 2820.99 ~2821

r=40: 5019.11 ~5025

r =45: 6353.84 ~6361

(within .1 % on that last one)

I only found one example where it overestimates:

r=46 6639.63 ~6625

proof: Actually I'm not sure why, but this expression is exact:

because r^2-a^2 is the height of the circle in one quadrant as a increases and the floor of that height counts the number of grid points less than that height then you multiply that by 4 and add the points on the axes with the 4*r term and add one for the point in the very center.

and then I used the fact that the average value before flooring is probably .5 to get the approximation

## No comments:

## Post a Comment