Monday, February 3, 2025

Spinning graphs and the vertical lines that test them

You’re taking a math exam, and you’ve been asked to draw the graph of a function. That is, your graph must pass the vertical line test, so that no vertical line intersects your function’s graph more than once.

You decide you’re going to graph the absolute value function, $y = |x|,$ and ace the test.

There’s just one problem. You are dealing with a bout of dizziness, and can’t quite make out the $x$- and $y$-axes on the exam in front of you. As a result, your function will be rotated about the origin by a random angle that’s uniformly chosen between $0$ and $360$ degrees.

What is the probability that the resulting graph you produce is in fact a function (i.e., $y$ is a function of $x$)?

Let's assume that the map of $y = |x|$ is rotated about the origin by an angle of $\theta \sim U(0^\circ,360^\circ)$ degrees with respect to the positive $x$-axis. We can think of this situation as defining a new set of variables $$\begin{pmatrix} \tilde{x} \\ \tilde{y} \end{pmatrix} = \begin{pmatrix} \cos \frac{\pi\theta}{180} & -\sin \frac{\pi\theta}{180} \\ \sin \frac{\pi\theta}{180} & \cos \frac{\pi\theta}{180} \end{pmatrix} \begin{pmatrix} x \\ |x| \end{pmatrix} = \begin{pmatrix} x \cos \frac{\pi\theta}{180} - |x| \sin \frac{\pi\theta}{180} \\ x \sin \frac{\pi\theta}{180} + |x| \cos \frac{\pi\theta}{180} \end{pmatrix}.$$ So we have $\tilde{x} = f(x)$ and $\tilde{y} = g(x)$ as parametric functions of our previous variable $x.$

Now we see that if $f$ is one-to-one, then the parametric curve $(f(x), g(x))$ will pass the vertical line test, since there is only one possible value of $x$ such that $\tilde{x} = f(x),$ then there can only be at most one intersection between any vertical line and the curve.

On the other hand, if $f$ is not one-to-one, then for some $x_1 \ne x_2,$ we have $f(x_1) = f(x_2).$ In this case, since $f(x_1) = f(x_2),$ we have equivalently $$(x_1 - x_2) \cos \frac{\pi \theta}{180} = ( |x_1| - |x_2| ) \sin \frac{\pi \theta}{180}.$$ Now let's look at the values of $g(x_1)$ and $g(x_2).$ If $\sin \frac{\pi\theta}{180} = 0,$ then $f(x) = x \cos \frac{\pi\theta}{180},$ which is a one-to-one function, so if $f$ is not one-to-one then we can assume that $\sin \frac{\pi \theta}{180} \ne 0.$ Therefore, we have \begin{align*}g(x_1) - g(x_2) &= (x_1 - x_2) \sin \frac{\pi \theta}{180} + (|x_1| - |x_2| ) \cos \frac{\pi \theta}{180} \\ &= (x_1 - x_2) \sin \frac{\pi \theta}{180} + (|x_1| - |x_2|) \sin \frac{\pi \theta}{180} \frac{ \cos \frac{\pi \theta}{180}}{\sin \frac{\pi\theta}{180}} \\ & = (x_1 - x_2) \sin \frac{\pi \theta}{180} + (x_1 - x_2) \cos \frac{\pi \theta}{180} \frac{\cos \frac{\pi \theta}{180}}{\sin \frac{\pi \theta}{180}} \\ &= (x_1 - x_2) \left( \sin \frac{\pi \theta}{180} + \frac{ \cos^2 \frac{\pi \theta}{180}}{\sin \frac{\pi \theta}{180}} \right) \\ &= \frac{ x_1 - x_2}{\sin \frac{\pi \theta}{180}},\end{align*} so since $x_1 \ne x_2,$ we have $g(x_1) \ne g(x_2).$ Thus, the vertical line $\tilde{x} = f(x_1) = f(x_2)$ would intersect the curve at $\tilde{y}_1 = g(x_1)$ and $\tilde{y}_2 = g(x_2),$ with $\tilde{y}_1 \ne \tilde{y}_2.$ Thus, if $f$ is not one-to-one then the parametric curve will fail the vertical line test. Therefore, the parametric curve will pass the vertical line test if and only if $f$ is one-to-one.

So let's analyze the function $$f(x) = x \cos \frac{\pi\theta}{180} - |x| \sin \frac{\pi\theta}{180}.$$ We see that $$f^\prime(x) = \begin{cases} \cos \frac{\pi\theta}{180} + \sin \frac{\pi\theta}{180}, &\text{if $x \lt 0$;} \\ \cos \frac{\pi\theta}{180} - \sin \frac{\pi\theta}{180}, & \text{if $x \gt 0.$} \end{cases}$$ If $f$ is monotonic, then it is obviously one-to-one, so we need only determine for what values of $\theta \in (0^\circ, 360^\circ)$ does $\cos \frac{\pi\theta}{180} - \sin \frac{\pi\theta}{180}$ and $\cos \frac{\pi\theta}{180} + \sin \frac{\pi\theta}{180}$ have the same signs, that is, when does $$0 \lt \left(\cos \frac{\pi\theta}{180} - \sin \frac{\pi\theta}{180}\right) \left( \cos \frac{\pi\theta}{180} + \sin \frac{\pi\theta}{180} \right) = \cos^2 \frac{\pi\theta}{180} - \sin^2 \frac{\pi\theta}{180} = \cos \frac{\pi\theta}{90}.$$ So since $\cos x \gt 0$ on $x \in [ 0, \frac{\pi}{2} ) \cup ( \frac{3\pi}{2}, 2\pi],$ we see that the resulting graph will pass the vertical line test whenever $\theta \in [ 0^\circ, 45^\circ ) \cup (135^\circ, 225^\circ) \cup ( 315^\circ, 360^\circ ],$ which means that the probability of passing the vertical line test if $\theta \sim U(0,360)$ is $$p = \frac{|45 - 0| + |225 - 135| + |360 - 315|}{360} = \frac{1}{2}.$$

No comments:

Post a Comment