Twelve Unit Cubes in a Cube of Side 2.9315,
Found by Hardening Balls into Cubes

Yohei Nakajima1

We give a packing of 12 unit cubes in a cube of side 2.93151852.9315185, with every pair and every wall at least 10−610^{-6} apart, improving the previous best known side 2.93277176872.9327717687 (H. Lin, July 2026 (Tencent Hunyuan, n.d.)). The packing was found by a soft-to-rigid homotopy: unit-diameter balls are compressed in a shrinking box and then deformed through rounded cubes into rigid unit cubes while inward pressure on the box continues. The final configuration is tightened with a constrained solver that keeps every corner inside the box and a separating plane between every nearby pair, and validated by an exact rational certificate. On unit squares in a square, the same method recovers the best known packings for n=11n=11 (now proved optimal), 1717, 1818, 1919, 2626 and 2727, and at equal budgets beats a rigid-start control run on the same schedule. We report where the method fails (n=28,29n=28,29 squares; n=10,11n=10,11 cubes so far), an ablation in which an oriented intermediate shape showed no benefit, and code to reproduce every result.

Introduction

Let sd(n)s_d(n) be the side of the smallest dd-dimensional cube that contains nn non-overlapping unit cubes, free to rotate. For squares (d=2d=2) the problem has a long record history (Erdős and Graham 1975; Stromquist 2003; Friedman, n.d.b; The Squares Project, n.d.); the smallest unsettled case, n=11n=11, was recently closed (The Squares Project, n.d.). For cubes (d=3d=3) far fewer results exist. Friedman’s catalogue (Friedman, n.d.a) lists non-trivial packings for n=9n=9–1414 and 2828–3333; the entries for n=11n=11 and 1212 were improved in 2026 (T. Berthold et al. in March for n=11n=11, as credited in (Friedman, n.d.a), which gives no coordinate file; H. Lin in July for n=11n=11 and 1212, with coordinates published in (Tencent Hunyuan, n.d.)), and for every other n<34n<34 the trivial packing is the best known.

Contribution.
  1. A packing of 12 unit cubes in a cube of side 2.93151850947972.9315185094797 with every pair and every wall separated by at least 10−610^{-6} (§3), 0.00125330.0012533 below the previous record 2.93277176870486532.9327717687048653. It is certified in exact rational arithmetic.

  2. A simple search method, soft-to-rigid homotopy with inward pressure (§2), and an exact tightening step that turns its output into a locally optimal packing to 10−1210^{-12}.

  3. An empirical record of what the method does and does not reach: in 2D it recovers six published records from random starts and beats a rigid-start control; it fails on n=28,29n=28,29 squares; an oriented intermediate shape shows no benefit (§4, §5).

This is a search result, not an optimality proof.

Gensane and Ryckelynck’s perturbation–compression algorithm found dense square packings, including n=11n=11, from random starts (Gensane and Ryckelynck 2005). Recent square records (n=28n=28, 2929, 3939, 4141, 5050, 5151, 5555) come from rigid simulated annealing and exact refinement (The Squares Project, n.d.). Our method differs in starting from balls and changing the shapes, not just their positions, during the search.

Method

Shape family.

A rounded cube of softness r∈[0,12]r\in[0,\tfrac12] is a cube of half-side 12−r\tfrac12-r dilated by a ball of radius rr (the Minkowski sum). At r=12r=\tfrac12 it is a unit-diameter ball, at r=0r=0 a unit cube, and every member lies inside the unit cube with the same centre and orientation. Hardening (r↓0r\downarrow 0) therefore only grows the shapes, and the container must expand to accommodate them. The square version uses rounded squares.

Energy and pressure.

