Last updated:

Sphere packing guide

Sphere Packing in a Cylinder: How to Calculate the Optimal Radius and Height

Packing spheres into a cylinder comes down to two numbers: how many fit in one circular layer, and how many layers fit in the height. Multiply them together and you have your total. The trick is working out each number separately, and this guide shows you exactly how.

Three horizontal layers of spheres packed inside a cylinder, with the cylinder radius R and height H labelled
Spheres arranged in three circular layers inside a cylinder, labelled with radius R and height H

Packing spheres into a box is straightforward: everything lines up in neat rows. A cylinder is trickier, because circles don't tile a round cross-section the way squares tile a flat grid. There's always a curved gap near the wall, and the best arrangement shifts depending on how wide the cylinder is relative to the spheres.

The good news: once you see the trick, it's genuinely simple. Spheres per layer depends only on the radius ratio. Layers in the height depends only on the height divided by the diameter. Multiply the two and you're done.

Just need the number? Drop your radius and height into the Sphere Packing Calculator and it handles the layer math for you, including the trickier nested arrangements.

Table of Contents

The Two-Step Method

Here's the whole idea in one line:

Total spheres ≈ (spheres per layer) × (number of layers)

The first number depends on how wide the cylinder is compared to the spheres. The second depends on how tall it is. They're independent, which is what makes this manageable: solve each one separately, then multiply.

Everything below assumes identical spheres, which is the case in almost every real packing problem: ball bearings, marbles, fruit, you name it.

Step 1: How Many Spheres Fit in One Layer?

Picture looking straight down into the cylinder. Each sphere shows up as a circle, and the question becomes: how many small circles of radius r fit inside the big circle of radius R? That's a classic geometry puzzle called "circle packing in a circle," and the answer depends entirely on the radius ratio, R ÷ r.

Top-down view of a cylinder showing 7 spheres per layer when the radius ratio is 3, and 9 spheres per layer when the ratio is about 3.75
Top-down view: 7 spheres per layer at a radius ratio of 3, and 9 spheres per layer at a ratio of about 3.75

The wider the cylinder relative to the spheres, the more you fit into each layer. There's a clean case at R ÷ r = 3: six spheres in a ring around the wall, plus one sitting perfectly in the centre, giving seven per layer. After that the numbers stop being tidy, but mathematicians have worked out the optimal arrangements. Here are the key thresholds:

Radius ratio (R ÷ r) Max spheres per layer
1.01
2.02
2.153
2.414
2.705
3.007 (1 centre + 6 ring)
3.308
3.619
3.8110
4.0312
4.2413
4.5215
4.8619
5.1220

To use it, work out your ratio and read off the largest count whose threshold it meets or beats. A cylinder of radius 7.5 cm holding radius-2 spheres has a ratio of 7.5 ÷ 2 = 3.75. That clears the 3.61 threshold for 9 spheres but not the 3.81 needed for 10, so you fit 9 spheres per layer.

Watch the wall gap: A sphere touching the cylinder wall has its centre at distance R − r from the axis, not R. That detail is why a ratio of 3.9 doesn't quite reach 10 spheres: there isn't room for the centres to spread out far enough. When you're close to a threshold, round down.

Step 2: How Many Layers Fit in the Height?

This part is friendlier. If you stack layers directly on top of each other (every sphere sitting squarely on the one below), each layer adds one sphere-diameter of height:

Number of layers = ⌊H ÷ 2r⌋ (round down)

For radius-2 spheres (diameter 4 cm) in a 14.5 cm cylinder: ⌊14.5 ÷ 4⌋ = 3 layers.

Side view comparing a simple stack of 3 layers with a nested arrangement that fits 4 layers in the same height
Side view: simple stacking gives 3 layers; nesting each layer into the gaps below can fit 4 in the same height

There's a way to do better. If you nestle each layer down into the gaps of the one below (the way oranges settle in a crate), the layers sit closer together. The vertical gap shrinks from 2r to about 2r × 0.816, buying you roughly 15% more layers in the same height. It's a real gain, but it makes the arithmetic messier and the top layer can end up partially supported. Simple stacking is the dependable baseline.

