Sunday, November 10, 2024

Snoring while sorting

You are waiting in line to be sorted into one of the four houses of Logwarts (a posh wizarding boarding school in the Scottish highlands) by an anthropomorphic sorting hat. The hat is a bit of a snob about the whole matter, and refuses to sort two students in a row into the same house. If a student requests a certain house, but the previously sorted student was already sorted into that same house, then the hat chooses randomly from among the three remaining houses.

You are standing 10th in line, and you make plans to request Graphindor house for yourself. As for the other students in line, you can assume that they have random preferences from among the four houses. The first student steps up, and has a brief, quiet conversation with the hat. After a few moments, the hat proclaims, “Graphindor!” At this point, what is the probability that you will be sorted into Graphindor?

Let's define our probability space such that it will be useful for the this problem. Of course, as stated there are three other houses with fanciful names (perhaps Hufflepath, Ravenndiagram and Slytheorem), but as far as you're concerned it is Graphindor or bust, so luckily all of these outcomes are indistinguishable to you. Let $p_{i,k}$ be the probability that the $i$th wizardling on line is sorted into Graphindor, subject to the fact that the $k$th wizardling on line was the last one to actually be sorted to Graphindor.

As far as you are concerned, you get to Graphindor as long as the 9th wizard is not sorted there, since you will always ask the hat to sort you into Graphindor. So, given that the 1st wizardling on line was just sorted into Graphindor, the probability that you will be sorted into Graphindor is $p=1-p_{9,1}.$ All that remains now is to divine what the formula for $p_{i,k}$ is anyway.

Let's say that we know $p_{i,k}$ for some $1 \leq k \leq i.$ There are two ways for the $(i+1)$th wizardling to end up sorted into Graphindor: either (a) the $i$th wizard is sorted to some ``not Graphindor'' house and the $(i+1)$th wizardling requested Graphindor; or (b) the $i$th wizard is sorted to some ``not Graphindor'' house and the $(i+1)$th wizardling requested that same ``not Graphindor'' house. In both cases, the probability of event (a) is $1/4$ while the probability of event (b) is $1/12 = 1/4 \cdot 1/3.$ Putting these two together, we get the recursion relationship $$p_{i+1,k} = \frac{1}{4} (1-p_{i,k}) + \frac{1}{12} (1-p_{i,k}) = \frac{1-p_{i,k}}{3}, \,\,\text{for $i \geq k \geq 1.$}$$ By construction, we have $p_{k,k} = 1,$ for each $k \geq 1.$

This recursive formula leads to the explicit formula $$p_{i,k} = \frac{1}{4} \left(1 + 3 \cdot (-3)^{k-i}\right), \,\,\, \text{for all $i \geq k \geq 1.$}\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\star$$ We see that for $i=k \geq 1$ that we recover $p_{k,k} = \frac{1}{4} (1 + 3 \cdot (-3)^0 ) = 1,$ as our base case. If we assume that the formula $\star$ holds for some $i \geq k \geq 1,$ then from the recursive formula we see that \begin{align*}p_{i+1,k} = \frac{1-p_{i,k}}{3} &= \frac{1 - \frac{1}{4} \left(1 + 3 \cdot (-3)^{k-i} \right)}{3} \\ &= \frac{\frac{3}{4} - \frac{3}{4} \cdot (-3)^{k-i}}{3} \\ &= \frac{1}{4} \left( 1 + \frac{3}{-3} (-3)^{k-i} \right) \\ &= \frac{1}{4} \left( 1 + 3 \cdot (-3)^{k-i-1} \right),\end{align*} which follows formula $\star$ for the case $i+1$. Thus by induction we have proven the formula. This therefore allows us to answer that if you are $10$th in line and have resolved to request Graphindor no matter what that your probability of getting sorted into Graphindor after the first wizard is sorted into Graphindor is $$p=1-p_9 = 1 - \frac{1}{4} \left(1 + 3 \cdot (-3)^{1-9}\right) = \frac{3-3^{-7}}{4} = \frac{6560}{8748} = \frac{1640}{2187} \approx 0.7498856882....$$

Now, instead of being 10th in line, suppose you are $N$th in line, where $N$ is some value much greater than 10. Because so many students are being sorted in front of you, you decide you’ll take a nap. You wake up without any idea of how long you were out—it could have been a second, or it could have been an hour, you’re just not sure. It’s still not your turn to be sorted yet, but you see a student wearing the hat. After a brief moment, the hat shouts, “Graphindor!”

What is the smallest value of $N$ such that your probability of being sorted into Graphindor is greater than $p$? (To be clear, when you wake up, the student being sorted is anywhere from first in line to immediately before you in line with equal probability.)

