Sunday, June 14, 2026

The average wave

Another wave is approaching the island, but no one knows which direction it’s coming from—for the moment, all directions are equally likely. On average, what is the length of the stretch of land directly under the wave halfway between when the wave first and last makes contact with the island?

Using our function $$\ell (\theta) = \min \left\{ \sqrt{(3 - \cos \theta) (1 + \cos \theta)}, \frac{ \tan \theta (1- \cos \theta) + \sqrt{(3-\cos \theta) (1 + \cos \theta)}}{2} \right\}$$ from the Classic answer along with the symmetry arguments that we made there to come to the conclusion that the average length of the stretch of land is \begin{align*}\bar{\ell} &= \int_0^{\pi/2} \ell(\theta) \frac{ 2d\theta }{ \pi } = \frac{2}{\pi} \int_0^{\cos^{-1} 1/3} \frac{ \tan \theta ( 1- \cos \theta) + \sqrt{(3 - \cos \theta) (1 + \cos \theta) }}{2} \,d\theta \\ &\quad\quad\quad\quad\quad\quad\quad\quad\quad + \frac{2}{\pi} \int_{\cos^{-1} 1/3}^{\pi/2} \sqrt{ (3 - \cos \theta) (1 + \cos \theta) } \,d\theta \end{align*}

Well that is certainly a mouthful, but we can break it into some pieces and come up with an analytical solution. First we see that if we rewrite the portion under the radical as $$\frac{\sqrt{(3 - \cos \theta)( 1 + \cos \theta) }}{2} = \sqrt{ 1- \left(\frac{1-\cos \theta}{2} \right)^2}$$ that we can do some trigonometrical simplifications and substitutions. So in particular we see that since $\sin \frac{\theta}{2} = \sqrt{ \frac{1-cos \theta}{2} }$ when $\theta \in (0, \frac{\pi}{2}),$ then we get \begin{align*}\int \sqrt{ 1- \left( \frac{ 1 - \cos \theta }{2} \right)^2 } \,d\theta &= \int \sqrt{ 1 - \sin^4 \frac{\theta}{2} } \,d\theta \\&= \int \sqrt{ \left( 1 - \sin^2 \frac{\theta}{2} \right) \left( 1 + \sin^2 \frac{\theta}{2} \right) } \,d\theta \\ &= \int \cos \frac{\theta}{2} \sqrt{ 1 + \sin^2 \frac{\theta}{2} } \,d\theta \\ &= 2\int \sqrt{1 + u^2} \,du,\end{align*} where the last equation involves the substitution of $u = \sin \frac{\theta}{2}.$ Using integration by parts, we get $$\int \sqrt{1+u^2} \,du = u \sqrt{1 + u^2} - \int \frac{u^2 \,du}{\sqrt{1+u^2}} = u \sqrt{1+u^2} + \int \frac{du}{\sqrt{1+u^2}} - \int \sqrt{ 1 + u^2 } \,du,$$ so that we get $$\int \sqrt{1+u^2} \,du = \frac{1}{2} \left( u \sqrt{1 + u^2} + \int \frac{du}{\sqrt{1+u^2}} \right) = \frac{1}{2} \left( u \sqrt{1+ u^2} + \sinh^{-1} u\right) + C.$$ Therefore we see that \begin{align*}\int \frac{ \sqrt{ (3-\cos \theta) (1 + \cos \theta) } }{2} \,d\theta &= \int \sqrt{ 1 - \left( \frac{1 - \cos \theta}{2} \right)^2 } \,d\theta \\ &= \sin \frac{\theta}{2} \sqrt{ 1 + \sin^2 \frac{\theta}{2} } + \sinh^{-1} \left(\sin \frac{\theta}{2}\right) + C.\end{align*} Similarly, but with a lot less fuss, we can get $$\int \frac{\tan \theta (1 - \cos \theta)}{2} \,d\theta = -\frac{1}{2} \ln | \cos \theta | + \frac{\cos \theta}{2} + C.$$

