Sunday, July 12, 2026

The one where they end up at the same place

The climber and the sprinter are racing up a perfectly sinusoidal hill. They go from the base, where the gradient is 0 percent, to the peak, where the gradient is again 0 percent. For them to reach the top at the same time, what should the maximum gradient of the hill be?

Ok, so a few things are left unstated here, so let's insert them. Let's assume that the horizontal distance of this hill section is 1, since units don't seem to matter in the slightest at Tour de Fiddler. Since we know that the hill is perfectly sinusoidal, we see that the height at horizontal distance $x \in [0,1]$ from the start is given by $$h(x) = \frac{h}{2} + \frac{h}{2} \sin \left( \pi x - \frac{\pi}{2} \right) = \frac{h}{2} \left(1 - \cos (\pi x) \right),$$ where $h$ is the total height of the hill. In particular, we additionally see that the gradient at a vertical distance of $x$ from the start is given by $$g(x) = h^\prime (x) = \frac{\pi h}{2} \sin (\pi x).$$ So like the Classic problem we will solve the problem with respect to one variable, in this case the height $h,$ and then transform it into the desired variable, in this case $$g_{max} = \max_{x \in [0,1]} \frac{\pi h}{2} \sin(\pi x) = \frac{\pi h}{2}.$$

In order to figure out the time elapsed for a rider, we might first want to chop the horizontal distance into say $N$ small pieces, say with $x_n = \frac{n}{N},$ for $n = 0, 1, \dots, N.$ In this case, we can determine for each short segment of horizontal distance from say $x_{n-1}$ to $x_n,$ what the horizontal inclination $\theta_n$ is, in order to determine the speed of the rider over that small interval $v_n = v(\theta_n).$ Then we see that since $v_n$ represents the total speed, that the horizontal speed is only $v_n \cos \theta_n,$ so that the time it would take for the rider to traverse the small segment would be $$t_n = \frac{x_{n+1} - x_n}{ v_n \cos \theta_n} = \frac{1}{N v_n \cos \theta_n}.$$ Then the total time elapsed is \begin{align*}T = \sum_{n=1}^{N} t_n = \sum_{n=1}^N \frac{1}{N (v_n \cos \theta_n)} &\to \int_0^1 \frac{dx}{ v(\theta(x)) \cos \theta(x) } \\ &= \int_0^1 \frac{dx}{ \frac{P}{m \sin \theta(x) + 10} \cos \theta(x) } \\ &= \frac{1}{P} \int_0^1 \left(m \tan \theta(x) + 10 \sec \theta(x) \right) \,dx \end{align*} as $N \to \infty.$

Since $$\theta(x) = \tan^{-1} g(x) = \tan^{-1} h^\prime(x) = \tan^{-1} \left( \frac{\pi h}{2} \sin (\pi x) \right),$$ we have $$T(h) = \frac{1}{P} \int_0^1 \left( m \tan \left( \tan^{-1} \left( \frac{\pi h}{2} \sin (\pi x) \right) \right) + 10 \sec \left( \tan^{-1} \left( \frac{\pi h}{2} \sin (\pi x) \right) \right)\right) \,dx.$$ Because $\tan( \tan^{-1} u) = $u and $\sec (\tan^{-1} u) = \sqrt{1 + u^2}$ for all $u \in \mathbb{R},$ we have \begin{align*} T(h) &= \frac{m}{P} \int_0^1 \frac{\pi h}{2} \sin(\pi x) \,dx + \frac{10}{P} \int_0^1 \sqrt{ 1 + \left( \frac{\pi h}{2} \sin(\pi x)\right)^2} \,dx \\ &= \frac{mh}{P} + \frac{10}{P} \int_0^1 \sqrt{1 + \left( \frac{\pi h}{2} \sin(\pi x)\right)^2} \,dx \\ &= \frac{mh}{P} + \frac{20}{P \pi} E\left(-\frac{\pi^2 h^2}{4}\right),\end{align*} where $E(k) = \int_0^{\pi/2} \sqrt{1 - k \sin^2 t} \,dt$ is the complete elliptical integral of the second kind.