OK, so now it becomes a little clearer why I chose such obscure nomenclature for the earlier problem. However, in this case where you are sitting at $N$th in line and then dozed off only to wake up as the wizardling in uniformly randomly distributed position $M$ is sorted into Graphindor, so we have the expected probability of being sorted into Graphindor is still dependent on whether or not the person immediately in front of you is sorted into Graphindor, that is $q=1-p_{N-1,M}$. However, here since $M$ is random we have \begin{align*} q = 1 - p_{N-1,M} &= 1 - \sum_{i=1}^{N-1} \mathbb{P} \{ M = i \} p_{N-1,i} \\ &= 1 - \frac{1}{N-1} \sum_{i=1}^{N-1} \frac{1}{4} \left(1 + 3 \cdot (-3)^{i-N+1} \right) \\ &= \frac{3}{4} - \frac{3 \cdot (-3)^{1-N}}{4(N-1)} \sum_{i=1}^{N-1} (-3)^i \\ &= \frac{3}{4} - \frac{3 \cdot (-3)^{1-N}}{4(N-1)} \frac{(-3) - (-3)^N}{1-(-3)} \\ &= \frac{3}{4} \left( 1 - \frac{ 9 \cdot (-3)^{-N} + 3}{4(N-1)} \right) \\ &= \frac{3}{16} \frac{4N-7-9\cdot(-3)^{-N}}{N-1}\end{align*} If we then want to know what is the minimal $N$ such that $q = q(N) \gt p = \frac{1640}{2187},$ we need get a nonlinear, monotonically increasing equation that we can just as easily guess and check for a solution.

In particular, if we solve the approximation where we ignore that pesky exponential function and equally ignore the integrality of $N$, we get $$\tilde{q}(x) = \frac{3 (4x-7)}{16(x-1)}.$$ If we were to solve $$\tilde{q}(x) = \frac{3(4x-7)}{16(x-1)} = p$$ for a non-integer value of $x$, we get $$x^* = \frac{21-16p}{12-16p} = \frac{19687}{4} = 4921.75.$$ This seems like a very good place to start hunting and pecking with $N^* = \lceil x^* \rceil = 4922.$ Let's first check $$\tilde{q}(N^*) = \frac{3 \cdot (4 \cdot 4922 -7)}{16 \cdot 4921} = \frac{59043}{78736} \approx 0.7498856939.....,$$ which is roughly $6 \times 10^{-9}$ larger than $p.$ Since $9 \cdot (-3)^{-N^*} \ll 10^{-9},$ we can confirm that $N^* = 4922$ is the smallest integer value such that if you fell asleep and randomly woke up to some wizardling ahead of you in line is being sorted to Graphindor then your probability of also getting sorted to Graphindor is $q(N) \gt p = \frac{1640}{2187}.$

Monday, November 4, 2024

Is that what squaring the circle means?

A pseudo-square has the following properties:

  1. It is a simple, closed curve.
  2. It has four sides, all the same length.
  3. Each side is either a straight line segment or the arc of a circle.
  4. The four sides are joined at four corners, with each corner having an internal angle of 90 degrees or 270 degrees.

The pseudo-square pictured above has two straight sides, which run radially between arcs of two concentric circles. Assuming this is a unit pseudo-square (i.e., each side has length 1), what is its area?

As you can see, I've pre-doctored the image from the prompt with some parameters. Let $r$ be the radius of the smaller circle and let $\theta$ be the angle inscribed between the two straight line edges. From here, if the shape is a unit pseudo-square then the larger radius is $1+r,$ so we can find the formula for the area of the shape in terms of $r$ and $\theta,$ as $$A(r,\theta) = \pi r^2 + \frac{1}{2} \theta \left((1+r)^2 - r^2\right) = \pi r^2 + \frac{1}{2} \theta (1 + 2r).$$ That is all well and good, but we now have to find the particular value of $r$ and theta that allow for this shape to be unit pseudo-square. In particular, the length of the arc on the larger of the two concentric circles is $$\ell = \theta (1 + r).$$ The length of the other arc is $$\tilde{\ell} = (2\pi - \theta) r.$$ Since the shape is a unit pseudo-square we have the nonlinear system of equations \begin{align*} \theta ( 1 + r) &= 1 \\ (2\pi - \theta) r &= 1.\end{align*} By setting $\theta = (1 + r)^{-1}$ and plugging into the second equation we get $$\left(2\pi - \frac{1}{1+r}\right) r = 1,$$ which is equivalent to the quadratic equation $$2\pi r^2 + 2(\pi - 1) r - 1 = 0.$$ Thus, if the shape is a unit pseudo-square then the smaller radius $r$ is equal to $$r^* = \frac{1-\pi + \sqrt{1+\pi^2}}{2\pi}.$$

By plugging $\theta = (1+r)^{-1}$ into the area formula we get $A(r) = \pi r^2 + \frac{1+2r}{2(1+r)},$ so plugging in $r^*$ from above we get the area of the unit psuedo-square with two straight lines is \begin{align*}A^* = A(r^*) &= \pi \left( \frac{1-\pi + \sqrt{1+\pi^2}}{2\pi} \right)^2 + \frac{ 1 + 2 \frac{1-\pi + \sqrt{1+\pi^2}}{2\pi} }{2 \left( 1 + \frac{1-\pi + \sqrt{1+\pi^2}}{2\pi} \right)}\\ &= \frac{1+\sqrt{1+\pi^2}}{2\pi} \approx 0.683874197466......\end{align*}

