Monday, December 25, 2023

Voluminous rectangular prisms

There are several rectangular prisms with integer edge lengths that have an internal diagonal of length $2024.$ What is the greatest volume among these prisms?

Let's say we have a retangular prism with length $\ell,$ width $w,$ and height $h.$ The volume is $V = \ell w h$ while the length of the internal diagonal is $L = \sqrt{\ell^2 + w^2 + h^2}.$ In this case, we then need to looks for all Pythagorean quadruples $a^2 + b^2 + c^2 = d^2$ that have $d=2024.$ While we certainly could use primitive Pythagorean quadruples for the odd divisors of $2024$ (namely, $11$, $23,$ and $253$), we might as well just brute force the entire thing and do a dumb search: In a series of nested loops, we can loop through $a = 1, \dots, 2024,$ $b = a, a+1, \dots, 2024,$ and $c = b, b+1, \dots, 2024$ and print out the triple $(a, b, c)$ any time that $a^2 +b^2 + c^2 = 2024^2.$ This yields the following forty-one quadruples:

\begin{align*} 24^2 + 640^2 + 1920^2 &= 2024^2 \\ 24^2 + 1152^2 + 1664^2 &= 2024^2 \\ 64^2 + 168^2 + 2016^2 &= 2024^2 \\ 64^2 + 1344^2 + 1512^2 &= 2024^2 \\ 96^2 + 152^2 + 2016^2 &= 2024^2 \\ 96^2 + 872^2 + 1824^2 &= 2024^2 \\ 96^2 + 936^2 + 1792^2 &= 2024^2 \\ 96^2 + 1088^2 + 1704^2 &= 2024^2 \\ 152^2 + 864^2 + 1824^2 &= 2024^2 \\ 168^2 + 1344^2 + 1504^2 &= 2024^2 \\ 192^2 + 856^2 + 1824^2 &= 2024^2 \\ 192^2 + 1304^2 + 1536^2 &= 2024^2 \\ 224^2 + 600^2 + 1920^2 &= 2024^2 \\ 224^2 + 672^2 + 1896^2 &= 2024^2 \\ 224^2 + 1176^2 + 1632^2 &= 2024^2 \\ 264^2 + 528^2 + 1936^2 &= 2024^2 \\ 264^2 + 1232^2 + 1584^2 &= 2024^2 \\ 280^2 + 576^2 + 1920^2 &= 2024^2 \\ 360^2 + 800^2 + 1824^2 &= 2024^2 \\ 360^2 + 1376^2 + 1440^2 &= 2024^2 \\ 368^2 + 1104^2 + 1656^2 &= 2024^2 \\ 424^2 + 480^2 + 1920^2 &= 2024^2 \\ 424^2 + 768^2 + 1824^2 &= 2024^2 \\ 424^2 + 1248^2 + 1536^2 &= 2024^2 \\ 480^2 + 576^2 + 1880^2 &= 2024^2 \\ 528^2 + 1144^2 + 1584^2 &= 2024^2 \\ 576^2 + 744^2 + 1792^2 &= 2024^2 \\ 576^2 + 928^2 + 1704^2 &= 2024^2 \\ 576^2 + 1216^2 + 1512^2 &= 2024^2 \\ 576^2 + 1368^2 + 1376^2 &= 2024^2 \\ 600^2 + 640^2 + 1824^2 &= 2024^2 \\ 672^2 + 936^2 + 1664^2 &= 2024^2 \\ 672^2 + 1176^2 + 1504^2 &= 2024^2 \\ 744^2 + 1088^2 + 1536^2 &= 2024^2 \\ 768^2 + 1304^2 + 1344^2 &= 2024^2 \\ 768^2 + 1304^2 + 1344^2 &= 2024^2 \\ 856^2 + 1248^2 + 1344^2 &= 2024^2 \\ 864^2 + 1216^2 + 1368^2 &= 2024^2 \\ 928^2 + 936^2 + 1536^2 &= 2024^2 \\ 936^2 + 1152^2 + 1376^2 &= 2024^2 \\ 1104^2 + 1104^2 + 1288^2 &= 2024^2 \end{align*}

The rectangular prism with integral edge lengths internal diagonal length of $2024$ with the largest volume is $1104 \times 1014 \times 1288$ which has volume $1,569,835,008.$ Note that this is not necessarily that far from the overall, non-integral solution of a cube with side length $2024 / \sqrt{3}$ which has volume $1,595,694,111.621353...$, which is only about $1.6\%$ larger than the volume of the integral rectangular prism, so not too shabby.

Monday, December 18, 2023

You've got be flipping kidding me!

Kyle and Julien are playing a game in which they each toss their own fair coins. On each turn of the game, both players flip their own coin once. If, at any point, Kyle’s most recent three flips are Tails, Tails, and Heads (i.e., TTH), then he wins. If, at any point, Julien’s most recent three flips are Tails, Tails, and Tails (i.e, TTT), then he wins.

However, both players can’t win at the same time. If Kyle gets TTH at the same time Julien gets TTT, then no one wins, and they continue flipping. They don’t start over completely or erase their history, mind you—they merely continue flipping, so that one of them could conceivably win in the next flip or two.

