Problems

Here are a few problems I like, each connected to something elsewhere on this site. The solutions are folded up, so try each one first.

1. Two random points

Pick two points uniformly at random in the unit square. What is the expected distance between them in the taxicab metric? What about in the ordinary Euclidean metric?

Solution

Write the points as (X1,Y1)(X_1, Y_1) and (X2,Y2)(X_2, Y_2), and let S=∣X1−X2∣S = |X_1 - X_2| and T=∣Y1−Y2∣T = |Y_1 - Y_2|. These are independent, and each is distributed like ∣U−V∣|U - V| for independent uniform U,VU, V on [0,1][0, 1], which has density 2(1−s)2(1 - s) on [0,1][0, 1].

Taxicab. The distance is S+TS + T, so by linearity of expectation its mean is 2 E S2\,\mathbb{E}\,S, where

E S=∫012s(1−s) ds=13.\mathbb{E}\,S = \int_0^1 2s(1 - s)\,ds = \frac{1}{3}.

The answer is 23\tfrac{2}{3}.

Euclidean. The distance is S2+T2\sqrt{S^2 + T^2}. The integrand is symmetric in ss and tt, so we can integrate over the half of the square where t≤st \le s and double the result. In polar coordinates that half is 0≤θ≤π/40 \le \theta \le \pi/4, 0≤r≤sec⁡θ0 \le r \le \sec\theta, so

ES2+T2=8∫0π/4 ⁣ ⁣∫0sec⁡θr2(1−rcos⁡θ)(1−rsin⁡θ) dr dθ.\mathbb{E}\sqrt{S^2 + T^2} = 8\int_0^{\pi/4}\!\!\int_0^{\sec\theta} r^2 (1 - r\cos\theta)(1 - r\sin\theta)\,dr\,d\theta.

The inner integral is sec⁡3θ12−sin⁡θ20cos⁡4θ\frac{\sec^3\theta}{12} - \frac{\sin\theta}{20\cos^4\theta}. Using ∫0π/4sec⁡3θ dθ=12(2+ln⁡(1+2))\int_0^{\pi/4} \sec^3\theta\,d\theta = \tfrac{1}{2}\big(\sqrt{2} + \ln(1 + \sqrt{2})\big) and ∫0π/4sin⁡θcos⁡4θ dθ=13(22−1)\int_0^{\pi/4} \frac{\sin\theta}{\cos^4\theta}\,d\theta = \tfrac{1}{3}\big(2\sqrt{2} - 1\big), we get

ES2+T2=8(2+ln⁡(1+2)24−22−160)=2+2+5ln⁡(1+2)15≈0.5214.\begin{aligned} \mathbb{E}\sqrt{S^2 + T^2} &= 8\left(\frac{\sqrt{2} + \ln(1 + \sqrt{2})}{24} - \frac{2\sqrt{2} - 1}{60}\right) \\ &= \frac{2 + \sqrt{2} + 5\ln(1 + \sqrt{2})}{15} \approx 0.5214. \end{aligned}

So on a grid you walk about 28% farther on average. That’s close to 4/π≈1.274/\pi \approx 1.27, the average ratio of taxicab to Euclidean length for a step in a uniformly random direction.

2. Staying below the diagonal

You walk from (0,0)(0, 0) to (n,n)(n, n) on a grid by a uniformly random shortest route, so each of the (2nn)\binom{2n}{n} routes is equally likely. What is the probability that you never step strictly above the line y=xy = x?

Solution

Call a route bad if it meets the line y=x+1y = x + 1. Since y−xy - x changes by exactly 1 at each step, these are exactly the routes that go above y=xy = x.

Given a bad route, reflect the portion after its first visit to y=x+1y = x + 1 across that line. The reflection maps (a,b)(a, b) to (b−1,a+1)(b - 1, a + 1), so the new route ends at (n−1,n+1)(n - 1, n + 1) instead of (n,n)(n, n). Conversely, along any route from (0,0)(0, 0) to (n−1,n+1)(n - 1, n + 1), the quantity y−xy - x starts at 0, ends at 2, and changes by 1 at each step, so the route meets y=x+1y = x + 1; reflecting the portion after its first meeting gives back a bad route. These two maps are inverses, so bad routes correspond exactly to routes ending at (n−1,n+1)(n - 1, n + 1), of which there are (2nn−1)\binom{2n}{n-1}. Therefore

P(never above)=(2nn)−(2nn−1)(2nn)=1−nn+1=1n+1.P(\text{never above}) = \frac{\binom{2n}{n} - \binom{2n}{n-1}}{\binom{2n}{n}} = 1 - \frac{n}{n+1} = \frac{1}{n+1}.

The numerator is the Catalan number CnC_n.

3. Turning up the shade

