Distance between two circles on a cube I found this problem in a book on undergraduate maths in the Soviet Union (http://www.ftpi.umn.edu/shifman/ComradeEinstein.pdf):

A circle is inscribed in a face of a cube of side a. Another circle is circumscribed about a neighboring face of the cube. Find the least distance between points of the circles.

The solution to the problem is in the book (page 61), but I am wondering how to find the maximum distance between points of the circles and I cannot see how the method used there can be used to find this.

I placed the inscribed circle on the top face (+y direction) and the circumscribed circle on the front face (+z direction). Their locus of points is
$$ \begin{align} 
\vec{r}_1 & = \begin{bmatrix} r_1 \cos \theta_1 & \frac{a}{2} & r_1 \sin \theta_1 \end{bmatrix} \\
\vec{r}_2 & = \begin{bmatrix} r_2 \cos \theta_2 & r_2 \sin \theta_2 & \frac{a}{2} \end{bmatrix} 
\end{align} $$
where $r_1 = \frac{a}{2}$, $r_2 = \frac{a}{\sqrt{2}}$ and $a$ is the side of the cube.
The distance (squared) is $$d^2 = \| \vec{r}_1 -\vec{r}_2 \|^2 $$ which is a function of $\theta_1$ and $\theta_2$.
It comes out as
$$ \frac{d^2}{a^2} = \frac{5}{4} - \frac{\sqrt{2} \cos\theta_1 \cos \theta_2 + \sin \theta_1 + \sqrt{2} \sin \theta_2}{2} $$
To minimize this you have to set $$\frac{\partial}{\partial \theta_1} \frac{d^2}{a^2} = 0$$ and at the same time $$\frac{\partial}{\partial \theta_2} \frac{d^2}{a^2} = 0$$
The system to solve is $$\begin{align} \frac{\sin \theta_1 \cos \theta_2}{\sqrt{2}} - \frac{\cos\theta_1}{2} & = 0 \\ \frac{\cos \theta_1 \sin \theta_2}{\sqrt{2}} - \frac{\cos\theta_2}{\sqrt{2}} & = 0 \end{align} $$
From the first equation $\cos \theta_2 = \frac{\cot \theta_1}{\sqrt{2}}$. When used in the second equation I get $\theta_1 = \arctan \sqrt{2}$.
The result I get was $$\frac{d^2}{a^2} = \frac{5}{4} - \frac{\sqrt{6}}{2} $$