Can you find a unit pseudo-square that has three curved sides and just one straight side? What is the area of your new unit pseudo-square?

Without loss of generality, we can assume that the one flat side is positioned along the bottom. We would need to have two curved sides connected to this flat bottom that curve towards each other, with there being a third circle that is tangent to the circular arcs. The resulting shape is sort of like the shape of some pawns in chess. See the figure below. We again insert some parameters. Let the flat side be the line segment from $(-\frac{1}{2},0)$ to $(\frac{1}{2},0).$ Let the two symmetric sides attached to flat bottom be arcs of the circles centered at $(-a,0)$ and $(a,0),$ respectively, each with radius $a+\frac{1}{2},$ with subtended angle $\theta$. Let the final arc be from the circle centered $(0,b)$ with radius $r$ and subtended angle $2(\pi - \theta).$

Let's first try to figure out how to quantify the area of the pseudo-square with three curved sides. The region denoted by $B$ has area given by $$A_B = \frac{1}{2} (\pi - \theta) r^2.$$ The region denoted by $C$ has area given by $$A_C = \frac{1}{2} r^2 \tan \theta.$$ Finally, the region denoted by $D$ has aread given by $$A_D = \frac{1}{2} \theta \left(a + \frac{1}{2}\right)^2 - \frac{1}{2} a^2 \tan \theta.$$ The area of the entire pseudo-square with three curved sides is thus \begin{align*}A = A(a,r,\theta) &= 2 \left(A_B + A_C + A_D\right) \\ &= (\pi - \theta + \tan \theta) r^2 + \theta \left(a + \frac{1}{2}\right)^2 - a^2 \tan \theta.\end{align*}

With some creative trigonometry we can obtain $r = r(a,\theta),$ thus reducing the dimensions of the problem a smidge. The region denoted by $C$ is a triangle whose height is $r$ and base $\beta,$ which is some portion of line segment of total length $a + \frac{1}{2},$ since that line segment is a radius of the circle centered at $(-a,0)$ of radius $a+\frac{1}{2}.$ Since the line segment, negative $x$-axis and positive $y$-axis form a triangle, we can compute $\beta$ as $$\beta = a + \frac{1}{2} - a\sec \theta.$$ Since $r = \beta \cot \theta,$ we have $$r = r(a,\theta) = \left( \left(a+\frac{1}{2}\right) - a \sec \theta \right) \cot \theta = \frac{ (a + \frac{1}{2}) \cos \theta - a }{ \sin \theta }.$$ Therefore, we have $$A = A(a,\theta) = (\pi - \theta + \tan \theta) \left( \frac{ \left(a + \frac{1}{2}\right) \cos \theta - a }{\sin \theta} \right)^2 + \theta \left(a + \frac{1}{2} \right)^2 - a^2 \tan \theta.$$

OK, now that that significantly more intricate foundational work is out of the way, we need to ensure that each of these curves sides is unit length. Since the more vertical arcs are symmetric, we only need to quantify $\ell=(a+\frac{1}{2}) \theta$ and $\tilde{\ell} = 2(\pi - \theta) r,$ and set them both equal to $1$ to obtain the nonlinear system of equations \begin{align*} (a + \frac{1}{2}) \theta &= 1 \\ 2(\pi - \theta) r = (\pi - \theta) \frac{(a+1/2)\cos \theta - a}{\sin \theta} &= 1\end{align*} Solving for $a$ in the second equation and then plugging back into the first we get $$\frac{ \sin \theta - \pi + \theta }{ 2(\pi - \theta) ( \cos \theta - 1) } \theta = 1.$$ This non-linear equation is solved with $$\theta^* \approx 0.74960359...$$ which leads to $$a^* = \frac{2-\theta^*}{2\theta^*} \approx 0.8340377...$$ which ultimately leads to the area of a unit pseudo-square with three curved sides of $$A^* = A(a^*, \theta^*) \approx 0.8317044...$$

Monday, October 28, 2024

Conditional candy

It’s Halloween time! While trick-or-treating, you encounter a mysterious house in your neighborhood.

You ring the doorbell, and someone dressed as a mathematician answers. (What does a “mathematician” costume look like? Look in the mirror!) They present you with a giant bag from which to pick candy, and inform you that the bag contains exactly three peanut butter cups (your favorite!), while the rest are individual kernels of candy corn (not your favorite!).

You have absolutely no idea how much candy corn is in the bag—any whole number of kernels (including zero) seems equally possible in this monstrous bag.

You reach in and pull out a candy at random (that is, each piece of candy is equally likely to be picked, whether it’s a peanut butter cup or a kernel of candy corn). You remove your hand from the bag to find that you’ve picked a peanut butter cup. Huzzah!