For centres cic_i, orientations qiq_i (quaternions in 3D, angles in 2D) and container side LL, E=∑i<j(2r−sd(i,j))+2+∑i∑walls(violation)+2+μL,E=\sum_{i<j}\big(2r-\operatorname{sd}(i,j)\big)_+^2+\sum_i\sum_{\text{walls}}(\text{violation})_+^2+\mu L, where sd(i,j)\operatorname{sd}(i,j) is the signed distance between the cores (cube of half-side 12−r\tfrac12-r): exact Euclidean distance when separated (vertex–face and edge–edge features), and minus the separating-axis penetration depth when overlapping (15 axes for cubes (Gottschalk, Lin, and Manocha 1996)). The value of sd\operatorname{sd} is continuous where cores first touch but its gradient can jump there, so EE is piecewise smooth and the schedule is a search heuristic rather than a smooth homotopy. The term μL\mu L is inward pressure; the box resizes symmetrically so all walls push. Positions, orientations and LL follow momentum gradient descent with analytic gradients (checked against finite differences on 72,00072{,}000 random cube-pair gradient components and 120,000120{,}000 square-pair components, sampled away from core contact).

Schedule.

Compress balls under pressure 3μ3\mu (5,000 steps); morph r:12→0r:\tfrac12\to0 linearly at pressure μ=0.02\mu=0.02 (45,000 steps); settle rigid cubes while μ\mu decays to 2⋅10−62\cdot10^{-6} (3,000 steps). Optional annealing adds Gaussian kicks to positions and angles that decay to zero during compression and morphing. The rigid control runs the identical schedule with r=0r=0 throughout. It is a within-schedule ablation, not a tuned rigid-body optimizer: the schedule was designed for soft shapes.

Legalization.

Penalty pressure tolerates small overlaps. Each run is legalized by scaling centres apart about their mean (bisection to the smallest factor at which no pair overlaps by more than 10−1210^{-12} under the separating-axis test) and measuring the tight bounding cube. All sides reported below are legal packings.

Exact tightening.

Runs within a threshold of the catalogue are passed to a constrained solver: minimize LL over centres, rotations and per-pair separating planes uij⋅p=ciju_{ij}\cdot p=c_{ij} with |uij|=1|u_{ij}|=1 (each uiju_{ij} is parameterized in the tangent plane of its current value and renormalized, so plane scale is fixed), subject to every corner of every cube lying in [0,L]3[0,L]^3 and the corners of ii and jj lying on opposite sides of their plane. We use SLSQP (Kraft 1988) in outer iterations with a trust region, rebuilding the pair list and re-basing rotations each iteration, and accept a step only if the independently legalized side decreases. From near-miss runs the solver converges to Trump’s s2(11)s_2(11) (Trump 1979) and Bidwell’s s2(17)s_2(17) (Friedman, n.d.b) to 10−1210^{-12}, and from a perturbed copy to Friedman’s s3(9)=2+1/2s_3(9)=2+1/\sqrt2.

Exact certificate.

For a reported 3D packing we expand centres by a factor 1+10−61+10^{-6} about their mean and inflate each half-side to 12(1+10−12)\tfrac12(1+10^{-12}), which covers floating-point non-orthogonality of the axes. We convert every coordinate to an exact rational, compute all corners exactly, and check (i) every corner lies in [0,S]3[0,S]^3 for a rational SS and (ii) every pair is strictly separated by an explicit rational plane. A linear program proposes each plane; the check itself uses only exact arithmetic.

Twelve cubes

Theorem 1. Twelve unit cubes fit in a cube of side 2.93151850947972.9315185094797 with pairwise and wall clearance at least 10−610^{-6}. Hence s3(12)≤2.9315185094797<2.9327717687048653s_3(12)\le 2.9315185094797<2.9327717687048653.

