Nothing Special   »   [go: up one dir, main page]

login
A376215
Maximum number of non-overlapping discs with a diameter of 1 that can fit within an n×n square, using hexagonal packing or square packing, whichever is more efficient.
1
1, 4, 9, 16, 25, 36, 49, 68, 85, 105, 126, 150, 175, 216, 247, 279, 314, 350, 389, 429, 492, 538, 585, 635, 686, 740, 822, 880, 941, 1003, 1068, 1134, 1203, 1307, 1380, 1456, 1533, 1613, 1694, 1817, 1904, 1992, 2083, 2175, 2270, 2366, 2511, 2613, 2716, 2822, 2929, 3039
OFFSET
1,2
COMMENTS
Maximum error on the first 99 terms = 3.3%. (See the Specht's site).
The first row of discs is placed on the base of the square. Then hexagonal packing is applied, row by row, as much as possible. We find a number N of discs. If n^2>N then the whole packing is replaced by the square one. Example: n=3 => N=8 but since n^2=9 we can indeed place 9 discs.
Note: useful only for n=2, 3, 4, 5, 6, 7.
FORMULA
a(n) = max(n^2,n*floor(1+2*(n-1)/sqrt(3)) - floor(floor(1+2*(n-1)/sqrt(3))/2));
PROG
(Matlab/Octave)
% Given here just for it is easier to understand than the formula.
% Warning: because of sqrt(3), which necessarily has a truncated represensation, results for large values of n may be incorrect.
% Hexagonal packing (upwards)
dh=sqrt(3)/2; nrows=floor(1+(n-1)/dh); % Number of rows
npairs=floor(nrows/2); % Number of pairs of rows
ndiscs=(2*n-1)*npairs; % Number of discs for the pairs
if nrows>2*npairs % Additional row (for n=1, 3, 5, 7, 8, etc.)
ndiscs=ndiscs+n;
end
a(n)=max(n^2, ndiscs); % Sometimes n^2 is better
(Python)
from math import isqrt
def A376215(n): return max(n**2, n*(m:=1+isqrt(((n-1)**2<<2)//3))-(m>>1)) # Chai Wah Wu, Nov 06 2024
CROSSREFS
Cf. A084617.
Sequence in context: A294497 A080160 A110723 * A084617 A179126 A354180
KEYWORD
nonn,more
AUTHOR
Maurice Clerc, Sep 15 2024
STATUS
approved