Therefore the the first integral \begin{align*}I_1 &= \frac{2}{\pi} \int_0^{\cos^{-1} 1/3} \frac{ \tan \theta (1 - \cos \theta) }{2} + \sqrt{ 1 - \left( \frac{1-\cos \theta}{2} \right)^2 } \,d\theta \\ &= \frac{2}{\pi}\left[ -\frac{1}{2} \ln | \cos \theta | - \frac{\cos \theta}{2} + \sin \frac{\theta}{2} \sqrt{ 1 + \sin^2 \frac{\theta}{2} } + \sinh^{-1} \left( \sin \frac{\theta}{2} \right) \right]^{\theta = \cos^{-1} 1/3}_{\theta = 0} \\ &= \frac{2}{\pi}\left( -\frac{1}{2} \ln \frac{1}{3} + \frac{1}{6} + \sqrt{ \frac{ 1 - \frac{1}{3}}{2}} \sqrt{ 1 + \left(\sqrt{ \frac{ 1 - \frac{1}{3} }{2} }\right)^2 } + \sinh^{-1} \sqrt{ \frac{1 - \frac{1}{3}}{2} } \right) \\ &\quad\quad\quad\quad\quad - \frac{2}{\pi}(0 + \frac{1}{2} + 0 + 0) \\ &= \frac{2}{\pi} \left(\frac{1}{2} \ln 3 + \frac{1}{3} + \sinh^{-1} \sqrt{\frac{1}{3}} \right) \\ &= \frac{2}{\pi}\ln 3 + \frac{2}{3\pi}, \end{align*} since $\sinh^{-1} t = \ln ( t + \sqrt{ 1 + t^2} ),$ so $$\sinh^{-1} \sqrt{\frac{1}{3}} = \ln \left( \sqrt{\frac{1}{3}} + \sqrt{1 + \frac{1}{3}} \right) = \ln \left( \sqrt{\frac{1}{3}} + \sqrt{ \frac{4}{3}} \right) = \ln \left( 3 \sqrt{\frac{1}{3}} \right) = \ln \sqrt{3} = \frac{1}{2} \ln 3.$$ The second integral is \begin{align*}I_2 &= \frac{4}{\pi} \int_{\cos^{-1} 1/3}^{\pi/2} \sqrt{ 1 - \left( \frac{1 - \cos \theta}{2} \right)^2 } \,d\theta \\ &= \frac{4}{\pi} \left[ \sin \frac{\theta}{2} \sqrt{ 1 + \sin^2 \frac{\theta}{2} } + \sinh^{-1} ( \sin \frac{\theta}{2} ) \right]_{\theta=\cos^{-1} 1/3}^{\theta=\pi/2} \\ &= \frac{4}{\pi} \left( \frac{1}{\sqrt{2}} \cdot \sqrt{1+\frac{1}{2}} + \sinh^{-1}\frac{1}{ \sqrt{2}} \right) \\ &\quad\quad\quad - \frac{4}{\pi} \left( \sqrt{ \frac{ 1 - \frac{1}{3}}{2}} \sqrt{ 1 + \left(\sqrt{ \frac{ 1 - \frac{1}{3} }{2} }\right)^2 } + \sinh^{-1} \sqrt{ \frac{1 - \frac{1}{3}}{2} } \right) \\ &= \frac{4}{\pi} \left( \frac{\sqrt{3}}{2} + \sinh^{-1} \frac{1}{\sqrt{2}} - \frac{2}{3} - \frac{1}{2} \ln 3 \right)\end{align*} Putting this all together and taking advantage of some beneficial cancelling, we get that the average length of the stretch of land covered by the wave at 10:05 a.m. if all directions for it to approach Semicircle Island are equally likely is $$\bar{\ell} = I_1 + I_2 = \frac{4}{\pi} \left( \frac{ \sqrt{3}}{2} + \sinh^{-1} \frac{1}{\sqrt{2}} \right) - \frac{2}{\pi} \approx 1.30443945503\dots$$ miles.

The longest wave

Semicircle Island is shaped like a perfect semicircle (or semidisk, technically), with a radius of $1$ mile. It doesn’t have any permanent residents, but it’s a very popular destination for surfers.

Rumor has it that a big wave is headed toward the island. This thin, straight wall of water never changes speed or direction. It will first make contact with the island at 10 a.m. and it will last be in contact with the island at 10:10 a.m. What is the longest possible stretch of land that is directly under the wave at 10:05 a.m.?

With my deepest apologies for my bad Paint skills, let's use a modified version of picture from the Extra Credit prompt and note that I inserted a ray that is perpendicular to the direction of travel of the wave that happens to make an angle of $\theta$ with the positive $x$-axis.

Let's assume that the center of the semi-disk is the point $(0,0),$ the place where the wave first hits the island is at the point $(\cos \theta, \sin \theta)$ and the formula for the ray connecting the origin and this point is $y = x \tan \theta$ as long as $\theta \ne \frac{\pi}{2}.$ Since the wave is perpendicular to this ray, the wave's slope must be the negative reciprocal of that of the ray, so we have the fomula for the wave at 10:00 a.m. is $y= -x \cot \theta + \csc \theta,$ which works as long as $x \not\in \{ 0, \pi\}.$ We similarly see that since the wave at each future point will be parallel to this line that the equation that models the position of the wave at 10:10 a.m. is either $y= -(x+1) \cot \theta,$ if $\theta \in (0, \frac{\pi}{2}),$ or $y = -(x-1) \cot \theta$ if $\theta \in ( \frac{\pi}{2}, \pi ).$ For simplicity, and by symmetry let's just assume going forward that $\theta \in (0, \frac{\pi}{2}).$ In this case, we see that the formula that models the position of the wave at 10:05 a.m., based on the uniform motion of the wave, is then $$y = -x \cot \theta + \frac{\left(\csc \theta + (-\cot \theta)\right)}{2} = -x \cot \theta + \frac{1 - \cos \theta}{2 \sin \theta}.$$

