Monday, March 28, 2022

Xiddlerian Algorithm

The astronomers of Planet Xiddler are back at it. They have developed a new technology for measuring the radius of a planet by analyzing its cross sections.

And so, they launch a satellite to study a newly discovered, spherical planet. The satellite sends back data about three parallel, equally spaced circular cross sections which have radii $A$, $B$ and $C$ megameters, with $0 \lt A \lt B \lt C.$ Based on these values, the scientists calculate the radius of the planet is $R$ megameters. To their astonishment, they find that $A$, $B$, $C$ and $R$ are all whole numbers!

What is the smallest possible radius of the newly discovered planet?

Let's first discuss the method to the Xiddlerian algorithmic madness. Setting up a reference frame, let's assume that we rotate the newly discovered planet so that the cross sections are parallel to the $xy$-plane and that the smallest cross section has the largest value of $z$, at say $z = k.$ Let's additionally assume that the equal distance between each cross section is $h$ for some $0 \lt h \lt R.$ Then we have the following system of equations: \begin{align*} A^2 + k^2 &= R^2 \\ B^2 + (k-h)^2 &= R^2 \\ C^2 + (k-2h)^2 &= R^2\end{align*} where $0 \lt h \lt k \lt R$ are unknown.

By taking the difference between the first two equations we get the hyperbola $$(k-h)^2 - k^2 + B^2 - A^2 = h^2 - 2kh + B^2 - A^2 = 0$$ or equivalently $$h = k \pm \sqrt{k^2 - B^2 + A^2}.$$ Naturally, since we want $h \lt k,$ we need to choose the lower branch of the hyperbola, that is $$h_1(k) = k - \sqrt{k^2 - B^2 + A^2}.$$ Similarly, by taking the difference between the first and last equations, we get the hyperbola $$(k-2h)^2 - k^2 + C^2 - A^2 = 4h^2 -4kh + C^2 - A^2 = 0$$ or equivalently $$h = \frac{k \pm \sqrt{k^2 - C^2 + A^2}}{2}.$$ Here, again, we can safely choose the lower branch since otherwise we are not guaranteed to have $(k-2h)^2 \lt (k-h)^2$ (which is equivalent to $B \lt C$), that is $$h_2(k) = \frac{k - \sqrt{k^2 - C^2 + A^2}}{2}.$$

The intersection of these two curves occurs when $$k = 2 \sqrt{k^2 - B^2 + A^2} - \sqrt{k^2 - C^2 + A^2}.$$ Squaring both sides gives $$k^2 = 4(k^2 - B^2 + A^2) - 4\sqrt{k^2 - B^2 + A^2}\sqrt{k^2 - C^2 + A^2} + (k^2 - C^2 + A^2),$$ or equivalently $$4 \sqrt{k^2 - B^2 + A^2} \sqrt{k^2 - C^2 + A^2} = 4k^2 - 4(B^2-A^2) - (C^2 - A^2).$$ Squaring both sides again gives $$16 (k^2 - B^2 + A^2) (k^2 - C^2 + A^2) = (4k^2 - 4(B^2 - A^2) - (C^2 -A^2))^2$$ or equivalently \begin{align*}0 &= 16k^4 - 16((B^2 - A^2) + (C^2 - A^2)) k^2 + (A^2 - B^2)(C^2 - A^2) \\ \quad\quad & \quad\quad\quad -16 k^4 + 8(4(B^2 - A^2) + (C^2 - A^2)) k^2 + (4(B^2 - A^2) + (C^2 - A^2))^2 \\ &= 8(2(B^2 - A^2) - (C^2 - A^2)) k^2 - (4(B^2 -A^2) + (C^2 - A^2))^2 + 16(C^2-A^2)(B^2-A^2) \\ &= 8 (2(B^2 - A^2) - (C^2 - A^2))k^2 - (4(B^2 - A^2) - (C^2 - A^2))^2.\end{align*} That is, $$k^2 = \frac{(4(B^2 - A^2) - (C^2 - A^2))^2 }{ 8(2(B^2 - A^2) - (C^2 - A^2)) } = \frac{(4B^2 -3A^2 -C^2)^2}{8(2B^2 - A^2 - C^2)}$$ and hence \begin{align*}R^2 &= A^2 + k^2 = A^2 + \frac{(4B^2 - 3A^2 - C^2)^2}{8(2B^2 - A^2 - C^2)} \\ &= \frac{8A^2 (2B^2 - A^2 - C^2) + (4B^2 - 3A^2 - C^2)^2}{8(2B^2 - A^2 - C^2)} \\ &= B^2 + \frac{(C^2 - A^2)^2}{8(2B^2 - A^2 - C^2)}\end{align*} That is, $$R = R(A,B,C) = \sqrt{ B^2 + \frac{(C^2 - A^2)^2}{8(2B^2 - A^2 - C^2)}}.$$