What is the probability that Kyle wins this game?

This game, like many coin flipping problems of its ilk, can be modeled as a Markov chain. There are two absorbing states, let's call them, $\textsf{WinJ}$ and $\textsf{WinK}$, and nine transient states, call them, $(i, j)$ where $i, j \in \{0, T, TT\},$ represent the state where Julien is in state $i$ and Kyle is in state $j.$ State $(0,0),$ which represents both the starting space and the case that both Julien and Kyle just flipped H and that Kyle's last three flips were not TTH, can transition to $(T,0)$, $(0,T)$, $(T,T)$ or itself, each with equal probability. On the other hand, we see that due to the tie breaker procedures, state $(TT, TT)$ can transition to $(0,0)$, $\textsf{WinJ}$, $\textsf{WinK}$ and $(TT,0),$ each with equal probability. We can similarly build up all of the other transitions Let's represent the probabilistic state of the system as $\pi = (p_\textsf{WinJ}, p_\textsf{WinK}, p_{(0,0)}, p_{(0,T)}, p_{(0,TT)}, p_{(T,0)}, p_{(T,T)}, p_{(T,TT)}, p_{(TT,0)}, p_{(TT,T)}, p_{(TT,TT)} ) \in [0,1]^{11},$ then the probability transition matrix can be represented as $$P = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0.25 & 0.25 & 0 & 0.25 & 0.25 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0.25 & 0 & 0.25 & 0.25 & 0 & 0.25 & 0 & 0 & 0 \\ 0 & 0.5 & 0.25 & 0 & 0 & 0.25 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0.25 & 0.25 & 0 & 0 & 0 & 0 & 0.25 & 0.25 & 0 \\ 0 & 0 & 0.25 & 0 & 0.25 & 0 & 0 & 0 & 0.25 & 0 & 0.25 \\ 0 & 0.5 & 0.25 & 0 & 0 & 0 & 0 & 0 & 0.25 & 0 & 0 \\ 0.5 & 0 & 0.25 & 0.25 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0.5 & 0 & 0.25 & 0 & 0.25 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0.25 & 0.25 & 0.25 & 0 & 0 & 0 & 0 & 0 & 0.25 & 0 & 0 \end{pmatrix}.$$ We can subdivide the transition matrix into the resolving states, $$R = \begin{pmatrix} 0 & 0 \\ 0 & 0 \\ 0 & 0.5 \\ 0 & 0 \\ 0 & 0 \\ 0 & 0.5 \\ 0.5 & 0 \\ 0.5 & 0 \\ 0.25 & 0.25 \end{pmatrix}$$ and the transitory states $$T = \begin{pmatrix} 0.25 & 0.25 & 0 & 0.25 & 0.25 & 0 & 0 & 0 & 0 \\ 0.25 & 0 & 0.25 & 0.25 & 0 & 0.25 & 0 & 0 & 0 \\ 0.25 & 0 & 0 & 0.25 & 0 & 0 & 0 & 0 & 0 \\ 0.25 & 0.25 & 0 & 0 & 0 & 0 & 0.25 & 0.25 & 0 \\ 0.25 & 0 & 0.25 & 0 & 0 & 0 & 0.25 & 0 & 0.25 \\ 0.25 & 0 & 0 & 0 & 0 & 0 & 0.25 & 0 & 0 \\ 0.25 & 0.25 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0.25 & 0 & 0.25 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0.25 & 0 & 0 & 0 & 0 & 0 & 0.25 & 0 & 0 \end{pmatrix}$$ such that we can represent the transition matrix $P$ in block form as $P = \begin{pmatrix} I & 0 \\ R & T \end{pmatrix}.$ If we start at particular state, say $\pi_0,$ then by the $n$th step, our probabilistic state is $$\pi_n = \pi_0 P^n = \pi_0 \begin{pmatrix} I & 0 \\ (I + T + T^2 + \dots + T^{n-1}) R & T^n \end{pmatrix}.$$ If we let $n \to \infty,$ then since $T^n \to 0$ and $I + T + T^2 + \dots + T^{n-1} \to (I - T)^{-1},$ we have that the ultimate transition matrix is $$\pi_\infty = \pi_0 \begin{pmatrix} I & 0 \\ (I - T)^{-1} R & 0 \end{pmatrix}.$$

Here, the probability that Kyle wins is given by the $p_\textsf{WinK}$ (2nd) entry in $\pi_\infty.$ Since we are starting at $\pi_0 = (0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0),$ and we are only concerned with $p_\textsf{WinK}$ we can instead of solving the entire matrix inverse of $I - T$ rather just solve the system of equations $$(I - T) x = R \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \\ 0.5 \\ 0 \\ 0 \\ 0.5 \\ 0 \\ 0 \\ 0.25 \end{pmatrix}$$ and then taking the first coordinate. Choosing your favorite matrix alegbra software, programming language or, due to certain foibles with which you are burdened, a bunch of loose leaf paper and loads of patience, you get to the probability that Kyle will win as $$p_\textsf{WinK} = \frac{36367}{74368} = 48.9014....\%$$