Let's pause here and think about what the length of a chord of a full circle would be. For simplicity let's assume that the chord is parallel to the $x$-axis, at say $y = h.$ In this case, we see that the endpoints of the chord are at $(\pm \sqrt{1-h^2}, h),$ so the length of the curve is $2\sqrt{1-h^2}.$ We further notice that if we rotate the entire $xy$-plane clockwise by angle $\frac{\pi}{2} - \theta,$ then the positive $y$-axis would be mapped to the ray $y= x \tan \theta,$ as we had before. In the case of the circle case, the chord length is obviously preserved in this orthogonal rotation, but now we want to only include the portion of the rotated chord that is now above the $x$-axis. We see that the portion of the chord that was in quadrant II before the rotation is still definitely in the upper half-plane post-rotation, so we should get at least $\sqrt{1-h^2}.$ The only thing to calculate is how much of the half-chord that was in the quadrant I. Firstly, it is perhaps the case depending on the height $h$ and rotational angle $\theta$ that the entirety of the half-chord is in the upper half-plane post-rotation, so the maximum that we could ever get is $\sqrt{1-h^2}.$ On the other hand, if we look at the right triangle formed by the ray $y = x\tan \theta,$ the rotated half-chord and the $x$-axis. Using trigonometry we see that the side with length $h$ is adjacent to the angle whose measure is \theta, with the half-chord opposite that angle, so we have the length of the half-chord in the upper half-plane as $h \tan \theta.$ So putting this altogether, we see that in a case where the we have the line $y=h$ and a rotation of the xy-plane clockwise by $\frac{\pi}{2}-\theta$ then the length of the chord that remains in the upper half-plane is $$\ell(h, \theta) = \min \{ 2 \sqrt{1-h^2}, \sqrt{1-h^2} + h \tan \theta \}.$$

That's cool an all, but let's return to our particular wave. We see that the we certainly have $\theta,$ by design, but all we need is to determine $h$ in this case. In the case of our wave that is modeled by the line $$y = -x\cot \theta + \frac{1- \cos \theta}{\sin \theta},$$ we can use that same right triangle that we used in the generic case above and the fact that the line crosses the $x$-axis as the point $x = \frac{\sec \theta - 1}{2}$ to determine that $$h = \frac{\sec \theta - 1}{2} \cos \theta = \frac{1 - \cos \theta}{2}.$$ Therefore, we see that the length of the stretch of land covered at 10:05 a.m. if it first touches the island at a point $(\cos \theta, \sin \theta)$ is \begin{align*}\ell(\theta) = \ell\left(\frac{1- \cos\theta}{2}, \theta\right) &= \min \left\{ 2 \sqrt{ 1 - \left(\frac{1 - \cos \theta}{2} \right)^2 }, \frac{1 - \cos \theta}{2}\tan \theta + \sqrt{ 1 - \left( \frac{1 - \cos \theta}{2} \right)^2 } \right\} \\ &= \min \left\{ \sqrt{ (3 - \cos \theta) (1 + \cos \theta) }, \frac{\tan \theta ( 1 - \cos \theta) + \sqrt{(3-\cos \theta)(1 + \cos \theta)} }{2} \right\},\end{align*} for $\theta \in (0, \frac{\pi}{2}).$ Analyzing the parts we see that $\tan \theta (1 - \cos \theta)$ is always increasing on this interval, while the term within the square root is always decreasing, therefore we can reason that that maximal length occurs exactly at the cutover point when $$\tan \theta (1 - \cos \theta) = \sqrt{ (3 - \cos \theta) (1 + \cos \theta) }.$$ While I am sure there are many who may want to try to solve analytically, from a geometric intuition perspective, this cutover occurs exactly when the point where the wave crosses the $x$-axis is at the point $(1,0)$, that is, when $$\frac{\sec \theta^* - 1}{2} = 1,$$ or $\sec \theta^* = 3,$ or $\theta^* = \cos^{-1} \frac{1}{3}.$ At this critical point, the longest possible stretch of land that the wave is covering at 10:05 a.m. is $$\ell^* = \ell( \cos^{-1} \frac{1}{3} ) = \sqrt{ (3 - \frac{1}{3}) (1 + \frac{1}{3} ) } = \frac{4}{3} \sqrt{2} \approx 1.88561808316\dots$$ miles.

