Wikipedia:Reference desk/Archives/Mathematics/2023 December 9

Mathematics desk
< December 8 << Nov | December | Jan >> Current desk >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


December 9

edit

Longest cylinder in a box

edit

Given a rectilinear box with interior dimensions a,b,c, what is the longest cylinder of radius r that can fit in the box?
In the limit of r=0, the answer is just to place the cylinder along the space diagonal, so the length would be  . But with a nonzero r, the geometry of how the cylinder meets the corner of the box seems rather complicated. Is there an easy way to solve this? CodeTalker (talk) 18:31, 9 December 2023 (UTC)[reply]

Don't expect an easy solution. An easy non-trivial lower bound on the length is given by   where   but if   it is not strict. In the general case the axis of the cylinder will not be aligned with a diagonal, but wlog the centres of box and cylinder can be made to coincide. It is tempting to assume that the longest fitting cylinder necessarily touches all six sides, but I don't think this is actually the case.  --Lambiam 20:42, 9 December 2023 (UTC)[reply]
Just to clarify a bit, by a cylinder I assume you mean a right circular cylinder. And I'm going to assume (see the previous comment) that the cylinder touches all three side. If that's not the case then the problem reduces to find the longest rectangle with one side 2r that fits into a give rectangle, and that seems easier. Perhaps that problem should be solved first to get an idea how intractable things will get when you add a dimension. I think you can simplify things a bit by using symmetry. Double the size of the box and place it so the coordinates of the corners are (±a, ±b, ±c) This will double the length of the cylinder. Then by symmetry the origin is at the midpoint of the axis, so halve the length by only considering the length from the origin to an endpoint. Say the endpoint is E = (d, e, f). Let Pa = (a, y, z) be the point at which the end of the cylinder touches the side x=a. We know three things about this point: 1) It's on both the planes x=a and (d, e, f)⋅(x, y, z) = (d, e, f)⋅(d, e, f). 2) Its distance from E is r. 3) Of the points on the line of intersection of the planes x=a and (d, e, f)⋅(x, y, z) = (d, e, f)⋅(d, e, f), Pa is the closest to E. 3 implies Pa is a linear combination of (d, e, f) and (1, 0, 0) by Lagrange multipliers, so Pa can be written (a, ue, uf). Define Pb and Pc similarly and we get Pb = (vd, b, vf), Pc = (wd, we, c). We now have six unknowns d, e, f, u, v, w, and six equations from 1 and 2. There may be better ways of doing it, but that's how I would approach the problem. I haven't done all the algebra required to get to the final answer though. --RDBury (talk) 21:01, 9 December 2023 (UTC)[reply]
The same question was asked on StackExchange here, with no solution posted, while a version with a specified ratio   was asked here. The latter one also has no solutions but contains the onset of a path that might lead to a solution; I have not tried to assess the correctness of the steps taken.  --Lambiam 21:07, 9 December 2023 (UTC)[reply]
The section details for the Wolfram Demonstrations Project "Tube in a Cube" confirms that the longest cylinder is not always in diagonal position. The statement that a numerical root search is used to find the solution for the diagonal case strongly suggests there is no algebraic solution for the general diagonal case. The text also refers to the paper "Straw in a Box", which I haven't read.  --Lambiam 11:22, 11 December 2023 (UTC)[reply]
I've just read through Straw in a Box; it does yield a solution for the length of the longest cylinder along the space diagonal in terms of the root of an equation (well, technically eight equations, one must choose   that yields the longest cylinder), and according to them said equation yields a polynomial when it is squared 3 times, but that polynomial is of degree 16 in terms of the square of the length, and is thus for all intents and purposes too complicated to solve algebraically. But if you do manage to solve the equation for the length of the cylinder, then they also have equations for the coordinates of the centers of the circles forming the bases of the cylinder given that length. GalacticShoe (talk) 17:30, 11 December 2023 (UTC)[reply]
The "Straw in a Box" article does seem to address the problem as much as can be feasibly, though I haven't looked at in detail. I think it would be helpful, as I hinted at above, to use the two dimensional case as a starting point. The 2D problem is to find the longest rectangle with one side of fixed length 2r, that fits in a given rectangle with sides a and b. The article sets the origin to one of the corners, but I still think the problem is easier if you set the origin to the center. I think it simplifies things as well to look at the problem from the other direction; instead of inscribing the smaller rectangle in the larger one, circumscribe the larger one around the smaller one. So if the "axis" of the inner rectangle (i.e. line joining the midpoints of the sides of length 2r) is from (0, 0) to (d, e). Then it's not too hard to see that if the circumscribing rectangle goes from -a to a in the x direction and from -b to b in the y direction:
 
This isn't too bad, and the real trick is solving for d and e.
Returning to three dimensions, the reversed problem might be stated as: Given a cylinder with axis from (-d, -e, -f) to (d, e, f) and radius r, find the smallest a, b, c so that the box from -a to a in the x direction, from -b to b in the y direction and from -c to c in the z direction contains the cylinder. While not exactly trivial, this problem does seem doable without having to solve higher order algebraic equations.. --RDBury (talk) 01:22, 12 December 2023 (UTC)[reply]
Elimination of   from the pair of equations for a planar diagonal results in a sextic equation in   so it appears that in the general 2D case one also needs to resort to numerical methods. Equivalently, one can use the pair of non-algebraic equations
 
in the unknowns   and   Given a solution, use    --Lambiam 11:17, 12 December 2023 (UTC)[reply]
You cas use the substitution cos φ = (1-u2)/(1+u2), sin φ = 2u/(1+u2) to turn the trigonometric system back into an algebraic system, and there are other substitutions you can try. But if there is a simple formula I couldn't find it. The original question was whether there is an easy way to solve the problem; I'd say the short answer is no. Unless there's some clever way to approach it that everyone is missing. --RDBury (talk) 20:03, 12 December 2023 (UTC)[reply]