In this case, in particular, if we wanted to see when does $T_c(h) = T_s(h),$ then we have \begin{align*}0 = T_c(h) - T_s(h) &= \left( \frac{m_c h}{P_c} + \frac{20}{P_c \pi} E\left( - \frac{\pi^2 h^2}{4} \right) \right) - \left( \frac{m_s h}{P_s} + \frac{20}{P_s \pi} E \left( - \frac{\pi^2 h^2}{4} \right) \right) \\ &= \frac{1}{P_cP_s} \left( h (P_s m_c - P_c m_s) + \frac{20 (P_s-P_c)}{\pi} E\left( - \frac{\pi^2 h^2}{4} \right) \right),\end{align*} so the two times will be equal when we have $$h \left( \frac{P_c m_s - P_s m_c}{10 (P_s - P_c)} \right) = \frac{2}{\pi} E \left( - \frac{\pi^2 h^2}{4} \right).$$ For our particular climber and sprinter, we know from the Classic problem that $\frac{P_c m_s - P_s m_c}{10 (P_s - P_c)} = 18,$ so we have the implicit equation $$18h = \frac{2}{\pi} E \left(-\frac{\pi^2h^2}{4} \right).$$

To properly root-solve for this implicit equation, we can use a fixed-point iteration method to solve for the point where $f(x) = \frac{1}{9\pi} E(-\frac{\pi^2 x^2}{4} )$ has a fixed point where $f(x)=x.$ In particular, we can define the small Python snippet, using the built-in special function $\textsf{scipy.special.ellipe}$:

Since $\frac{2}{\pi} E(z) \approx 1$ for $z \approx 0,$ let's start with an initial guess of $h_0 = \frac{1}{18}.$ Doing so, quickly retrieves, after 6 iterations the approximate solution of $$h^* \approx 0.05566157787953384\dots,$$ which means that for them to reach the top of the hill at the same time that maximum gradient should be $g_{max} = \frac{\pi h^*}{2} = 8.743300207677981\dots \%.$

The one where they go the same speed

As it’s now July, the Tour de Fiddler is back!

This time, we’ll be looking at a model for a cyclist’s speed $v$ as a function of their pedaling power $P,$ their mass $m,$ and the ground’s angle of inclination $\theta$: $$v = \frac{P}{m \sin \theta + 10}.$$

In cycling, roads are marked with a gradient $g,$ which is a hill’s slope, typically expressed as a percentage. Thus, an incredibly steep 45-degree incline has a gradient of 1, or “100 percent.”

Consider the following two riders:

  • A “climber,” who has a power of 300 and a mass of 60
  • A “sprinter,” who has a power of 325 and a mass of 80

At what gradient will the climber and sprinter cycle at the same speed?

In this case, since the formula involves the ground's angle of inclination $\theta,$ but we then want an answer in terms of gradient, $g,$ we need to understand how these two quantities relate to one another. In particular, we see that $g = \tan \theta,$ or equivalently $\theta = \tan^{-1} g,$ but more on this later.

In general if $v_c$ and $v_s$ are the climber's and sprinter's velocities, then they will be equal when $$\frac{P_c}{m_c \sin \theta + 10} = \frac{P_s}{m_s \sin \theta + 10},$$ or equivalently when $$P_c(m_s \sin \theta + 10) = P_s(m_c \sin \theta + 10)$$ which in turn is equivalent to when $$(P_cm_s - P_sm_c) \sin \theta = 10 (P_s - P_c),$$ or when $$\sin \theta^* = \frac{ 10 (P_s - P_c) }{ P_cm_s - P_s m_c }.$$ In particular, when we have $P_c = 300,$ $m_c = 60,$ $P_s = 325,$ and $m_c = 80,$ then we have $$\sin \theta^* = \frac{10 \cdot ( 325 - 300 )}{ 300 \cdot 80 - 325 \cdot 60 } = \frac{250}{4500} = \frac{1}{18},$$ or equivalently $\theta^* = \sin^{-1} \frac{1}{18}.$