For absolute completeness we can cover the cases of $\theta = 0,$ in which case wave is represented by vertical lines and at 10:05 a.m., the wave would be covering the unit interval along the positive $y$-axis and have a length of one mile. For the case of $\theta = \frac{\pi}{2},$ where the wave is represented by horizontal lines and the wave would be at $y= \frac{1}{2}$ and cover a distance of $2\sqrt{1 - \frac{1}{2}} = \sqrt{3} \lt \frac{4}{3} \sqrt{2}$ at 10:05 a.m. By symmetry, we can cover the case of $\theta \in (\frac{\pi}{2} , \pi)$ and by another symmetry we can cover the case of what if instead of last hitting the point at $(1,0)$ the wave first hits the point at $(1,0)$ and then only at 10:10 a.m. arrives at the point $(\cos \theta, \sin \theta),$ to show that there is certainly not a larger possible stretch of land to be found if instead of the subset $(0, \frac{\pi}{2})$ that we spent most of our time on, the wave came with an orientation of \theta with respect to the positive $x$-axis for some $\theta \in (\frac{\pi}{2}, 2\pi)$... but more on this later.

Sunday, May 31, 2026

Two sheep

Two sheep are at two random points inside a square pen. They are munching grass and staring in two random directions. Each sheep has a field of view that’s 180 degrees. What is the probability that they both see each other?

Let's first start with two sheep in a one-dimensional unit interval pen each of which randomly either look to the right or to the left. Obviously in this case, each sheep has a $50\%$ chance of randomly looking at the other sheep and their directional choices are independent, so the probability is $25\%.$

But wait, weren't we dealing with two sheep in a unit square pen? Sure, let's assume that one sheep is at the point $(a,b)$ and another is at $(c,d).$ Next let's draw the straight line $y = \frac{d-b}{c-b} (x - a) + b$ through these two points. The sheep at $(a,b)$ is staring into space in a direction that makes an angle $\theta$ with respect to the ray of the line that we just drew as $x$ increases. We see that either $0 \leq \theta \leq \frac{\pi}{2},$ in we can think of this as looking to the right with respect to the line between the sheep, or $\frac{\pi}{2} \leq \theta \leq \pi$ in which case we can think of this as looking to the left. Therefore, despite living in a fully two dimensional field, we can project this problem back into the one dimensional problem. Similarly, we can therefore conclude that the probability of these two sheep seeing each other in the square pen is $25\%.$

Three sheep

Now, three sheep are at three random points inside a square pen. They are munching grass and staring in three random directions. As before, each sheep has a field of view that’s 180 degrees. What is the probability that all three sheep see each other?

Here we have to be a bit less handwavy, but let's assume that the sheep are located at points $A=(a_1,a_2),$ $B=(b_1,b_2)$ and $C=(c_1,c_2)$, where the measure of the angle $m\angle CAB = \alpha,$ $m\angle ABC = \beta,$ and $m\angle BCA = \gamma.$ In this case the sheep at $A$ can only see $B$ if it is looking up to an angle of $\frac{\pi}{2}$ to the left or right of the line between $A$ and $B$. Similarly, it can only see $C$ if it is looking up to an angle of $\frac{\pi}{2}$ to the left or right of the line between $A$ and $C.$ Let's assume that the line between $A$ and $B$ forms an angle of $\theta$ with respect to the positive $x$-axis. Then since $m\angle CAB = \alpha,$ we see that the line between $A$ and $C$ must either form an angle of $\theta-\alpha$ or $\theta+\alpha.$ That means that either the sheep must be staring in the direction of $\phi \in \left[ \theta - \frac{\pi}{2}, \theta + \frac{\pi}{2} \right] \cap \left[ \theta - \alpha - \frac{\pi}{2}, \theta - \alpha + \frac{\pi}{2} \right] = \left[ \theta - \frac{\pi}{2}, \theta - \alpha + \frac{\pi}{2} \right]$ or $\phi \in \left[ \theta - \frac{\pi}{2}, \theta + \frac{\pi}{2} \right] \cap \left[ \theta + \alpha - \frac{\pi}{2}, \theta + \alpha + \frac{\pi}{2} \right] = \left[ \theta + \alpha - \frac{\pi}{2}, \theta + \frac{\pi}{2} \right],$ so in either case we have that the probability of the sheep at $A$ looking at both the sheep at $B$ and the sheep at $C$ is $$\frac{ \pi - \alpha }{ 2\pi} = \frac{1}{2} - \frac{\alpha}{2\pi}.$$ Since there was nothing special about $A$ and everything is independent, we see that the probability of all of the sheep looking at each other given the angles $\alpha,$ $\beta$ and $\gamma$ are $$p(\alpha, \beta, \gamma) = \left( \frac{1}{2} - \frac{\alpha}{2\pi}\right) \left( \frac{1}{2} - \frac{\beta}{2\pi} \right) \left( \frac{1}{2} - \frac{\gamma}{2\pi}\right).$$ We see that the maximum probability for any particular shape would be for an equilateral triangle $(\alpha=\beta=\gamma=\frac{\pi}{3})$, where the probability is $\frac{1}{27} = 3.\overline{703}\%,$ whereas the minimum probability is for three collinear points where say $\alpha=\pi$ and $\beta=\gamma=0,$ where the probability is $0.$