Certificate. The claim file (claims/cubincub_n12/cubincub_n12.json, Table 3) lists one pose [x,y,z,qw,qx,qy,qz][x,y,z,q_w,q_x,q_y,q_z] per cube, the format of the previous record file (Tencent Hunyuan, n.d.). It was obtained from the tightened packing (side 2.9315145779652.931514577965, with touching contacts) by spreading centres by a factor 1+1.0⋅10−61+1.0\cdot10^{-6} until every pair is separated by 10−610^{-6}, adding a 10−610^{-6} wall gap and rounding the side up. Two checks pass. (i) A floating-point 15-axis separating-axis test (verify.py, 30 lines): minimum wall gap 1.000000000⋅10−61.000000000\cdot10^{-6}, minimum pair gap 1.000000001⋅10−61.000000001\cdot10^{-6}. (ii) An exact check (certify_exact.py): every number is converted to a rational, rotations are the exactly orthogonal H(q)/|q|2H(q)/|q|^2, every corner lies in [0,s]3[0,s]^3 and every pair is strictly separated by an explicit rational plane.

Four cubes are exactly axis-aligned, two are tilted by less than 1∘1^\circ, and six are tilted by 9∘9^\circ or more (Figure 1). Several quaternions have repeated components (e.g. cube 1: (0.58389,−0.58389,−0.39884,−0.39884)(0.58389,-0.58389,-0.39884,-0.39884)), suggesting a closed form that we have not derived.

How it was found.

Seed 52 of the first 64 ball→\tocube starts with annealing ended at legalized side 2.9318212.931821; exact tightening lowered it to 2.9315145779652.931514577965. A second start (seed 83) ended at 2.9319102.931910 and tightens to 2.9316195412.931619541: a distinct local optimum, also below the catalogue. Two of 192 starts land below 2.932772.93277. Ball starts were extended from 64 to 192 after seed 52; the rigid control stayed at 32 (best 2.992572.99257). At equal budget (seeds 1–32), 13 ball→\tocube starts and 1 rigid start end below the trivial side 3 (one-sided Fisher p<0.001p<0.001).

Twelve unit cubes in a cube of side 2.9315152.931515. Blue: tilt below 1.5∘1.5^\circ; red: tilted.
Interactive: the run that found this packing, from balls to the certified cubes. Drag to rotate.
Other cube counts.

Table 1 summarizes the first 3D screen. The method matches Friedman’s n=9n=9 packing often, settles in worse arrangements at n=10n=10 and 1111, and is the only setup that comes near the catalogue at n=12n=12.

First 3D screen (annealed ball→\tocube vs. rigid control, 53,00053{,}000 steps per start; best after exact tightening). The best n=10n=10 run is within 2⋅10−72\cdot10^{-7} of 1+52/41+5\sqrt2/4; the tightened best n=11n=11 run equals 2+2/5≈2.8944272+2/\sqrt5\approx2.894427 to 10−910^{-9}, below the March 2026 value but above Lin’s 2.88295292.8829529.
nn catalogue starts (ball / rigid) best ball→\tocube best rigid matches (ball / rigid)
9 2.707112.70711 64 / 32 2.7071072.707107 2.7071072.707107 16 / 5
10 2.707112.70711 64 / 32 2.7677672.767767 2.8944282.894428 0 / 0
11 2.882952.88295 64 / 32 2.8944272.894427 2.9189922.918992 0 / 0
12 2.932772.93277 192 / 32 2.931515\mathbf{2.931515} 2.9925732.992573 —
13 2.9562.956 48 / — 2.9971842.997184 — 0 / —
14 2.989952.98995 42 / — 3.0000003.000000 — 0 / —

Validation on squares

We developed the method on unit squares, where records are dense and recently audited (The Squares Project, n.d.; Friedman, n.d.b).

n=11n=11.

With annealing and the long schedule, 6 of 160 random starts reach Trump’s packing (tilt 40.18∘40.18^\circ); 0 of 120 rigid-control starts do (best 3.88773.8877, median 4.0004.000). Trump’s packing has since been proved optimal (The Squares Project, n.d.), so this is a sanity check.

n=2n=2–3030 at a fixed schedule.

