Let point A be on a diagonal of one side of a cube. Let point B be on a diagonal of an adjacent side of the cube such that the two diagonals do not meet at a vertex.
Minimize the distance AB.
Oh boy, time to dust off the Linear Algebra!
Put the cube on a grid. Let one diagonal be from (0,0,0) to (1,1,0) and the other diagonal be (1,0,0) to (1,1,1).
Express each line in point-vector form L = V*t + P
Then the first diagonal is L1 = (1,1,0)*t1 + (0,0,0)
And the second diagonal is L2 = (0,1,1)*t2 + (1,0,0)
The line L3 that contains the shortest segment between L1 and L2 is orthogonal to both L1 and L2. Then V3 is easily calculated to be the cross product: (1,1,0) X (0,1,1) = (1,-1,1).
For any pair of points on L1 and L2 a vector L1-L2 can be formed. When that vector matches V3 then we will have points on line L3.
Then L1-L2 = ((1,1,0)*t1 + (0,0,0)) - ((0,1,1)*t2 + (1,0,0)) = V3*t3 = (1,-1,1)*t3.
Rearrange a bit to put the vectors on one side and the points on the other: (1,1,0)*t1 + (0,-1,-1)*t2 + (-1,1,-1)*t3 = (1,0,0).
This is pretty easy to solve, just load the vectors as columns in a matrix and find its reduced row echelon form:
[ 1 0 -1 1 ] [ 1 0 0 2/3 ]
rref [ 1 -1 1 0 ] = [ 0 1 0 1/3 ]
[ 0 -1 -1 0 ] [ 0 0 1 -1/3 ]
The important values are the first two in the last column which yield t1=2/3 and t2=1/3. Then the pair of closest points on L1 and L2 are (1,1,0)*(1/3) + (0,0,0) = (2/3,2/3,0) and (0,1,1)*(1/3) + (1,0,0) = (1,1/3,1/3).
The distance between (2/3,2/3,0) and (1,1/3,1/3) equals sqrt[(1/3)^2+(1/3)^2+(1/3)^2] = sqrt(1/3).