So if we know where $A$, $B$ and $C$ are all then we can get the side lengths of the triangle $a=\|B-C\|,$ $b=\|A-C\|,$ and $c=\|A-B\|.$ From this we can use the law of cosines to get \begin{align*}\alpha &= \cos^{-1} \left( \frac{b^2 + c^2 - a^2}{2bc} \right) = \cos^{-1} \left( \frac{ \|A-C\|^2 + \|A-B\|^2 - \|B-C\|^2}{ 2 \|A-B\| \|A-C\| } \right)\\ \beta &= \cos^{-1} \left( \frac{a^2 + c^2 - b^2}{2ac} \right) = \cos^{-1} \left( \frac{ \|B-C\|^2 + \|A-B\|^2 - \|A-C\|^2}{ 2 \|A-B\| \|B-C\| } \right)\\ \gamma &= \cos^{-1} \left( \frac{a^2 + b^2 - c^2}{2ab} \right) = \cos^{-1} \left( \frac{ \|B-C\|^2 + \|A-C\|^2 - \|A-B\|^2}{ 2 \|A-C\| \|B-C\| } \right),\end{align*} so we get $$p(A,B,C) = \left( \frac{1}{2} - \frac{\alpha(A,B,C)}{2\pi} \right) \left( \frac{1}{2} - \frac{\beta(A,B,C)}{2\pi} \right) \left( \frac{1}{2} - \frac{\gamma(A,B,C)}{2\pi} \right)$$ Putting this all together we get the probability that all three sheep see each other as $$P = \iint_{A \in [0,1]^2} \iint_{B \in [0,1]^2} \iint_{C \in [0,1]^2} p(A,B,C) \,dA\,dB\,dC,$$ which we will just use some Monte Carlo to estimate this probability.

After 10,000 Monte Carlo simulations for $A$, $B$, and $C,$ we obtain an estimated probability of all three sheep looking at one another $P \approx 2.72\%$. Knowing the way that these problems work out I wouldn't be surprised if somehow the integral works out to roughly $\frac{e}{100},$ but looking at the gnarliness of the integral, I would also be relatively surprised if it did.

Monday, May 25, 2026

June's Shortest Cylindrical Shell Path

Now, June is on a hollowed-out cylinder, also known as a “cylindrical shell.” The shell’s outer radius is $2$ meters and its inner radius is $1$ meter. The shell is $2$ meters tall. June is on the outer edge of one of the cylinder’s two flat faces. Her dinner is on the opposite face, and all the way around on the other end of that face.

Once again, your job is to help June find the shortest path along the surface of the shell so that she can chow down as quickly as possible. What’s the length of this shortest path?

In the classic problem, June was able to roughly ignore the rounded edge of the cylinder and use two straight lines to reach the food. Here, the hollowed out center will force her to take another approach. Let's again assume that June starts at $(2, 0, 2),$ her food is at $(-2, 0, 0),$ June's last stop on the upper face is at the point $(\cos \theta, \sin \theta, 2)$ and first stop on the lower face is at the point $(\cos \phi, \sin \phi, 0),$ for some $0 \leq \theta \leq \frac{\pi}{3}$ and $\frac{2\pi}{3} \leq \phi \leq \pi.$ Here, we note that we can constrain $\theta$ and $\phi$ a little bit more than in the Classic problem, since the distance from $(\cos \theta, \sin \theta, 2)$ to $(\cos \phi, \sin \phi, 0)$ is $$d_2(\theta, \phi) = \sqrt{4 + (\phi-\theta)^2},$$ which is always less than descending vertically down from the upper to lower faces and then traversing along the inner radius from angle $\theta$ to $\phi,$ or vice versa. This means that we can rule out any of the values for $\theta$ and $\phi$ in $[\pi/3, 2\pi/3],$ where the straight line path would cross within the hollowed out inner circle and require June to travel along the curved inner radius.