You reach in again and pull a second candy at random. It’s another peanut butter cup! You reach in one last time and pull a third candy at random. It’s the third peanut butter cup!

At this point, whatever is left in the bag is just candy corn. How many candy corn kernels do you expect to be in the bag?

The probability of drawing three peanut butter cups in a row, conditional on there being $k$ candy corn kernels, is $$\mathbb{P} \{ c = 3 \mid k \} = \frac{ 3 }{k + 3 } \frac{ 2}{k + 2} \frac{1}{k+1} = \frac{6}{(k+3) (k+2) (k+1) }.$$ Using Bayes' theorem, we can retrieve the conditional distribution of the number of candy corn kernels conditional on pulling three peanut butter cups in a row, namely, \begin{align*}\mathbb{P} \{ k \mid c = 3 \} &= \frac{ \mathbb{P} \{ c = 3 \mid k \} \mathbb{P} \{ k \} }{ \mathbb{P} \{ c = 3 \} } \\ &= \frac{ \mathbb{P} \{ c = 3 \mid k \} }{ \sum_{\ell = 0}^\infty \mathbb{P} \{ c = 3 \mid \ell \} } \\ &= \frac{ \frac{6}{(k+1)(k+2)(k+3)} }{ \sum_{\ell=0}^\infty \frac{6}{(\ell+1)(\ell+2)(\ell+3)} }\\ &= \frac{1}{M (k+1)(k+2)(k+3)},\end{align*} where $$M = \sum_{\ell=0}^\infty \frac{1}{(\ell +1)(\ell+2)(\ell+3)}.$$

We can calculate the convergent series $M$ by method of partial fractions. Let \begin{align*} \frac{1}{(\ell + 1)(\ell + 2)(\ell + 3)} &= \frac{A}{\ell+1} + \frac{B}{\ell+2} + \frac{C}{\ell+3} \\ &= \frac{ A (\ell + 2) (\ell + 3) + B(\ell + 1)(\ell + 3) + C(\ell + 1)(\ell + 2)}{ (\ell + 1) (\ell+2) (\ell+3) } \\ &= \frac{ (A + B + C) \ell^2 + (5A + 4B + 3C) \ell + (6A + 3B + 2C)}{(\ell+1)(\ell+2)(\ell+3)}.\end{align*} So we have the resulting system of linear equations \begin{align*} A + B + C &= 0 \\ 5A + 4B + 3C &= 0 \\ 6A + 3B + 2C & = 1 \end{align*}, which has solution $A = C = \frac{1}{2}$ and $B = -1.$ Therefore, $$\frac{1}{(\ell + 1) (\ell + 2)(\ell + 3)} = \frac{1}{2} \frac{1}{\ell+1} - \frac{1}{\ell+2} + \frac{1}{2} \frac{1}{\ell+3},$$ so we have \begin{align*} M &= \sum_{\ell = 0}^\infty \frac{1}{(\ell+1)(\ell+2)(\ell+3)} = \lim_{L\to \infty} \sum_{\ell=0}^L \frac{1}{(\ell+1)(\ell+2)(\ell+3)} \\ &= \lim_{L \to \infty} \sum_{ell=0}^L \left( \frac{1}{2} \frac{1}{\ell+1} - \frac{1}{\ell+2} + \frac{1}{2} \frac{1}{\ell+3} \right) \\ &= \lim_{L \to \infty} \frac{1}{2} \left( 1 + \frac{1}{2} + \frac{1}{3} + \cdots + \frac{1}{L+1} \right) - \left( \frac{1}{2} + \frac{1}{3} + \cdots + \frac{1}{L+1} + \frac{1}{L+2} \right) + \frac{1}{2} \left( \frac{1}{3} + \cdots + \frac{1}{L+1} + \frac{1}{L+2} + \frac{1}{L+3} \right) \\ &= \lim_{L\to \infty} 1 \cdot \frac{1}{2} + \frac{1}{2} \cdot \left( \frac{1}{2} - 1 \right) + \left( \frac{1}{2} - 1 + \frac{1}{2} \right) \cdot \left( \frac{1}{3} + \cdots + \frac{1}{L+1} \right) + \frac{1}{L+2} \cdot \left(-1 + \frac{1}{2} \right) + \frac{1}{L+3} \cdot \frac{1}{2} \\ &= \lim_{L \to \infty} \frac{1}{2} - \frac{1}{4} + O(L^{-2}) = \frac{1}{4}.\end{align*}