Tip: For a guaranteed, defensible answer (homework, packaging specs, or quotes), use simple stacking: layers = ⌊H ÷ 2r⌋. Reach for nested stacking only when you're genuinely trying to squeeze out maximum capacity; verify it with the calculator.

Putting It Together

Two numbers, one multiplication. Here's the radius-10, height-11 cylinder with radius-2 spheres:

  1. Per layer: ratio = 10 ÷ 2 = 5.0 → 19 spheres
  2. Layers: ⌊11 ÷ 4⌋ = 2
  3. Total: 19 × 2 = 38 spheres

A wide, shallow cylinder: two generous layers that each hold 19 spheres for a total of 38.

Worked Examples

Here are the exact cylinders that come up again and again, all with radius-2 spheres (diameter 4 cm), using reliable simple stacking.

Example 1: Radius 10, Height 11

Ratio = 10 ÷ 2 = 5.0, which clears the 4.86 threshold for up to 19 per layer. Layers = ⌊11 ÷ 4⌋ = 2. Total = 38 spheres. Nesting can squeeze in a third layer, pushing the total higher, but 38 is the safe, simple-stacking answer.

Example 2: Radius 6, Height 10

Ratio = 6 ÷ 2 = 3.0, giving exactly 7 per layer (the 1-centre-plus-6-ring arrangement). Layers = ⌊10 ÷ 4⌋ = 2. Total = 14 spheres with simple stacking, up to 21 if you nest three layers.

Example 3: Radius 7.5, Height 16

Ratio = 7.5 ÷ 2 = 3.75 gives 9 per layer, and ⌊16 ÷ 4⌋ = 4 layers. Total = 36 spheres. A moderately wide cylinder with a clean 9-per-layer arrangement spread across four tidy layers.

Example 4: Designing for 34 Spheres

34 is an awkward number: it doesn't split into neat equal layers. The closest tidy option is two layers of 17, which needs a radius ratio of about 4.79 (radius ≈ 9.6 cm, round up to 10) and a height of 8 cm. Because 34 doesn't factor neatly, you'll usually round up to a cylinder that holds a few more and leave a couple of slots empty.

Example 5: Radius 5, Height 20

Ratio = 5 ÷ 2 = 2.5. That clears 2.41 for 4 per layer but not 2.70 for 5. Layers = ⌊20 ÷ 4⌋ = 5. Total = 20 spheres. A tall, narrow cylinder that fits a modest count per layer across many stacked layers.

Reality check: These per-layer maxima assume spheres in their mathematically optimal positions. In a real container with a slightly off ratio, you might land one short. When precision matters, the Sphere Packing Calculator computes the exact arrangement rather than reading off a table.

Designing a Cylinder for a Target Number of Spheres

Sometimes you know the count and need the container. The approach:

  1. Pick a layer count. Factor your target into (per layer) × (layers). For 38 spheres, 19 × 2 is the natural split; 14 × 3 (= 42, four spare) is also workable if you prefer more layers.
  2. Set the radius from the per-layer count using the ratio table. Nineteen per layer needs R ÷ r ≥ 4.86, so for radius-2 spheres, R ≥ 9.72 cm. Round up to 10.
  3. Set the height from the layer count: H = layers × 2r. Two layers of radius-2 spheres need H = 2 × 4 = 8 cm. A little extra clearance (0.5 to 2 cm) helps in practice.

You'll often find more than one valid cylinder. A tall-narrow one (few per layer, many layers) and a short-wide one (many per layer, few layers) can hold the same count, with different surface areas. That matters if you're paying for material. You can check the container capacity with the Cylinder Volume Calculator.

The Surface-Area-Limited Version

A common twist fixes the cylinder's total surface area: "what's the most spheres I can pack if the container's surface area is 1,000 cm²?" The constraint is the standard closed-cylinder formula:

Surface area = 2πR² + 2πRH = 2πR(R + H)