Therefore, taking the Euclidean distances along the upper and lower faces of the cylindrical shell, we have that the Extra Credit distance formula is given by $$d(\theta, \phi) = \sqrt{5 - 4 \cos \theta} + \sqrt{5 + 4 \cos \phi} + \sqrt{4 + (\phi - \theta)^2}.$$ so we need to find $$d^* = \inf \left\{ d(\theta, \phi) \mid 0 \leq \theta \leq \frac{\pi}{3}, \frac{2\pi}{3} \leq \phi \leq \pi \right\}.$$ From a symmetry perspective, let's assume that $\phi = \pi - \theta,$ which means that we can define \begin{align*}\tilde{d} (\theta) &= d(\theta, \pi-\theta) \\ &= \sqrt{5 - 4\cos \theta} + \sqrt{5 + 4 \cos (\pi - \theta)} + \sqrt{4 + (\pi - \theta - \theta)^2} \\ &= 2 \sqrt{5 - 4 \cos \theta} + \sqrt{4 + (\pi - 2\theta)^2}.\end{align*} Here we see that $$\tilde{d}^\prime (\theta) = \frac{4\sin \theta}{\sqrt{ 5 - 4 \cos \theta}} + \frac{ 2 (2\theta - \pi) }{\sqrt{ 4 + (\pi - 2\theta)^2} },$$ so setting this equal to zero we get $$\frac{4 \sin \theta}{\sqrt{5 - 4 \cos \theta}} = \frac{ 2 (\pi - 2\theta) }{\sqrt{4 + (\pi - 2\theta)^2}}.$$ Squaring both sides and using some trigonometry identities, we see that this is equivalent to the implicit function $$\theta + \frac{2\sin \theta}{2 \cos \theta - 1} = \frac{\pi}{2}.$$

Let's use Newton-Raphson method on the function $$f(\theta) = \theta + \frac{2\sin \theta}{2\cos \theta - 1} - \frac{\pi}{2},$$ where $$f^\prime(\theta) = 1 + \frac{4-2\cos \theta}{(2\cos \theta - 1)^2},$$ to figure out the proper root of this implicit function, we see that we can start with an example of $\theta_0 = \frac{1}{2},$ then $$\theta_{n+1} = \theta_n - \frac{f(\theta_n)}{f^\prime(\theta_n)},$$ for $n = 0, 1, 2, \dots.$ We see that after only a few steps we quickly settle into $$\theta^* = \lim_{n \to \infty} \theta_n = 0.457751785361\dots.$$ This translates into a minimal distance for June to get to her food on the cylindrical shell of $$\tilde{d}^* = \tilde{d}(\theta^*) \approx 5.368959019243\dots$$ meters.

$n$ $\theta_n$ $f(\theta_n)$ $f^\prime(\theta_n)$ $\tilde{d}(\theta_n)$
1 0.500000000000 0.198927402511 4.936412045223 5.371299778386
2 0.459702026353 0.008790035183 4.516178419967 5.368964120693
3 0.457755682704 0.000017530945 4.498196526681 5.368959019263
4 0.457751785377 0.000000000070 4.498160714274 5.368959019243
5 0.457751785361 0.000000000000 4.498160714132 5.368959019243

June's Shortest Cylindrical Path

June the ant is on a cylinder. More specifically, she is on the edge of one of the cylinder’s two circular faces. Her dinner is on the edge of the opposite circular face, and all the way around on the other side of that face. The radius of the cylinder is $2$ meters and its height is $2$ meters.

Your job is to help June find the shortest path along the surface of the cylinder so that she can chow down as quickly as possible. What’s the length of this shortest path?

Let's assume that June is located at the point $(2,0,2)$ while her food is located at $(-2,0,0),$ making the center of the cylinder aligned with the positive $z$-axis. Let's assume that June's path last leaves the top circular face at the point $(2\cos \theta, 2\sin \theta, 2),$ for some $0 \leq \theta \leq \pi.$ Similarly, let's assume that June's path first arrives on the bottom circular face at the point $(2 \cos \phi, 2\sin \phi, 0),$ for some $\theta \leq \phi \leq \pi.$ Though June's path could theoretically wander about anywhere, let's assume that she will walk in straight lines when on the two circular faces and on a straight line with respect to the curved outer edge. The path along the upper circular face will have a distance $$d_1(\theta) = \sqrt{ (2\cos \theta - 2)^2 + (2 \sin \theta)^2 + (2-2)^2 } = 2 \sqrt{ 1 - 2 \cos \theta } = 4 \sin \frac{\theta}{2}.$$ The path along the lower circular face will have a distance $$d_3(\phi) = \sqrt{ (2 \cos \phi + 2)^2 + (2 \sin \phi)^2 + (2-2)^2 } = 2 \sqrt{ 1 + 2 \cos \phi } = 4 \cos \frac{\phi}{2}.$$ The path along the curved outer edge is given by $d_2(\theta, \phi) = 2 \sqrt{1 + (\phi - \theta)^2},$ which we can see either by unrolling the curved outer edge into a rectangle and realizing that the path is the hypotenuse of a triangle with height $2$ and base $2 (\phi - \theta)$, or more formally by paramaterizing the path along the outer edge as the curve $x(t) = 2 \cos t,$ $y(t) = 2 \sin t,$ $z(t) = 2 \frac{\phi - t}{\phi - \theta},$ for $t \in [\theta, \phi]$ and finding \begin{align*}d_2(\theta, \phi) &= \int_\theta^\phi \sqrt{ \left(\frac{dx}{dt}\right)^2 + \left( \frac{dy}{dt} \right)^2 + \left( \frac{dz}{dt} \right)^2 } \,dt \\ &= \int_\theta^\phi \sqrt{ (-2\sin t)^2 + (2 \cos t)^2 + \left(\frac{-2}{\phi - \theta}\right)^2 } \,dt \\ &= \int_\theta^\phi \sqrt{ 4 \sin^2 t + 4 \cos^2 t + \frac{4}{(\phi - \theta)^2} } \,dt \\ &= \frac{2 \sqrt{1 + (\phi - \theta)^2}}{\phi - \theta} \int_\theta^\phi \,dt \\ &= 2 \sqrt{ 1 + (\phi - \theta)^2 }.\end{align*} So the total distance is $$d(\theta, \phi) = d_1(\theta) + d_2(\theta, \phi) + d_3(\phi) = 4 \sin \frac{\theta}{2} + 4 \cos \frac{\phi}{2} + 2 \sqrt{ 1 + (\phi - \theta)^2 }.$$