Among cases whose best known packing has tilted squares, the method matches n=5,10,11n=5,10,11 and none from 1717 upward at the standard step budget; the rigid control matches 55 and 1010. Grid cases split by slack: when the grid has empty cells (n=6,7,12,13,20,21n=6,7,12,13,20,21) rigid starts fall into it more often (46–100% vs. 2–19%), while for full or nearly full grids (n=9,15,16,22n=9,15,16,22–25,3025,30) rigid starts jam at tilts they cannot rotate out of (e.g. n=25n=25: rigid 0/24, balls 7/48, one-sided Fisher p≈0.05p\approx0.05, suggestive only).

Old records recovered with more steps and exact tightening.
Squares: best known packings reached from random starts. No run went below a catalogue value in about 5,000 starts at n≥17n\ge17.
nn best known (finder) recovered to hit rate
17 4.6755304.675530 (Bidwell 1998) 10−1210^{-12} 10/960 blob; 0/80 rigid (1/40 vs 0/40 on equal seeds)
18 4.8228764.822876 (Hämäläinen 1980) 10−510^{-5} 2/24
19 4.8856184.885618 (Wainwright 1979) 10−1210^{-12} 2/960
26 5.6213205.621320 (Friedman 1997) 10−1210^{-12} 4/160, 10/160, 10/96 at 3×\times/5×\times/10×\times steps
27 5.7071075.707107 (Göbel 1979) 10−1210^{-12} 1/416
28 5.8244455.824445 (Ellsworth 2025) — best 5.8444985.844498
29 5.9338335.933833 (Schadt 2025) — best 5.9389965.938996

Exact tightening matters: raw runs stop about 10−410^{-4} above the record because of penalty slack, and the solver also pulls runs from up to 0.0220.022 away into the record basin (n=27n=27). After tightening, every arrangement within 0.0010.001 of the catalogue at n=17n=17 and 1919 was the catalogue packing itself.

Ablations and negative results

Oriented intermediate shape.

Disks carry no orientation, and on the n=11n=11 hit the angles lock in only once r<0.06r<0.06. We tested morphing through regular octagons cut back to squares, which exert torque from the start. On the same seeds and steps (n=17,19n=17,19, seeds 1–160), octagons hit 0/320 vs. 4/320 for annealed disks (one-sided p≈0.06p\approx0.06), with no better medians and 3×3\times the cost. We find no evidence that an oriented intermediate shape helps; since octagons also change the boundary geometry, this does not isolate the timing of orientation commitment.

Penalty polish.

A fixed-box squeeze-and-shake stage changed sides by at most 0.0090.009 and never changed the arrangement; it is superseded by exact tightening.

Scaling.

Hit rates fall with nn at a fixed budget. At n=26n=26 they rise with hardening time; at n=27n=27–2929 they do not.

Discussion

The method’s value is the basin it lands in: starting from balls, configurations are dense before orientation matters, and rotation is decided only as corners appear. For 3D, where the catalogue is sparse, this was enough to improve n=12n=12: 2 of 192 starts land below the record. At n=13n=13 and 1414 (48 and 42 starts, no rigid control) no run came within 0.040.04 and 0.010.01 of the catalogue; the best n=14n=14 run is the trivial side 33.

Limitations.

(i) No optimality claims. (ii) The catalogue values for cubes were read from Friedman’s page images, and Lin’s packings are not described in text; 2.932772.93277 is truncated (“2.93277+2.93277+”), which does not affect a 0.001260.00126 margin. (iii) Hit rates are from modest, sometimes unequal sample sizes and are reported with counts. (iv) The rigid control is an internal ablation; we did not benchmark against rigid simulated annealing or perturbation–compression (Gensane and Ryckelynck 2005). (v) Annealing noise is near zero by the time orientations lock in (r<0.06r<0.06); a schedule that peaks there is untested.

Reproducibility.

All code, seeds, run logs and certificates are at https://github.com/yoheinakajima/soft-to-rigid-packing, archived as release v1.0.0 at doi:10.5281/zenodo.23248095. scripts/reproduce_n12.sh regenerates the n=12n=12 packing and its certificate in a few minutes on a laptop.