Therefore, we have $$\mathbb{P} \{ k \mid c = 3 \} = \frac{4}{(k+1)(k+2)(k+3)},$$ for $k = 0, 1, \dots,$ so we can calculated the conditional expectation as $$\mathbb{E} \left[ K \mid c = 3 \right] = \sum_{k=0}^\infty k \mathbb{P} \{ k \mid c = 3 \} = 4 \sum_{k=0}^\infty \frac{k}{(k+1)(k+2)(k+3)}.$$ As before, we can solve this series by the method of partial fractions. Here instead of the earlier system of equations, we now want to solve \begin{align*} A + B + C &= 0 \\ 5A + 4B + 3C &= 1 \\ 6A + 3B + 2C &= 0 \end{align*} which has solution $A = -\frac{1}{2},$ $B = 2,$ $C = - \frac{3}{2}.$ Thus the conditional expected number of candy corn kernels given that I drew the three peanut butter cups is \begin{align*}\mathbb{E} \left[ K \mid c = 3 \right] &= 4 \sum_{k=0}^\infty \frac{k}{(k+1)(k+2)(k+3)}\\ &= \lim_{L \to \infty} 4 \left(-\frac{1}{2} + \left( -\frac{1}{2} + 2 \right) \cdot \frac{1}{2} + O(L^{-2}) \right) = 4 \cdot \frac{1}{4} = 1.\end{align*}

Sunday, October 20, 2024

How boring can you get?

I have a large, hemispherical piece of bread with a radius of $1$ foot. I make a bread bowl by boring out a cylindrical hole with radius $r,$ centered at the top of the hemisphere and extending all the way to the flat bottom crust.

What should the radius of my borehole be to maximize the volume of soup my bread bowl can hold?

N.B. I originally conceived of this week's Fiddler problem in my mind's eye with the hemispherical bread having a flat upper crust, which led to initially thinking that it was a very weird setup where you keep cutting your cylindrical hole downward until you ever so slightly bump up against the curved bottom crust at which point you stop since obviously otherwise your bread bowl would have a hole in it and your soup would leak out. This is essentially the inverted logic of the handwavy no-surface-tension argument I make below, so in the end I think the math ends up being roughly the same ....

So anyway, freely choosing the coordinate system that best suits me, assume that your bread fills the space $B = \{ (x,y,z) \mid x^2 + y^2 + z^2 \leq 1, z \geq 0 \}.$ Assume that a cylindrical borehole takes would remove the portion of the $B$ that satisfyies $x^2 + y^2 \leq r^2,$ for some radius $r \gt 0.$ Ultimately, since we cannot rely on molecular properties of the varying soups that might fill the bread bowl to postulate any additional volume of soup due to surface tension, let's assume that the bread bowl can only be filled up to its upper rim, that is, the cylindrical cavity is given by $C(r) = \{ (x,y,z) \mid x^2 + y^2 \leq r^2, 0 \lt z \leq \sqrt{1-r^2}\}.$ The volume of $C(r)$ is given by $V(r) = \pi r^2 \sqrt{1-r^2}.$

Differentiating $V(r)$ gives $$V^\prime(r) = 2\pi r \sqrt{1-r^2} + \pi r^2 \left( \frac{-r}{\sqrt{1-r^2}} \right) = \frac{\pi r \left( 2(1-r^2) -r^2 \right)}{\sqrt{1-r^2}} = \frac{\pi r (2-3r^2)}{\sqrt{1-r^2}}.$$ Thus $V$ has critical points as $r_1 = 0$, $r_2 = \sqrt{\frac{2}{3}} = \frac{\sqrt{6}}{3},$ and $r_3 = 1.$ Since $V(0)=V(1)=0,$ the maximum possible volume of soup contained in this bread bowl is $$V^* = \frac{2\pi\sqrt{3}}{9} \approx 1.20919957616\dots$$ cubic feet, which occurs when choosing a radius of $$r^* = \frac{\sqrt{6}}{3} \approx 0.816496580928\dots$$ feet.

Instead of a hemisphere, now suppose my bread is a sphere with a radius of $1$ foot. Again, I make a bowl by boring out a cylindrical shape with radius $r,$ extending all the way to (but not through) the curved bottom crust of the bread. The central axis of the hole must pass through the center of the sphere.

What should the radius of my borehole be to maximize the volume of soup my bread bowl can hold?

Again hearkening back to my earlier spatial reasoning struggles, I could not for the life of me understand why this extra credit problem was in any way different from just having double the volume since you would then stop cutting as soon as you hit the curved bottom crust. Since I take Axiom of the Benevolent Fiddlermeister as a given, I have to assume that the extra credit problem is somehow different from the regular problem, so we will assume that I have a precision instrument that can bore a perfectly cylindrical hole in the spherical bread until I ever so slightly approach the curved lower crust and then somehow liquefy and extract the remaining bready portions all the way down to curved lower crust. So in this case the bowl takes the shape $\tilde{C}(r) = \{ (x,y,z) \mid x^2 + y^2 \leq r^2, -\sqrt{1-x^2-y^2} \lt z \leq \sqrt{1-r^2} \}.$ In this case, the volume is \begin{align*}\tilde{V}(r) &= \int_{ x^2 + y^2 \leq r^2 } \int_{-\sqrt{1-x^2-y^2}}^{\sqrt{1-r^2}} \, dz \,dy \,dx\\ &= \int_{x^2 + y^2 \leq r^2} \left( \sqrt{1-r^2} + \sqrt{1-x^2 -y^2}\right) \,dy \,dx \\ &= \int_0^{2\pi} \int_0^r \left( \sqrt{1-r^2} + \sqrt{1 - \rho^2} \right) \rho \,d\rho \, d\theta \\ &= \pi r^2 \sqrt{1-r^2} + 2\pi \int_0^r \rho \sqrt{1-\rho^2} \,d\rho \\ &= \pi r^2 \sqrt{1-r^2} + \frac{2\pi}{3} \left( 1 - (1-r^2)^{3/2} \right).\end{align*} We can write $(1-r^2)^{3/2} = (1-r^2) \sqrt{1-r^2}$ to then factor even further and see that $$\tilde{V}(r) = \pi r^2 \sqrt{1-r^2} + \frac{2\pi}{3} \left( 1 - (1-r^2) \sqrt{1-r^2} \right) = \frac{2\pi}{3} + \frac{\pi \sqrt{1-r^2}}{3} (5r^2 - 2).$$