So June would want to find $$d^* = \inf \{ d(\theta, \phi) \mid 0 \leq \theta \leq \phi \leq \pi \}.$$ Let's treat the case where $\theta = \phi$ and hence we have a univariate problem $$\tilde{d}(\theta) = 4 \sin \frac{\theta}{2} + 4 \cos \frac{\theta}{2} + 2.$$ We see that in this case, we have $$\frac{d}{d\theta} \tilde{d} = 2 \cos \frac{\theta}{2} - 2 \sin \frac{\theta}{2}$$ which has critical points whenever $\tan \frac{\theta}{2} = 1,$ that is $\frac{\theta}{2} = \frac{\pi}{4},$ or $\theta^* = \frac{\pi}{2}.$ Therefore, we see that the minimal value of $$ \tilde{d}^* = \inf_{0 \leq \theta \leq \pi} \tilde{d}(\theta) = \min \left\{ \tilde{d}(0), \tilde{d}(\pi), \tilde{d} \left( \frac{\pi}{2} \right) \right\} = \min \{ 6, 6, 4\sqrt{2}+2 \} = 6,$$ which occurs when either $\theta=0$ or $\theta=\pi.$ This amounts to either going straight down the curved side and then taking a straightline path across the diameter to the food, or vice versa.

Let's fix some $\theta \in [0,\pi)$ and then try to minimize with respect to $\phi.$ We see that $$\frac{\partial d}{\partial \phi} = -2 \sin \frac{\phi}{2} + \frac{ 2(\phi - \theta)}{\sqrt{1 + (\phi-\theta)^2}}.$$ Setting this equal to zero and doing a bunch of algebra and trigonometry identities we get the implicit function $$\phi - \tan \frac{\phi}{2} = \theta.$$ Letting $g(t) = t - \tan \frac{t}{2},$ we see that $g^\prime(t) = 1 - \frac{1}{2} \sec^2 \frac{t}{2},$ so the largest possible value of $g$ occurs when $\sec^2 \frac{t}{2} = 2$ or equivalently when $\cos \frac{t}{2} = \frac{\sqrt{2}}{2},$ that is when $t = \frac{\pi}{2},$ and in particular we see that $$g(t) \leq g^* = g( \frac{\pi}{2} ) = \frac{\pi}{2} - 1.$$ Therefore, we see that if $\theta \geq \frac{\pi}{2} - 1$ then we have $\frac{\partial d}{\partial \phi} \leq 0$ for all $\phi \in [\theta, \pi],$ so if $\theta \gt \frac{\pi}{2} - 1,$ then the shortest path that can be obtained by choosing $\phi = \pi$ is $$ \inf_{\phi \in [\theta, \pi]} d(\theta, \phi) = d(\theta, \pi) = 4 \sin \frac{\theta}{2} + 2 \sqrt{ 1 + (\pi - \theta)^2}.$$ We see that in this case if we set $$\delta(\theta) = 4 \sin \frac{\theta}{2} + 2 \sqrt{ 1 + (\pi - \theta)^2}$$ that $$ \delta^* = \inf_{\theta \in [\frac{\pi}{2} -1, \pi]} \delta(\theta) = \delta(\pi) = 6.$$