Set that equal to your budget and you get a relationship between R and H. Then it's a search: for each workable radius, the equation gives you the matching height, you compute spheres-per-layer × layers, and you keep whichever pair holds the most. Wider cylinders win more per layer but cost height; taller ones win on layers but waste area on the curved wall.

The sweet spot is usually a moderately squat cylinder. Rather than grind through it by hand, this is exactly the trade-off the Sphere Packing Calculator is built to solve.

Whether you're packing a container or just working with cylinders, these will save you time:

Packing into a box instead? See our companion guide on finding the optimal box dimensions to pack 27 spheres: a simpler calculation that uses the same diameter-per-axis formula.

Frequently Asked Questions

How do you calculate how many spheres fit in a cylinder?

Multiply the spheres per layer by the number of layers. Spheres per layer comes from the radius ratio (R ÷ r) using a circle-packing table; the number of layers is ⌊H ÷ 2r⌋, the height divided by the sphere diameter, rounded down.

How many radius-2 spheres fit in a cylinder of radius 10 and height 11?

About 38 with simple stacking: 19 spheres per layer (ratio 5.0) across 2 layers (⌊11 ÷ 4⌋ = 2). A nested arrangement can fit a third layer and push the total higher.

Why does r = 10, h = 11 hold 38 spheres?

A radius ratio of 10 ÷ 2 = 5.0 clears the 4.86 threshold for 19 spheres per layer, and a height of 11 cm gives 2 layers (⌊11 ÷ 4⌋ = 2). Nineteen times two is 38.

How many spheres fit in one layer of a cylinder?

It depends on the radius ratio R ÷ r. At a ratio of 3 you get 7 (a centre sphere plus a ring of 6). Higher ratios fit more: roughly 9 at a ratio of 3.6, 12 at 4.0, and 19 at 4.9. When you're between two thresholds, always round down.

What is the minimum cylinder radius to hold 38 spheres of radius 2?

For two layers of 19 you need a radius ratio of at least 4.86, so R ≥ 4.86 × 2 = 9.72 cm, rounded up to 10 cm. Height needs to be at least 2 × 4 = 8 cm for two layers.

Does nesting the layers really fit more spheres?

Yes. Settling each layer into the gaps of the one below shrinks the layer spacing from 2r to about 1.63r, fitting roughly 15% more layers in the same height. It's harder to calculate by hand, so use simple stacking as your baseline and the Sphere Packing Calculator to confirm a nested result.

What if the cylinder's surface area is fixed?

Use 2πR(R + H) = your area budget to link radius and height, then test radius values to see which pairing packs the most spheres. A moderately squat cylinder usually wins over a tall-thin or short-wide extreme.

What is the packing density inside a cylinder?

Simple stacking in a cylinder reaches roughly 52% density, similar to a box arranged in a grid. Nested hexagonal stacking can push this to around 60% or more, depending on the radius ratio and how well the outermost ring of each layer fits the curved wall.

How does packing in a cylinder differ from packing in a rectangular box?

In a box, every dimension is independent: divide length, width, and height by the diameter, round down, and multiply. In a cylinder, the cross-section is circular, so the per-layer count doesn't follow a simple division formula. It depends on the radius ratio and the geometry of fitting circles inside a circle.

What is the formula for the cylinder height that holds a given number of layers?

For simple stacking: H = layers × 2r, where r is the sphere radius. Three layers of radius-2 spheres need H = 3 × 4 = 12 cm. Add a small clearance margin (0.5 to 2 cm) for real-world containers to ensure the lid closes without pressing on the top layer.

Key Takeaways

Sphere packing in a cylinder looks complex but reduces to two easy questions: how many spheres per layer (set by the radius ratio R ÷ r) and how many layers (set by the height). Multiply them and you're done. The cleanest case is a ratio of 3, giving 7 spheres per layer; a radius-10, height-11 cylinder holds 38 radius-2 spheres across two wide layers of 19. Simple stacking gives a reliable answer every time, and nesting the layers squeezes out a bit more if you need it.

When you'd rather skip the table lookups, the Sphere Packing Calculator does the whole thing in one step: box or cylinder, with or without nesting.