Since we have $$\tan (\sin^{-1} u) = \frac{u}{\sqrt{1-u^2}},$$ for any $u \in [-1,1],$ we see that the gradient at which the climber and sprinter will have the same speed is $$g^* = \tan \left( \sin^{-1} \frac{1}{18} \right) = \frac{ \frac{1}{18} }{ \sqrt{ 1 - \left( \frac{1}{18} \right)^2 } } = \frac{1}{\sqrt{18^2 -1}} = \frac{\sqrt{323}}{323} \approx 5.56414884\dots\%.$$

Monday, July 6, 2026

Retsy Boss VIII's Star Fitting Homage

After 250 years, the nation has commissioned Retsy Boss VIII to design a new flag with one star for each of the nation’s current $58$ states. As an homage to the original flag design, Retsy wants to select $58$ stars from the square grid that are all at most some distance $R$ from a point on the plane. What is the minimum distance $R$ that Retsy can use?

Thankfully for Retsy Boss VIII, her namesake left her the Python code to run the optimization to find the number of stars given $h,$ $k$ and $R.$ Also, fortunately for Retsy Boss VIII she knew to look at OEIS to look up the integer sequence A000328, which captures the case of $h=k=0$ and $R \in \mathbb{N},$ to give her a decent idea of where to start. In particular, we see that $N(0,0,4) = 49$ and $N(0,0,5)=81,$ so let's start looking for $R \in [4,5].$ In particular, she wants to find $$R^* = \inf \left\{ R \in [4,5] \mid N^*(R) = \sup_{(h,k) \in [0,1]^2} N(h,k,R) \geq 58 \right\}.$$

Retsy didn't want to exhaustively search the entire phase space, so first she went about implementing a secant method update to arrive at some point $R$ for which $N^*(R) = 58.$ In particular, let's let $R_0 = 4,$ $R_1 = 5$ and $$R_{n+1} = \frac{R_{n-1} N^*(R_n) - R_n N^*(R_{n-1}) + 58 (R_n - R_{n-1})}{N^*(R_n) - N^*(R_{n-1})}.$$ Note that relatively quickly we arrive at some value with $N^*(R) = 58,$ that is,

$n$ $R_n$ $N^*(R_n)$
$0$ $4$ $49$
$1$ $5$ $81$
$2$ $4.20689655\dots$ $59$
$3$ $4.17084639\dots$ $58$

That is all well and good, but Retsy VIII wants the minimal such value of $R$ such that $N^*(R) = 58.$ Now she turns to a binary search of the interval $[a_0,b_0] = [4, 4.17084639],$ to within a tolerance of $\varepsilon = 10^{-6}.$ For each $n,$ she defines $c_n = \frac{a_n+b_n}{2}.$ If $N^*(c_n) \lt 58,$ then she defines $a_{n+1} = c_n$ and $b_{n+1} = b_n;$ however if $N^*(c_n) = 58,$ then she defines $a_{n+1} = a_n$ and $b_{n+1} = c_n.$ We can stop as soon as

$n$ $a_n$ $b_n$ $c_n$ $N^*(c_n)$
$0$ $4$ $4.17084639$ $4.08542320$ $56$
$1$ $4.08542320$ $4.17084639$ $4.12813480$ $57$
$2$ $4.12813480$ $4.17084639$ $4.14949060$ $57$
$3$ $4.14949060$ $4.17084639$ $4.16016850$ $58$
$4$ $4.14949060$ $4.16016850$ $4.15482955$ $57$
$5$ $4.15482955$ $4.16016850$ $4.15749902$ $58$
$6$ $4.15482955$ $4.15749902$ $4.15616428$ $58$
$7$ $4.15482955$ $4.15616428$ $4.15549691$ $58$
$8$ $4.15482955$ $4.15549691$ $4.15516323$ $57$
$9$ $4.15516323$ $4.15549691$ $4.15533007$ $58$
$10$ $4.15516323$ $4.15533007$ $4.15524665$ $58$
$11$ $4.15516323$ $4.15524665$ $4.15520494$ $58$
$12$ $4.15516323$ $4.15520494$ $4.15518409$ $57$
$13$ $4.15518409$ $4.15520494$ $4.15519451$ $58$
$14$ $4.15518409$ $4.15519451$ $4.15518930$ $57$
$15$ $4.15518930$ $4.15519451$ $4.15519191$ $57$
$16$ $4.15519191$ $4.15519451$ $4.15519321$ $58$
$17$ $4.15519191$ $4.15519321$ $4.15519256$ $58$

