Skip to content
Vamshi Jandhyala

Books · The Fiddler: Solutions

Chapter 69

Can You Spin the Graph?

You graph y=xy=|x|, but it is rotated about the origin by a uniformly random angle in [0,360)[0^\circ,360^\circ). What is the probability the rotated graph still passes the vertical line test (still defines yy as a function of xx)?

The Fiddler, Zach Wissner-Gross, January 31, 2025(original post)

Solution

The graph is two rays from the origin, 9090^\circ apart, initially pointing at 4545^\circ and 135135^\circ. A pair of rays passes the vertical line test exactly when the two rays lie on opposite sides of the vertical axis: if both rays had a horizontal component of the same sign, a vertical line just past the origin would cross both. Writing the rays after rotation as aa and a+90a+90^\circ, we need cosa\cos a and cos(a+90)=sina\cos(a+90^\circ)=-\sin a to have opposite signs, i.e. cosasina>0\cos a\sin a>0, i.e. sin2a>0\sin 2a>0. That holds for half of all aa, so P=12.P=\boxed{\tfrac12}.

The computation

Spin the actual graph: pick a random rotation, point both rays through it, and check whether their horizontal components disagree in sign (the vertical line test). The pass rate is one half.

import numpy as np
rng = np.random.default_rng(0)
phi = rng.uniform(0, 360, 2_000_000) * np.pi / 180
a, b = np.radians(45) + phi, np.radians(135) + phi
print((np.cos(a) * np.cos(b) < 0).mean())   # 0.5000

Extra Credit

Now z=x+yz=|x|+|y| is rotated by a uniformly random 33D rotation. What is the probability it still defines zz as a function of (x,y)(x,y)?

Solution

The surface has four planar faces with unit normals (±1,±1,1)/3(\pm1,\pm1,1)/\sqrt3. It remains a graph in the lab vertical direction exactly when that direction makes a positive dot product with every face normal, and a uniform random rotation sends the (un-rotated) vertical to a vector uu uniform on the sphere. Requiring u(±1,±1,1)>0u\cdot(\pm1,\pm1,1)>0 for all four sign choices collapses to the single condition uz>ux+uyu_z>|u_x|+|u_y|. The solid angle of that region gives P=1π0π/2 ⁣(11+sin2φ2+sin2φ)dφ0.1082.P=\frac1\pi\int_0^{\pi/2}\!\left(1-\sqrt{\frac{1+\sin2\varphi}{2+\sin2\varphi}}\right)d\varphi\approx\boxed{0.1082}. (The official extra-credit value is paywalled; this is my own.)

The computation

Encode the experiment rather than the integral: draw vectors uniformly on the sphere (a random orientation of the vertical) and measure how often all four faces still tilt upward, uz>ux+uyu_z>|u_x|+|u_y|.

u = rng.normal(size=(5_000_000, 3))
u /= np.linalg.norm(u, axis=1, keepdims=True)
print((u[:, 2] > np.abs(u[:, 0]) + np.abs(u[:, 1])).mean())   # 0.1082