Heatwave’s Balanced mode picks the route that minimizes T+λST + \lambda S, where TT is the walking time, SS is the time spent in the sun, and λ≥0\lambda \ge 0 says how much you mind the sun. Fastest is λ=0\lambda = 0, and Coolest is the limit as λ→∞\lambda \to \infty.

  1. Show that raising λ\lambda never makes the chosen route sunnier or quicker. This should hold even when several routes tie and any of them might be chosen.
  2. Call a route efficient if no other route is at least as quick and at least as shady, and strictly better in one of the two. Give an example of an efficient route that is never chosen, whatever λ\lambda is.
Solution
  1. Let λ<μ\lambda < \mu, and let PP and QQ be routes chosen for λ\lambda and μ\mu, with walking times TP,TQT_P, T_Q and sun times SP,SQS_P, S_Q. Since PP is optimal for λ\lambda and QQ is optimal for μ\mu,

    TP+λSP≤TQ+λSQandTQ+μSQ≤TP+μSP.T_P + \lambda S_P \le T_Q + \lambda S_Q \quad\text{and}\quad T_Q + \mu S_Q \le T_P + \mu S_P.

    Adding these and cancelling gives (μ−λ)(SQ−SP)≤0(\mu - \lambda)(S_Q - S_P) \le 0, so SQ≤SPS_Q \le S_P. Substituting into the first inequality gives TP−TQ≤λ(SQ−SP)≤0T_P - T_Q \le \lambda (S_Q - S_P) \le 0, so TQ≥TPT_Q \ge T_P.

  2. Suppose there are only three routes. PP takes 10 minutes with 8 in the sun, QQ takes 12 with 6 in the sun, and RR takes 14 with 2 in the sun. Each one is quicker or shadier than each of the others, so all three are efficient. For QQ to be chosen, we would need 12+6λ≤10+8λ12 + 6\lambda \le 10 + 8\lambda, so λ≥1\lambda \ge 1, and also 12+6λ≤14+2λ12 + 6\lambda \le 14 + 2\lambda, so λ≤12\lambda \le \tfrac{1}{2}. No λ\lambda satisfies both.

    Geometrically, if each route is plotted as the point (T,S)(T, S), a weighted sum can only choose points on the lower-left edge of their convex hull, and QQ lies above the segment from PP to RR.

4. How long until a fall?

Model someone standing still as a random walk. The horizontal position of their center of mass starts at 0, every second it shifts one unit left or right, and they fall when it reaches ±k\pm k, the edge of their base of support.

  1. If each shift is equally likely to go either way, show that the expected time until a fall is k2k^2 seconds.
  2. Now suppose they correct themselves: whenever they’re off center, each shift moves them back toward the center with probability 23\tfrac{2}{3}. From the center, they still go either way with probability 12\tfrac{1}{2}. Show that the expected time until a fall is 2k+2−3k−42^{k+2} - 3k - 4 seconds.
Solution

The walk is symmetric about 0, so only the distance dd from the center matters. Let tdt_d be the expected time to first reach distance d+1d + 1, starting from distance dd. The expected time until a fall is t0+t1+⋯+tk−1t_0 + t_1 + \cdots + t_{k-1}, and t0=1t_0 = 1 because the first shift always moves away from the center.

For d≥1d \ge 1, let pp be the probability of a shift toward the center and q=1−pq = 1 - p. Condition on the first shift. With probability qq it reaches distance d+1d + 1 in one second. With probability pp it moves to distance d−1d - 1, after which it takes td−1t_{d-1} seconds on average to return to distance dd, and then tdt_d more. So

td=1+p (td−1+td),or equivalentlytd=1+p td−1q.t_d = 1 + p\,(t_{d-1} + t_d), \qquad \text{or equivalently} \qquad t_d = \frac{1 + p\,t_{d-1}}{q}.
  1. With p=q=12p = q = \tfrac{1}{2}, the recurrence is td=td−1+2t_d = t_{d-1} + 2, so td=2d+1t_d = 2d + 1, and the expected time is 1+3+⋯+(2k−1)=k21 + 3 + \cdots + (2k - 1) = k^2.

  2. With p=23p = \tfrac{2}{3} and q=13q = \tfrac{1}{3}, it is td=2td−1+3t_d = 2t_{d-1} + 3. Then td+3=2(td−1+3)t_d + 3 = 2(t_{d-1} + 3), so td=2d+2−3t_d = 2^{d+2} - 3, and the expected time is

    ∑d=0k−1(2d+2−3)=2k+2−3k−4.\sum_{d=0}^{k-1} \left(2^{d+2} - 3\right) = 2^{k+2} - 3k - 4.

So a modest correction turns a quadratic expected time into an exponential one: with k=10k = 10, it goes from 100 seconds to 4,062. The same argument shows that for any correction probability p>12p > \tfrac{1}{2}, the expected time grows like (p/(1−p))k\big(p/(1 - p)\big)^k.

Do you have a slicker solution, or a problem you think I’d like? Send it over.