So we see that the optimal value of $R^*$ is about $4.15519256$ to within a tolerance of $\varepsilon = 10^{-6}.$ At this point, we can use map a contour plot, shown below, similar to what we did for the Classic problem. It is hard to discern, but the only place that the maximum is attained (up to the various symmetries of the $N$ function) when $R = 4.15519256$ is in a small neighborhood of the point $(h,k) = (1/2, 1/8)$ (seem familiar ... wink, wink?). If we were to graph the circle of radius $R = 4.15519256$ centered at $(1/2, 1/8),$ we see that it ever so slightly includes the lattice points $(-1,4),$ $(2,4),$ $(0,-4)$ and $(1,-4).$ In particular, since we see that the distance from $(1/2, 1/8)$ to any of these four lattices points is exactly the same, we can reduce the value of $R$ to precise that distance and maintain a value of $N^*(R) = 58,$ and hence the minimum distance that Retsy Boss VIII can use to honor her forebear's design is exactly $$R^* = \sqrt{0.5^2 + 4.125^2} = \sqrt{1.5^2 + 3.875^2} = \frac{\sqrt{1105}}{8} \approx 4.155192534648665\dots.$$

Move Over Ed McMahon, It's Retsy Boss's Star Search

When designing her new nation’s flag, Retsy Boss wanted to compactly arrange some stars. These stars were positioned along a square grid, but she only wanted to include stars whose centers were at most two units away from some point on the plane.

For example, if she had centered the circle on a star itself, then she could have placed a total of 13 stars on the flag, as shown below:

What is the greatest number of stars Retsy could have placed on the flag?

Let's define the function $N(h,k,R)$ to be the number of integer lattice points within distance $R$ of the point $(h,k) \in \mathbb{R}^2,$ in particular, we have $$N(h,k,R) = \# \left\{ (m,n) \in \mathbb{Z}^2 \mid (m-h)^2 + (n-k)^2 \leq R^2 \right\}.$$ If we have a fixed value of $k,$ let's say, then we see will have $$\eta_n(h,k,R) = \left\lfloor \sqrt{R^2 - (n-k)^2} + h \right\rfloor + \left\lfloor \sqrt{R^2 - (n-k)^2} - h \right\rfloor + 1,$$ where for clarity $\lfloor x \rfloor = \max \{ n \in \mathbb{Z} \mid n \leq x \}$ and in particular $\lfloor x \rfloor = -1$ for $x \in [-1,0).$ So in particular, we have $$N(h,k,R) = \sum_{n=-\lfloor R - k \rfloor}^{\lfloor R + k \rfloor} \eta_n (h,k,R).$$ We see for instance, that when $h=k=0$ and $R=2,$ that we indeed recover $\eta_{-2}(0,0,2) = \eta_2(0,0,2) = 1, \eta_{-1}(0,0,2) = \eta_1(0,0,2) = 3,$ and $\eta_0 (0,0,2)= 5,$ so we have $$N(0,0,2) = \sum_{n=-2}^2 \eta_n(0,0,2) = 1 + 3 + 5 + 3 + 1 = 13.$$

Now, since we also see that everything is periodic and symmetric, in order to solve Retsy's problem we only need to find $$N^* = \max \left\{ N(h,k,2) \mid 0 \leq k \leq h \leq \frac{1}{2} \right\},$$ since everything else in the unit square will can be recovered from this region and everything else in the plane is periodic so $N(h,k,2) = N([h], [k],2),$ for all $(h,k) \in \mathbb{R}^2,$ where $[x] = x - \lfloor x \rfloor$ is the fractional part function.

