About a month ago, math educator Marilyn Burns tweeted this puzzle:
Spoiler Alert: Stop here if you want to solve the puzzle yourself! Answers (some correct and some not) will be given below.
This innocent-seeming puzzle stirred several math teachers to exchange ideas, diagrams and animations. Some of them changed their minds about it as they worked through the problem. For example, Simon Gregg first thought that the answer is 1/4:
Upon further reflection, he changed his answer to 1/3:
There were some who used calculus to find a probability of 0.386. Gregg came to suspect they were right:
I approached the problem in a few ways myself. I thought about the sample space as sketched by Kaleb Allinson:
Assuming the spaghetti stick is one unit long, the horizontal axis represents the length of the shorter piece after the first break. Let’s call this . It must range between 0 and 1/2. The longer piece is then itself broken into a left piece with length and a right piece with length . I interpret the vertical axis in Allinson’s chart as the length . It could range between just above zero to nearly one if is very small, and it could range between between zero and around 1/2 if itself is close to 1/2. The length of the third side is not displayed in this diagram, but we can find it for any point by using .
The sample space of possible points combines the three right triangles in Allinson’s diagram. The shaded area in the middle represents the combinations of and that can lead to a spaghetti triangle. These combinations work because of the triangle inequalities, which require that no side be longer than the sum of the other two sides. Otherwise, the two shorter sides might just dangle pathetically off the long side like the arms of a T-Rex.
Allinson saw that one-third of the sample space corresponded to valid triangles, and so concluded that the probability of forming a triangle is 1/3. However, all parts of the diagram are not equally likely. All permitted values of are equally likely, but the distribution of depends on . When is very small, there is about a 50% chance that is less than 1/2. In contrast, when is near 1/2, there is almost a 100% change that is less than 1/2. The probability density in the diagram is not uniform; it increases from left to right.
In my mind, I pictured the probability density as a slanted roof above the diagram (in a third dimension). By some mental calculation I concluded that the probability of landing in the shaded area (what we might call the “triangle of triangles”) was 1/2.
To check my result, I made a spreadsheet to simulate many random spaghetti snaps. For each simulation, I sampled values for two random variables and , each uniformly distributed from 0 to 1. I used to set , the length of the shorter piece after the first break. We can let equal the lesser of and . We then find the next piece with . As mentioned above, the third piece . I set up the model to run 10,000 simulations and flag which ones could form triangles.
This is the result of one run with the and values plotted for each simulation. The blue dots indicate valid triangles. It looks like one-third of the points are good for triangles. However, the points are more crowded on the right than the left, and there are 3,823 blue dots out of 10,000 total. The blue triangle is denser than the orange areas and gets more than its share of the simulations.
Here is the same run plotted against the random variables and . The blue dots take up about 38% of the area of this evenly distributed chart.
I ran the spreadsheet several times and each time about 38% or 39% of the simulations allowed triangles. I had to doubt my answer of 1/2. I realized that the probability surface was not simply flat incline but something with a curve to it.
I communicated by Twitter and email with Mike Andrejkovics, a math teacher and math rapper(!) . He thought at first that the answer was 1/4 and he created a cool video to make his case. Mike then realized that his solution applied to a slightly different problem (see Variations below).
Like some of the other math teachers on Twitter, Mike used calculus to find the answer of .386 for the Marilyn Burns version of the problem. I decided to work through the calculus for myself. Mike had gotten me thinking some more about the probability density. None of the calculus solutions I had seen had provided an explicit formula for the probability density, but I thought that such a formula would clarify the problem for me.
Let be our probability density function (“pdf”) over the sample space in Kaleb Allinson’s diagram. This space ranges from 0 to 1/2 for the coordinate and from 0 to for the coordinate. We use to represent the length of the shorter piece after the first break. After the longer piece is broken into two pieces, the new piece on the left has length . The total probability over this space should equal one. In calculus notation, this means
The first statement integrates over the sample space . The second statement is equivalent. Working from the inside out, we begin by integrating as ranges from 0 to . This integral is basically just a function of , so we can write . Now our double integral becomes the single integral
We want to be constant, because we assume that is uniformly distributed from 0 to 1/2. The probability density in the sample space for each value of should be the same. Now if is constant, then it must equal 2 so that . Now we work back to the function . We need
which works with the pdf . Note that is a function of but not of . It grows along a curve from left to right.
Let’s look at this probability density function over the sample space. The volume enclosed by the figure is exactly one cubic unit, as required.
I like this shape. Every side could be made from a flat or rolled sheet of paper. Maybe architects should study probability density functions for inspiration!
Now let’s complete the solution to the spaghetti problem. We want to know the probability of landing in the shaded “triangle of triangles.” Call this region . Then the probability of making a triangle is
where represents the natural logarithm. I hope you don’t mind that I skipped over some of the integration steps at the end.
Let’s see what the solution looks like. Here is the probability density with the region for valid triangles colored in red. The volume of the red portion is 0.386.
The first version of the puzzle that Mike Andrejkovics solved appears as the “Walking Stick Puzzle” (#120) in The Puzzle Universe by Ivan Moscovich. This book was a great Christmas present from my wife. In the Walking Stick problem, the two breaks are made independently. It is not required that the second break occur along the longer piece after the first break.
I told my daughter (with whom I blog at Zeno’s Meatball) about the spaghetti puzzle. She interpreted the problem in physical terms. How do spaghetti strands really break? Aren’t they more likely to break near the middle than near the ends? Perhaps we grownups have been too simplistic with our uniform distributions.
Stayed tuned for a new variation on the puzzle that I will present in an upcoming post. I hope you enjoy it.
Copyright 2016. All Rights Reserved.