So we can just about start hunting and pecking for suitable triples $(A, B, C) \in \mathbb{N}^3$ such that $R \in \mathbb{N},$ but we can narrow the search by including $0 \lt A \lt B \lt C \lt R.$ Additionally, since $k^2$ must be a positive integer we must additionally have $8 \mid (C^2 - A^2)^2$ and $2B^2 - A^2 - C^2 \gt 0.$ The first conclusion is equivalent to the condition that $A \equiv C \mod 2,$ while the second conclusion ensures that we must have $C \lt \sqrt{2B^2 - A^2}$. After a while of hunting an pecking, we see that $(2, 7, 8)$ yields $R(A,B,C) = 8.$ An exhaustive search of triples $A \lt B \lt C \lt 8$ with $A \equiv C \mod 2$ and $C \lt \sqrt{2B^2 - A^2}$ reveals only four valid competitors: \begin{align*} (1,4,5) &\Rightarrow R(1, 4, 5) = 4\sqrt{7} \\ (1,6,7) &\Rightarrow R(1,6,7) = \frac{6\sqrt{165}}{11} \\ (2,5,6) &\Rightarrow R(2,5,6) = \frac{5 \sqrt{22}}{4} \\ (3,6,7) &\Rightarrow R(3,6,7) = \frac{4\sqrt{154}}{7}\end{align*} Since each of the competitors does not produce a sufficiently whole numbered $R$, the smallest radius the newly discovered planet can be is $8 = R(2,7,8)$ megameters.

Sunday, March 6, 2022

Geo and Desik's Conical Adventures

Two ants named Geo and Desik are racing along the surface of a cone. The circular base of the cone has a radius of $2$ meters and a slant height of $4$ meters. Geo and Desik both start the race on the base, a distance of 1 meter away from its center.

The race’s finish is halfway up the cone, $90$ degrees around the cone’s central axis from the start, as shown in the following diagram:

Geo and Desik both want your help in strategizing for the race. What is the length of the shortest path from the start to the finish?

Geo and Desik agree to a reference frame with which to work on devising the shortest path from start, $S,$ to finish, $F.$ They place the $x$-axis along the hyperplane that is perpendicular to the base and through the point $F,$ and the $y$-axis along the radius of the base containing $S,$ thus they conclude that $F = (-1,0,\sqrt{3})$ and $S = (0,-1,0).$

Desik decides to set up the optimization problem in two phases: (i) travel from $S$ along the circular base of the cone until you reach the conical surface and (ii) travel along the conical surface to $F.$ Desik knows that for any last point on the circular base, say $P,$ the fastest path from $S$ to $P$ is a straight line, but he is wary of assuming the same along conical surfaces.

Geo thinks geometrically and reasons that since cones have zero Gaussian curvature, he can cut along any meridian of the cone and unroll the resulting surface into a planar surface. In this case, let's say that we cut along the plane $y=0$ and then align that cut on a new $uv$-plane along the $v$-axis, such that the finish point $F$ is now located at $F=(0,2)$ and the flattened surface lies in the $u \lt 0$ halfspace. Since the slant height is the same for every point along the base of the cone, the flattened conical surface must be a circular sector of radius $R = 4.$ Furthermore, since the circumference of the base of the cone is $C = 4\pi,$ then the flattened cone must be a semi-circle of radius $R=4$ since the sector angle is $C / R = \pi.$