Acknowledgements.

Code, experiments and verification were developed with Claude (Anthropic), an AI system, under the author’s direction. The author takes responsibility for the content.

Coordinates for n=12n=12

Centres and unit quaternions (w,x,y,z)(w,x,y,z); cube ii occupies ci+R(qi)[−12,12]3c_i+R(q_i)[-\tfrac12,\tfrac12]^3 in the box [0,2.9315185094797]3[0,2.9315185094797]^3. Full-precision values: claims/cubincub_n12/cubincub_n12.json.

Coordinates of the n=12n=12 packing.
ii xx yy zz ww qxq_x qyq_y qzq_z
1 1.5243900087 2.4315173049 1.3320181026 0.5838886869 -0.5838886869 -0.3988408220 -0.3988408220
2 2.4315175095 2.4315173049 0.5000010000 0.7071067812 0.7071067812 -0.0000000000 0.0000000000
3 0.5000010000 1.4369556928 1.4377218077 0.5395289954 0.4570650535 0.4570650535 -0.5395289954
4 0.5098745912 0.5769319953 2.3545775829 0.4560511351 -0.5403863020 -0.4560472394 0.5403896022
5 0.6086104699 2.2929309153 2.3887769910 0.0258332833 0.7609821302 -0.6482073268 -0.0081302199
6 2.4315175095 1.4315163049 0.5000010000 0.0000000000 -0.0000000000 -0.0000000000 -1.0000000000
7 2.4298431049 2.4215276465 2.2620542416 0.0000269579 0.0016621483 -0.9999712786 0.0073944948
8 1.5800409188 1.4806927085 2.4315175095 0.0000000000 -0.9765112947 -0.2154662186 -0.0000000000
9 1.6870691741 0.7046058868 1.3931640729 0.1630483719 -0.8266039691 -0.3023204668 0.4458065074
10 0.6714203714 0.5125513149 0.5042794969 0.0019279356 0.0017767559 -0.7100527881 -0.7041435680
11 2.4315175095 0.5648571561 2.4315175095 0.5000000000 -0.5000000000 -0.5000000000 0.5000000000
12 0.5000010000 2.3777515563 0.5000010000 0.7071067812 -0.7071067812 0.0000000000 0.0000000000
Erdős, Paul, and Ronald L. Graham. 1975. “On Packing Squares with Equal Squares.” Journal of Combinatorial Theory, Series A 19: 119–23.
Friedman, Erich. n.d.a. “Cubes in Cubes.” Erich’s Packing Center, https://erich-friedman.github.io/packing/cubincub/.
———. n.d.b. “Packing Unit Squares in Squares: A Survey and New Results.” Electronic Journal of Combinatorics, Dynamic Survey DS7.
Gensane, Thierry, and Philippe Ryckelynck. 2005. “Improved Dense Packings of Congruent Squares in a Square.” Discrete & Computational Geometry 34: 97–109.
Gottschalk, Stefan, Ming C. Lin, and Dinesh Manocha. 1996. “OBBTree: A Hierarchical Structure for Rapid Interference Detection.” In Proceedings of SIGGRAPH ’96, 171–80.
Kraft, Dieter. 1988. “A Software Package for Sequential Quadratic Programming.” DFVLR-FB 88-28. DFVLR.
Stromquist, Walter. 2003. “Packing 10 or 11 Unit Squares in a Square.” Electronic Journal of Combinatorics 10: R8.
Tencent Hunyuan. n.d. “Hyra-Results: Packing Records.” https://github.com/Tencent-Hunyuan/Hyra-results/tree/main/AI4Science/packing_records.
The Squares Project. n.d. “An Atlas of the Square Packing Problem.” https://jlevy.github.io/squares/.
Trump, Walter. 1979. “Packing 11 Unit Squares in a Square.” https://trump.de/square-packing/.