We can code this up in the following Python code to explore the phase space and empirically determine $N^*$:

Using this Python code, we can plot the following contour plot, which shows that anywhere in the dark blue region produces the the largest possible number of stars that Retsy could place on the flag is $N^*=14.$ In particular, we can take the point $(h,k) = (0.5, 0.125)$ for foreshadowing purposes and explicitly compute that \begin{align*} \eta_{-1}(0.5,0.125,2) &= \lfloor \sqrt{ 4 - (-1-0.125)^2 } + 0.5 \rfloor + \lfloor \sqrt{ 4 - (-1-0.125)^2 } - 0.5 \rfloor + 1 \\ &\quad = \lfloor 1.654\dots + 0.5 \rfloor + \lfloor 1.654\dots - 0.5 \rfloor + 1 = 4\\ \eta_{0}(0.5,0.125,2) &= \lfloor \sqrt{ 4 - (-0.125)^2 } + 0.5 \rfloor + \lfloor \sqrt{ 4 - (-0.125)^2 } - 0.5 \rfloor + 1\\ &\quad =\lfloor 1.996\dots + 0.5 \rfloor + \lfloor 1.996\dots - 0.5 \rfloor + 1 = 4\\ \eta_{1}(0.5,0.125,2) &= \lfloor \sqrt{ 4 - (1-0.125)^2 } + 0.5 \rfloor + \lfloor \sqrt{ 4 - (1-0.125)^2 } - 0.5 \rfloor + 1\\ &\quad =\lfloor 1.798\dots + 0.5 \rfloor + \lfloor 1.798\dots - 0.5 \rfloor + 1 = 4\\ \eta_{2}(0.5,0.125,2) &= \lfloor \sqrt{ 4 - (2-0.125)^2 } + 0.5 \rfloor + \lfloor \sqrt{ 4 - (2-0.125)^2 } - 0.5 \rfloor + 1\\ &\quad =\lfloor 0.696\dots + 0.5 \rfloor + \lfloor 0.696\dots - 0.5 \rfloor + 1 = 2\end{align*} so that $$N(0.5,0.125,2)=N^*=4+4+4+2=14.$$

Sunday, June 21, 2026

A less than half-full tank

Frustrated with my old calculator, I toss it in the trash and buy a new one. But now I’m concerned this second calculator is also “tanked.” As before, every value of $A$ between $0$ and $1$ is equally likely, at first.

I ask my friend to generate one random number using this second calculator. My friend does so, and smirks. “I won’t tell you what the number is,” my friend says, “but it’s somewhere between $0$ and $0.5.$” On average, what can I expect the value of $A$ (for this second calculator) to be?

Similar to the classic problem, we will define terms with $A \sim U(0,1)$ at first and $X|A=a \sim U(0,a).$ In this case, we want to get the distribution of $A$ conditional on $0 \leq X \leq \frac{1}{2},$ that is, $$f_{A\mid 0 \leq X \leq 1/2} (a) = \lim_{da \downarrow 0} \frac{\frac{1}{da} \mathbb{P} \left\{ a -\frac{da}{2} \leq A \leq a + \frac{da}{2}, 0 \leq X \leq \frac{1}{2} \right\}}{ \mathbb{P} \{ 0 \leq X \leq \frac{1}{2} \} }.$$

Let's take the denominator first, like last time to see that \begin{align*}\mathbb{P} \{ 0 \leq X \leq \frac{1}{2} \} &= \int_0^1 \int_0^{1/2} \frac{1}{t} \chi_{[0,t]}(x) \,dx \,dt \\ &= \int_0^{1/2} \int_0^1 \frac{1}{t} \chi_{[0,t]}(x) \,dt \,dx \\ &= \int_0^{1/2} \left(\int_0^x 0 \,dt + \int_x^1 \frac{dt}{t} \right) \,dx \\ &= \int_0^{1/2} -\ln x \,dx \\ &= \frac{1}{2} - \frac{1}{2} \ln \frac{1}{2} = \frac{1}{2} \left( 1 + \ln 2 \right).\end{align*}

