cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A376215 #35 Nov 07 2024 08:36:33
%S A376215 1,4,9,16,25,36,49,68,85,105,126,150,175,216,247,279,314,350,389,429,
%T A376215 492,538,585,635,686,740,822,880,941,1003,1068,1134,1203,1307,1380,
%U A376215 1456,1533,1613,1694,1817,1904,1992,2083,2175,2270,2366,2511,2613,2716,2822,2929,3039
%N 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.
%C A376215 Maximum error on the first 99 terms = 3.3%. (See the Specht's site).
%C A376215 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.
%C A376215 Note: useful only for n=2, 3, 4, 5, 6, 7.
%H A376215 E. Specht, <a href="http://hydra.nat.uni-magdeburg.de/packing/csq/csq.html">The best known packings of equal circles in a square</a>
%F A376215 a(n) = max(n^2,n*floor(1+2*(n-1)/sqrt(3)) - floor(floor(1+2*(n-1)/sqrt(3))/2));
%o A376215 (Matlab/Octave)
%o A376215 % Given here just for it is easier to understand than the formula.
%o A376215 % Warning: because of sqrt(3), which necessarily has a truncated represensation, results for large values of n may be incorrect.
%o A376215 % Hexagonal packing (upwards)
%o A376215 dh=sqrt(3)/2;nrows=floor(1+(n-1)/dh); % Number of rows
%o A376215 npairs=floor(nrows/2); % Number of pairs of rows
%o A376215 ndiscs=(2*n-1)*npairs; % Number of discs for the pairs
%o A376215 if nrows>2*npairs % Additional row (for n=1, 3, 5, 7, 8, etc.)
%o A376215     ndiscs=ndiscs+n;
%o A376215 end
%o A376215 a(n)=max(n^2,ndiscs); % Sometimes n^2 is better
%o A376215 (Python)
%o A376215 from math import isqrt
%o A376215 def A376215(n): return max(n**2,n*(m:=1+isqrt(((n-1)**2<<2)//3))-(m>>1)) # _Chai Wah Wu_, Nov 06 2024
%Y A376215 Cf. A084617.
%K A376215 nonn,more
%O A376215 1,2
%A A376215 _Maurice Clerc_, Sep 15 2024