Geo continues explaining to Desik that in the flattened cone case, the finish point at $F = (0,2)$ on the $uv$-plane has a mirrored point $F^\prime = (0,-2),$ since in the unflatted cone case the upper and lower v-axes would be glued together. So in order to find the shortest distance from any point along the perimeter of the semi-circle, say $(-4\sin \kappa, 4\cos \kappa)$, to the $F$ we would want to take \begin{align*}d_1(\kappa) & = \min \{ \sqrt{ 16\sin^2 \kappa + (4\cos \kappa -2)^2 } , \sqrt{ 16 \sin^2 \kappa + (4 \cos \kappa + 2)^2 } \} \\ &= \min \{ 2\sqrt{5-4\cos \kappa}, 2\sqrt{5+4\cos \kappa} \}.\end{align*} The only point that Geo then needs to remind Desik of is that this angle $\kappa$ in the $uv$-plane is equivalently drawn from the apex of the cone to some point on the $xy$-plane in the original cone. In this case, since the radius of the base of the cone is $r = 2$ but the circular arc is the same length, Geo argues that in the $xy$-plane this arc should subtend an angle of $\kappa \frac{R}{r} = 2\kappa$ as in the picture below. That is, the point $(-4\sin \kappa, 4 \cos \kappa)$ in the $uv$-plane corresponds to the point $(-2\sin 2\kappa, 2\cos 2\kappa, 0)$ on the original cone. Therefore, the straight line distance from the start to this point is $$d_2(\kappa) = \sqrt{ (-2\sin 2\kappa + 1)^2 + 4\cos^2 2\kappa } = \sqrt{5 - 4\sin 2\kappa}.$$

Having successfully understood Geo's geometric handwaving, Desik sets up the optimization problem $\min \{ D(\kappa) \mid 0 \leq \kappa \lt \pi \},$ where \begin{align*}D(\kappa) &= d_1(\kappa) + d_2(\kappa)\\ &= \begin{cases} 2\sqrt{5- 4\cos \kappa} + \sqrt{5-4\sin 2\kappa}, &\text{when $\cos \kappa \geq 0$} \\ 2\sqrt{5+4\cos \kappa} + \sqrt{5-4\sin 2\kappa} , &\text{when $\cos \kappa \lt 0$.}\end{cases}\end{align*} Differentiating, we have $$\frac{dD}{d\kappa} =\begin{cases} \frac{4\sin \kappa}{\sqrt{5-4\cos \kappa}} - \frac{4 \cos 2\kappa}{\sqrt{5- 4\sin 2\kappa}}, &\text{when $\cos \kappa \gt 0$}\\ undefined, &\text{when $\cos \kappa = 0$} \\ -\frac{4 \sin \kappa}{\sqrt{5 + 4\cos \kappa}} - \frac{4 \cos 2\kappa}{\sqrt{5 -4\sin 2\kappa}}, &\text{ when $\cos \kappa \lt 0$.}\end{cases}$$ The minimum of $D$ will occur on $[0,\pi]$ either at an endpoint or a critical point, that is, where either $\frac{dD}{d\kappa} = 0$ or $\frac{dD}{d\kappa}$ is undefined. In the prior case, the only such solution within $0 \leq \kappa \lt \pi$ is $\kappa^* = \frac{\pi}{6};$ whereas, in the latter case, the only solution in $[0,\pi]$ is $\kappa^* = \frac{\pi}{2}.$ Thus evaluating $D(0) = D(\pi),$ $D(\pi/6),$ and $D(\pi/2),$ we see that Geo's and Desik's minimial distance from start to finish is $D(\pi/6) = 3\sqrt{5-2\sqrt{3}}.$