Chapter 61
Can You Bake The Radish Pie?
Riddler Express
Start with any positive amount of flour. Replace it by the average of itself and divided by itself, and repeat forever. How many cups does the recipe converge to?
Solution
Call the running amount . Each step sends to . If this settles to a limit, the limit is a fixed point, unchanged by the step: The recipe is Newton’s method for in disguise: the iteration converges to from any positive start, here with . So whatever amount of flour you begin with, you end at cups.
The computation
Iterate the recipe from an arbitrary start and watch it converge.
def num_cups(start=2.0):
s = start
while True:
c = 0.5 * (s + 3 / s)
if abs(s - c) < 1e-12: return c
s = c
print(num_cups()) # 1.7320508... = sqrt(3)
Riddler Classic
In a regular -gon with side length , take a longest diagonal (joining opposite vertices). The diagonals perpendicular to it slice it into pieces. What is the product of the piece lengths? Extra credit: in a regular -gon with side , slice the altitude from a vertex the same way into pieces, and find that product.
Solution
Put the long diagonal on the -axis. Going up the right half of the polygon, each successive side turns by , and the perpendicular diagonals meet the axis at the vertices’ -coordinates. The piece between two consecutive cuts is the projection of one side onto the axis, which for the -th side works out to so the product is . To evaluate it, recall that the non-trivial -th roots of unity give . Writing each sine through complex exponentials and separating the odd-indexed factors from the even-indexed ones turns the product into divided by : Remarkably the side length and the value drop out entirely. For the odd case the same sine-product identity splits into odd and even terms, each equal to , giving :
The computation
For , build the polygon from coordinates, find where the perpendicular (vertical) diagonals cut the horizontal long diagonal, and multiply the gaps. For the odd case multiply the piece lengths directly.
import numpy as np
def diagonal_product(n): # even n: direct construction
R = 1 / np.sin(np.pi / n) # circumradius, side length 2
cuts = sorted({R * np.cos(2 * np.pi * j / n) for j in range(n // 2 + 1)})
return np.prod(np.diff(cuts))
print(diagonal_product(1000)) # 2.0
k = np.arange(1, 501)
print(np.prod(2 * np.sin((2 * k - 1) * np.pi / 1001))) # 31.638... = sqrt(1001)