Differentiating we get \begin{align*}\tilde{V}^\prime (r) &= \frac{10\pi r}{3} \sqrt{1-r^2} + \frac{\pi}{3} (5r^2 - 2) \left( \frac{-r}{\sqrt{1-r^2}} \right)\\ &= \frac{\pi r}{3\sqrt{1-r^2}} \left( 10 (1-r^2) - (5r^2 - 2) \right)\\ &= \frac{\pi r (4-5r^2)}{\sqrt{1-r^2}}.\end{align*} Thus $\tilde{V}$ has critical points at $r_1 = 0,$ $r_2 = \sqrt{\frac{4}{5}} = \frac{2\sqrt{5}}{5},$ and $r_3 = 1.$ Here since we have $\tilde{V}^\prime \gt 0$ when $r \lt \frac{2\sqrt{5}}{5}$ and $\tilde{V}^\prime \lt 0$ when $r \gt \frac{2\sqrt{5}}{5},$ we see that the maximum possible volume of our miraculously scooped out bread bowls with curved lower crusts is $$\tilde{V}^* = \frac{2\pi(5+\sqrt{5})}{15} \approx 3.03103706653\dots$$ cubic feet, which occurs when choosing a radius of $$\tilde{r}^* = \frac{2\sqrt{5}}{5} \approx 0.894427191\dots$$ feet.

Monday, October 14, 2024

Leading the logarithmic pack

You’re doing a $30$-minute workout on your stationary bike. There’s a live leaderboard that tracks your progress, along with the progress of everyone else who is currently riding, measured in units of energy called kilojoules. Once someone completes their ride, they are removed from the leaderboard.

Suppose many riders are doing the $30$-minute workout right now, and that they all begin at random times. Further suppose that they are burning kilojoules at different constant rates (i.e., everyone is riding at constant power) that are uniformly distributed between $0$ and $200$ Watts.

Halfway through (i.e., $15$ minutes into) your workout, you notice that you’re exactly halfway up the leaderboard. How far up the leaderboard can you expect to be as you’re finishing your workout?

Let's start by determining the distribution of the random other riders' outputs at any one time. At any particular time, say $\tau$, the only riders still on the leaderboard would have started at times $t \in (\tau - 1800, \tau).$ Let's assume that riders join the $30$ minute class uniformly randomly such that the probability that any join between the time $t$ and $t+dt$ is proportional to $dt,$ that is, at time \tau, the riders would have already completed $T \sim U(0,1800)$ seconds of the rider. These riders would also have uniformly distribution constant powers, $P \sim U(0,200).$ The total output is $O = P \cdot T,$ which we can get the distribution of by directly computing the \begin{align*}\mathbb{P} \{ O \leq \theta \} &= \frac{1}{360000}\int_0^{200} \int_0^{1800} \chi \{ p t \leq \theta \} \,dt \,dp \\ &= \frac{1}{360000} \int_0^{200} \int_0^{\min \{ 1800, \theta / p \}} \,dt \,dp \\ &= \frac{1}{360000} \int_0^{200} \min \left\{1800, \frac{\theta}{p} \right\} \,dp \\ &= \frac{1}{360000} \left( \int_0^{\theta/1800} 1800 \,dp + \int_{\theta / 1800}^200 \frac{\theta}{p} \,dp \right) \\ &= \frac{1}{360000} \left( \theta + \theta \left( \ln 200 - \ln (\theta / 1800) \right) \right) \\ &= \frac{\theta}{360000} \left( 1- \ln \left( \frac{\theta}{360000} \right) \right).\end{align*}

So let's simplify slightly and focus on the function $\Phi(t) = t ( 1 - \ln t ).$ So in particular, if at some point I find myself half way up the leaderboard, then that would mean that my output $\tilde{O} = 360000 \tilde{\theta}$ where $\Phi(\tilde{\theta}) = \frac{1}{2}.$ Of course, $\Phi$ does not have a neat and tidy inverse function, so we would have to implicitly solve for $\tilde{\theta} = \Phi^{-1}(0.5),$ but more on this later.