Let's assume that $a \gt \frac{1}{2},$ in which case, for small values of $da$ we have $\frac{1}{2} \leq a - \frac{da}{2},$ so we have $\chi_{[0,t]}(x) = 1$ for all $0 \leq x \leq 1/2$ and $t \in (a-da/2, a+da/2).$ Therefore, if $a \gt \frac{1}{2},$ then we have the numerator equal to \begin{align*}\frac{1}{da} \mathbb{P} \{ a - da/2 \leq A \leq a + da/2, 0 \leq X \leq 1/2 \} &= \frac{1}{da}\int_{a-da/2}^{a+da/2} \int_0^{1/2} \frac{1}{t} \chi_{[0,t]}(x) \,dx \, dt \\ &= \frac{1}{da} \int_{a-da/2}^{a+da/2} \frac{dt}{2t} = \frac{1}{2da} \left( \frac{a + \frac{da}{2}}{a - \frac{da}{2}} \right) \\&= \frac{1}{2} \left. \frac{d}{dt} \ln t \right|_{t=a} + O(da) = \frac{1}{2a} + O(da).\end{align*} On the other hand, if $a \lt \frac{1}{2},$ then if $da$ is small enough, then for every $t \in (a - da/2, a+da/2),$ we have $t \lt 1/2,$ so we have the denominator as \begin{align*}\frac{1}{da} \mathbb{P} \{ a - da/2 \leq A \leq a + da/2, 0 \leq X \leq 1/2 \} &= \frac{1}{da} \int_{a-da/2}^{a+da/2} \int_0^{1/2} \frac{1}{t} \chi_{[0,t]}(x) \,dx \,dt \\ &= \frac{1}{da} \int_{a-da/2}^{a+da/2} \left( \int_0^t \frac{1}{t}\, dx + \int_t^{1/2} 0 \,dx \right) \,dt \\ &= \frac{1}{da} \int_{a-da/2}^{a+da/2} 1 \,dt = 1\end{align*} Therefore, we see that as $da \downarrow 0,$ the numerator becomes the piecewise function $n(a) = \min \{ 1, \frac{1}{2a} \},$ so putting everything together, we see that $$f_{A\mid 0 \leq X \leq \frac{1}{2}} (a) = \frac{ n(a) }{ \frac{1}{2} (1 + \ln 2) } = \min \left\{ \frac{2}{1 + \ln 2}, \frac{1}{a(1 + \ln 2)} \right\}.$$

Therefore, if all we have is the knowledge that the draw from the tanked calculator is in the lower half of the interval, then the expected value of the tank parameter is \begin{align*}\mathbb{E} \left[ A \mid 0 \leq X \leq \frac{1}{2} \right] &= \int_0^{1/2} a \cdot \frac{2}{1 + \ln 2} \,da + \int_{1/2}^1 a \cdot \frac{1}{a(1 + \ln 2)} \,da \\ &= \left.\frac{2}{ 1 + \ln 2} \frac{a^2}{2} \right|_{a=0}^{a=1/2} + \frac{1}{1 + \ln 2} \cdot \frac{1}{2} \\ &= \frac{3}{4(1 + \ln 2)} \approx 0.442962081862\dots\end{align*}

A half-full tank

I think the random number generator on my calculator might be malfunctioning. Oh no!

Under normal conditions, it should generate random numbers between $0$ and $1.$ But my suspicion is that the calculator is “tanked,” meaning it only generates random numbers between $0$ and some value $0 \lt A \lt 1.$ Beyond that, I have no knowledge regarding the value of $A.$ At the moment, it’s equally likely to be any value from $0$ to $1$.

As an experiment, I ask the calculator to generate one random number. It produces a value of exactly $0.5.$ (While this is, admittedly, infinitely unlikely, let’s roll with it!) Based on this result, what can I expect the value of $A$ to be, on average?

