# Tube in a Cube

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram CDF Player or other Wolfram Language products.

Requires a Wolfram Notebook System

Edit on desktop, mobile and cloud with any Wolfram Language product.

For a given cylinder radius, this Demonstration finds the maximum-length cylinder that fits inside a rectangular box. For a cylinder radius approaching zero, the maximum-length cylinder lies on the diagonal connecting the opposite corners of the box. However, as the cylinder radius is increased, the longest cylinders lie along the longest dimension of the box.

Contributed by: Ed Bukhman and Daniel Lichtblau (March 2011)

Open content licensed under CC BY-NC-SA

## Snapshots

## Details

There are three relevant solution states for the problem: (A) the cylinder lies diagonally in the box, (B) the cylinder is diagonal in the plane of one of the sides, and (C) the cylinder lies lengthwise along the longest dimension of the box. The solution resulting in the longest cylinder length is chosen. Solution C is trivial, and solution B is found by projecting the cylinder onto one of the box sides, resulting in a picture like this: . The cylinder length can then be found by solving the fourth-degree polynomial equation for the value of the dihedral angle formed by the sides of the larger green rectangle and the smaller red one (the variable twodsol contains the relevant solution).

One approach to obtaining solution A is to find the center of the circular rim of the cylinder. The distance between this point and a similar point on the opposite end of the cylinder is the cylinder length. To find the coordinates of the center, solve a system of nine equations with nine unknowns, which are the coordinates of the three points at which the rim is tangent to the coordinate planes, translated so that the center point lies at the origin. Given the vector normal to the plane of the rim, , and the radius of the cylinder, , gives three sets of three equations: the distance between each of the three tangent points and the center is ; the vector normal and the vector differences between the tangent points and the center are perpendicular, and their dot products are zero; the intersections of the plane of the rim with each of the coordinate planes simultaneously lie in a coordinate plane and the rim planes and are tangent to the rim, each one perpendicular to an appropriate difference vector, just as the cross product of the vector normal and the difference vector lies in the plane of the rim and perpendicular to the difference vector. This vector will thus lie parallel to an appropriate coordinate plane and will have a component equal to zero. The resulting system is solved, translated back, and the solution that lies in the positive orthant is chosen. Finally, a numerical root search is used to obtain the vector normal that maximizes the length of a cylinder lying diagonally.

Another approach to this problem is found in [1].

Reference

[1] R. Jerrard, J. Schneider, R. Smallberg, and J. Wetzel, "Straw in a Box," *The College Mathematics Journal*, 37(2), 2006 pp. 93–102.

## Permanent Citation