So since the distribution of random riders is time invariant, if halfway through my ride I have output $\tilde{O} = 360000 \Phi^{-1}(0.5),$ then I can expect my output at end of my ride I have output $2\tilde{O}.$ In this case, the proportion of riders that I will be ahead of the leaderboard is \begin{align*}\Phi(2 \Phi^{-1}(0.5)) &= 2\Phi^{-1}(0.5) \left( 1- \ln (2\Phi^{-1}(0.5))\right) \\ &= 2 \Phi^{-1}(0.5) \left( 1- \ln 2 - \ln \Phi^{-1}(0.5) \right) \\ &= -2 \Phi^{-1}(0.5) \ln 2 + 2 \Phi^{-1} (0.5) \left( 1 - \ln \Phi^{-1}(0.5) \right) \\ &= -2 \Phi^{-1}(0.5) \ln 2 + 2 \Phi \left( \Phi^{-1}(0.5) \right) \\ &= 1 - 2 \Phi^{-1}(0.5) \ln 2 = 1 - 2 \tilde{\theta} \ln 2 .\end{align*} So, since we can analytically solve the inverse function to find that $\tilde{\theta} = \Phi^{-1}(0.5) = 0.1866823,$ I can expect to be ahead of about $$1-2 \tilde{\theta} \ln 2 \approx 74.1203380189...\%$$ of the riders at the end of my ride.

As an added bonus problem (though not quite Extra Credit), what’s the highest up the leaderboard you could expect to be $15$ minutes into your workout?

If I am killing it at 200 Watts for the first 15 minutes, then I would have an output of $\hat{O} = 200 \cdot 900 = 180000$ kJ, which would put me ahead of about $$\Phi\left(\frac{\hat{O}}{360000}\right) = \Phi(0.5) = 0.5 (1 + \ln 2) \approx 84.657359028...\%$$ of the riders after $15$ minutes.

Sunday, August 18, 2024

The arc of high jumping bends towards ... 2?

In the high jump, an athlete’s entire body must clear the bar. However, not every part of their body has to clear the bar at the same time. As a result, athletes arc their bodies over the bar, so that only a fraction of their mass is above the bar at any given time. In fact, athletes can theoretically clear the bar despite their center of mass remaining below the bar throughout the jump.

Let’s model the athlete’s jump as an arc of angle $2\phi$ that is centered over the bar, as shown below. For simplicity, assume that their mass is uniformly distributed across the length of their body. The dot in the diagram represents the athlete’s center of mass. Let $a$ represent the vertical distance between the athlete’s center of mass and their lowest points (presumably their outstretched fingers and toes), and let $b$ represent the vertical distance between the athlete’s center of mass and their highest point (presumably their waist).

If $\phi = \frac{\pi}{2}$ then the arc would be a complete semicircle. In that case, what is the ratio $a/b$?

As the angle $\phi$ gets very, very small (i.e., in the limit as $\phi$ goes to zero), what value does the ratio $a/b$ approach?

Let's solve the generic case for $\phi$ so that we can then do the two cases, both when $\phi = \frac{\pi}{2}$ and when $\phi \downarrow 0.$ Since we'll be taking ratios of everything anyway, let's just go ahead and assume that the circle on which the high jumper's arc is lying in the figure has radius $1$ and is centered at the origin. Then, with some trigonometric know-how, we see that the lowest point of the arc will be sitting at a height of $\cos \phi.$ So we must have $a + b = 1 - \cos \phi.$ Additionally we see that the jumper's body has a length of $2\phi,$ the length of this arc. So to find $a,$ we need only take the average of the jumper's height along this arc by taking the integral $$a + \cos \phi = \frac{1}{2\phi} \int_{\frac{\pi}{2} - \phi}^{\frac{\pi}{2} + \phi} \sin t \,dt = \frac{1}{2\phi} \left( -\cos (\frac{\pi}{2} + \phi) + \cos (\frac{\pi}{2} - \phi) \right) = \frac{\cos (\frac{\pi}{2} - \phi) }{\phi} = \frac{\sin \phi}{\phi}.$$ That is, $$a = \frac{\sin \phi}{\phi} - \cos \phi$$ and $$b = 1 - \cos \phi - a = 1 - \frac{\sin \phi}{\phi}.$$ Therefore for any value of \phi, the ratio of $a / b$ is $$r(\phi) = \frac{\frac{\sin \phi}{\phi} - \cos \phi}{1 - \frac{\sin \phi}{\phi}} = \frac{ \sin \phi - \phi \cos \phi }{\phi - \sin \phi}.$$

So in particular, if $\phi = \frac{\pi}{2}$ and the jumper's body makes a complete semicircle then the ratio $a/b$ is $$r(\frac{\pi}{2}) = \frac{\sin \frac{\pi}{2} - \frac{\pi}{2} \cos \frac{\pi}{2} }{\frac{\pi}{2} - \sin \frac{\pi}{2}} = \frac{1}{\frac{\pi}{2} - 1} = \frac{2}{\pi - 2} \approx 1.75193839388....$$