Ok, so we are now left with only the case where $\theta \in [0, \frac{\pi}{2} -1).$ In this case, we can approximate the implicit equation using a cubic function, since $\tan \frac{t}{2} \approx \frac{t}{2} + \frac{t^3}{24} + O(t^4)$ for $|t| \lt 1.$ This yields the new approximate implicit equation $$\phi - \left( \frac{\phi}{2} + \frac{\phi^3}{24} \right) = \theta,$$ or equivalently, $$\phi^3 - 12\phi + 24 \theta = 0.$$ This cubic has three real roots, and the middle one will yield a local minimum since it will represent the place where $\frac{\partial d}{\partial \phi} \lt 0$ to the left of the root and $\frac{\partial d}{\partial \phi} \gt 0$ to the right of the root. From the Viete formula, we see that this root will be at $$\phi^*(\theta) = 4 \cos \left( \frac{ \cos^{-1} \left( -\frac{3\theta}{2} \right) - 2\pi }{3} \right).$$ Importantly, we remember that we got into this mess because $\phi^*(\theta)$ roughly satisfies $$\frac{\partial d}{\partial \phi} (\theta, \phi^*(\theta)) \approx 0.$$ So let's define $$\Delta(\theta) = d(\theta, \phi^*(\theta)),$$ and look to find $\Delta^* = \inf \{\Delta(\theta) \mid \theta \in [0,\frac{\pi}{2}-1]\}.$ Thankfully, we see that \begin{align*}\Delta^\prime(\theta) &= 2 \cos \frac{\theta}{2} - 2 \sin \frac{\phi^*(\theta)}{2} (\phi^*)^\prime (\theta) + \frac{ 2(\phi^*(\theta) - \theta) }{ \sqrt{ 1 + (\phi^*(\theta) - \theta)^2 }} (\phi^*)^\prime (\theta) \\ &= 2 \cos \frac{ \theta}{2} + (\phi^*)^\prime (\theta) \left( - 2 \sin \frac{ \phi^*(\theta) }{2} + \frac{ 2( \phi^*(\theta) - \theta }{ \sqrt{ 1 + (\phi^* (\theta) - \theta)^2 }} \right) \\ & = 2 \cos \frac{ \theta}{2} + (\phi^*)^\prime (\theta) \frac{\partial d}{\partial \phi} (\theta, \phi^*(\theta)) \\ & \approx 2 \cos \frac{\theta}{2} \gt 0,\end{align*} for all $\theta \in [0, \frac{\pi}{2} - 1),$ therefore we see that $\Delta^* = \Delta(0) = 6.$

Therefore, since we went through all of the cases, we now anticlimactically confirm that in fact, June's shortest path to the food is 6 meters long.

Monday, May 11, 2026

Extra Credit Random-Ade Recipe

Once again I’m preparing random-ade, but this time I have three 12-ounce glasses.

I fill the first glass with a random amount of lemon juice, the second glass with a random amount of lime juice, and the third glass with a random amount of water. As before, each amount is chosen uniformly between 0 and 12 ounces, and all amounts are independent. Next, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.

At this point, I refill that empty glass with yet another random amount of the same liquid it previously contained. Once again, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.

Then I refill that now-empty glass with yet another random amount of the same liquid it previously contained. Again, I pour an equal amount from each glass into the pitcher until one of the glasses is empty.

On average, how much random-ade can I expect to prepare?

OK, so in the extra credit version we can let $E, I, W \sim U(0,12)$ represent the random volume in ounces of l"E"mon juice, l"I"me juice and "W"ater, respectively, that are initially poured into the glasses. Let $V_1, V_2 \sim U(0,12)$ be the additional random volumes that are poured into the then empty glasses. Here again we have $E, I, W, V_1,$ and $V_2$ independent. We have $$\tilde{R}(E,I,W,V_1,V_2) = \begin{cases} \min \{E,I,W\} + V_1 + V_2, & \text{if $V_1 + V_2 \leq \text{med} \{E, I, W \} - \min \{E, I, W \}$} \\ \text{med} \{E, I, W\}, &\text{if $V_1 \leq \text{med} \{E, I, W \} - \min \{E, I, W\} \leq V_1 + V_2$}\\ \text{med} \{E, I, W \} + \min \{ V_1, V_2 \}, &\text{if $\text{med}\{E, I, W\} - \min \{E, I, W\} \leq V_1$} \\ & \,\,\,\,\,\, \text{ and $\min \{V_1, V_2 \} \leq \max \{E, I, W \} - \text{med} \{E, I, W\}$}\\ \max \{E, I, W \}, &\text{if $\text{med} \{E, I, W\} - \min \{ E, I, W\} \leq V_1$}\\ & \,\,\,\,\,\, \text{ and $\min \{V_1, V_2\} \geq \max \{E, I, W\} - \text{med} \{E, I, W\}.$} \end{cases}$$

As we can see there are many possible cases to go through in order to get the theoretical solution; however, it is relatively easy to set up a Monte Carlo simulation. Doing so with $N= 100,000$ simulations gives an average $\tilde{R}$ value of $\hat{R} = 7.400516$ with standard error of $0.0081.$ So we can confidently say that the expected volume of the Extra Credit Ranom-Ade is about 7.40 ounces.