Let's first define some terms. Let's assume that the tank paramater $A \sim U(0,1),$ and since the calculator is tanked that random draws are all independently and identically distributed as $X \sim U(0,A),$ that is, $$f_{X|A=a}(x) = \lim_{dx \downarrow 0} \frac{1}{dx} \mathbb{P} \{ x - \frac{dx}{2} \leq X \leq x + \frac{dx}{2} \mid A = a\} = \frac{1}{a} \chi_{[0,a]}(x).$$ Using Bayesian theorem, we see that \begin{align*}f_{A|X=x} (a) &= \lim_{da \downarrow 0} \frac{1}{da} \mathbb{P} \{ a - \frac{da}{2} \leq A \leq a + \frac{da}{2} \mid X = x \} \\ &= \lim_{da \downarrow 0} \frac{ \mathbb{P} \{ a - \frac{da}{2} \leq A \leq a + \frac{da}{2}, X = x \} }{ da \mathbb{P} \{ X = x \} } \\ &= \lim_{da \downarrow 0} \frac{ \frac{1}{da} \int_{a - da/2}^{a+da/2} \frac{1}{t} \chi_{[0,t]}(x) \,dt }{ \int_0^1 \frac{1}{t} \chi_{[0,t]}(x) \,dt }.\end{align*} In particular, the denominator can be calculated as $$\int_0^1 \frac{1}{t} \chi_{[0,t]}(x) \,dt = \int_0^x \frac{1}{t} \chi_{[0,t]}(x) \,dt + \int_x^1 \frac{1}{t} \chi_{[0,t]}(x) \,dt = \int_0^x 0 \,dt + \int_x^1 \frac{dt}{t} = -\ln x.$$ The numerator meanwhile is equivalent to $\frac{1}{a} \chi_{[0,a)} (x),$ since if $x \lt a,$ then there is some $\alpha \lt 2(a-x)$ for which for any $0 \lt da \lt \alpha,$ $\chi_{[0,t]}(x) = 1$ for all $t \in (a-\frac{da}{2}, a + \frac{da}{2}),$ so that $$\frac{1}{da} \int_{a - da/2}^{a+da/2} \frac{1}{t} \chi_{[0,t]}(x) \,dt = \frac{1}{da} \int_{a-da/2}^{a+da/2} \frac{dt}{t} = \frac{ \ln \left( \frac{a + \frac{da}{2}}{a - \frac{da}{2}} \right) }{da} = \left.\frac{d}{dt} \ln t \right|_{t=a} + O(da) = \frac{1}{a} + O(da).$$ Similarly, if $x \gt a,$ then there is some $\alpha^\prime \lt 2(x-a)$ for which for any $0 \lt da \lt \alpha^\prime,$ then $\chi_{[0,t]}(x) = 0$ for all $t \in (a - \frac{da}{2}, a + \frac{da}{2} ),$ so that $$\frac{1}{da} \int_{a-da/2}^{a+da/2} \frac{1}{t} \chi_{[0,t]}(x) \,dt = 0.$$ Putting this all together, we see that $$f_{A\mid X=x}(a) = \begin{cases} -\frac{1}{a \ln x}, &\text{if $x \lt a \leq 1$;}\\ 0, &\text{if $0 \leq a \lt x.$}\end{cases}$$

Therefore, in particular, since we observed that $X = \frac{1}{2},$ we have the expected value of the tank parameter $A$ as \begin{align*}E[A \mid X = \frac{1}{2}] &= \int_0^1 a f_{A \mid X=\frac{1}{2}} (a) \,da \\ &= \int_0^{1/2} a \cdot 0 \,da + \int_{1/2}^1 a \cdot \left(- \frac{1}{a \ln \frac{1}{2}}\right) \,da \\ &= \int_{1/2}^1 \frac{da}{ln 2} \\& = \frac{1}{2\ln 2} \approx 0.72134752044\dots\end{align*}

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.