On the other hand, if we use some rough Taylor approximations around $\phi \approx 0$ we see that we have $$r(\phi) = \frac{\left(\phi - \frac{\phi^3}{6} + O(\phi^5)\right) - \phi \left( 1 - \frac{\phi^2}{2} + O(\phi^4)\right)}{\phi - \left(\phi - \frac{\phi^3}{6} + O(\phi^5)\right)} = \frac{ \frac{\phi^3}{3} + O(\phi^5) }{\frac{\phi^3}{6} + O(\phi^2)} = 2 \frac{1 + O(\phi^2)}{1 + O(\phi^2)}.$$ So, as $\phi \downarrow 0,$ we have $r(\phi) \to 2.$

Sunday, July 21, 2024

Tour de Fiddler fun

This time around, a lone rider in the Tour de Fiddler is being pursued by a group of four riders. The four riders have an advantage—they take equal turns being in the lead position, while the other three riders draft behind. At any given speed, being in the lead position (as well as riding solo) requires twice as much power as drafting.

Assume that every rider must maintain the exact same average power over time, whether they are the lone rider or in the pack of four. To be clear, their power can change over time, but the time-averaged value must be the same for every rider. Also, when leading a pursuing group or riding solo, one’s speed is directly proportional to one’s power. When drafting, one's speed matches that of the leader (again, at half the power output).

The pursuers just passed under a banner indicating there are 10 kilometers left in the stage. How far back of the lone rider can they afford to be, such that they still catch them at the finish line?

Let's first start with some preliminaries. Assume that all riders have average power output $\bar{P}$, such that, since speed is directly proportional to ones power, then the average speed of a single rider who has no one to draft off of is $v_1 = C\bar{P},$ for some constant of proportionality $C \gt 0.$

Let's now analyze what would happen if $k$ riders work together, taking equal turns being in the lead position. Since the average power must be $\bar{P},$ but any of the riders in this group spends only $\frac{1}{k}$ amount of time leading and the rest drafting at half-power, the amount of power spent while leading a pack of $k$ riders, say $P_k$, can be found in the equation $$\bar{P} = \frac{1}{k} P_k + \frac{k-1}{k} \frac{1}{2} P_k = \frac{k+1}{2k} P_k,$$ that is, $$P_k = \frac{2k}{k+1} \bar{P}.$$ So that means that the average velocity of a group of $k$ riders working together must be $$v_k = C P_k = C \frac{2k}{k+1} \hat{P} = \frac{2k}{k+1} v_1.$$

Ok, so with that in mind, the pursuers will finish in $T_4 = \frac{10}{v_4} = \frac{25}{4v_1},$ while if the leader has a lead of $x$ kilometers, then he will finish in $T_1 = \frac{10-x}{v_1}.$ Since we want $$T_4 = \frac{25}{4v_1} \leq \frac{10-x}{v_1} = T_1$$ in order for the pursuers to catch the leader, then the leader can be no more than $x \leq \frac{15}{4} = 3.75$ kilometers ahead of the pursuers if they want to catch him.

In today’s stage of the Tour de Fiddler, there are 176 total riders. Some riders are grouped together in a single breakaway, while the remainder are grouped together in the peloton. The breakaway group is 10 kilometers from the finish, while the peloton is one kilometer behind (i.e., 11 kilometers from the finish). What is the smallest number of riders that the breakaway needs to reach the finish line before the pursuing peloton?

Let's say there are $B$ riders in the breakaway group and $P$ riders in the peleton, where here $B+P = 176.$ The average speed of the peleton will be $$v_P = C\frac{2P}{P+1} v_1,$$ while the average speed of the breakaway is $$v_B = C\frac{2B}{B+1} v_1,$$ so the finishing times are $$T_P = \frac{11}{v_P} = \frac{11(P+1)}{2Pv_1}$$ and $$T_B = \frac{10}{v_B} = \frac{10(B+1)}{2Bv_1},$$ respectively. Since we want the breakaway group to win the stage, we must have $T_B \leq T_P,$ or equivalently $$\frac{10B+10}{B} \leq \frac{11P+11}{P},$$ which is again equivalent to $$BP+11B-10P \geq 0.$$ Since we have restriction that $B + P = 176,$ we are now looking for the minimum integer $B$ such that $$B(176-B) + 11B -10(176-B) = -B^2 + 197B - 1760 \geq 0.$$ Since the quadratic inequality holds for all (real) values of $$ B \in \left[ \frac{197 -\sqrt{31769}}{2} , \frac{197 + \sqrt{31769}}{2} \right],$$ we see that the breakaway must have at least $$B_\min = \left\lceil \frac{197 - \sqrt{31769}}{2} \right\rceil = \lceil 9.3806979381.... \rceil = 10$$ riders in order to beat the peleton.