Spaghetti Problem

This content is from http://www.alethis.net/mpotd/mpotd.php?id=00131

You have a plate of spaghetti in front of you (no sauce!). You pick two ends and tie them together. Then you pick two more ends and tie them together. Continue until there are no free ends left.

If there were n spaghettis originally, what is the probability that you now have a single giant loop consisting of all the spaghettis?

Pick the first end at random, from the 2n ends. When you pick the second end, you have 2n-1 choices, and exactly one of them (the other end of the spaghetti you chose) will create a loop at this step. The probability of creating a loop at this step is therefore 1/(2n-1), so the probability of not creating a loop is (2n-2)/(2n-1).

If we don’t create a loop at the first step, then at the second step, we have the same situation, but with 2n-2 free ends. Pick one end at random, and the probability of forming a loop at this step is 1/(2n-3), since there’s only one other end that is attached to the end you chose. The probability of not creating a loop at the second step is therefore (2n-4)/(2n-3).

When we eventually get down to two remaining segments, the same logic applies: pick one end, and of the remaing three ends, one forms a loop, while the other two allow us to proceed to the last step, where a single giant loop is formed. The probability is 2/3 of not creating a loop at this second last step.

To end up with a single loop at the end, we must not create a loop at any of the intermeditate steps, so the probability of this is:

2n – 22n – 42n – 62
2n – 12n – 32n – 53
=2n – 22n – 22n – 42n – 42n – 62n – 622
2n – 12n – 22n – 32n – 42n – 52n – 632
=4n-1(n – 1)!2
(2n – 1)!

The first few probabilities are:

nprob.
11
22/3
38/15
416/35

‘frac’

Syntax

frac(x)

Description

frac(x) represents the “fractional part” x-floor(x) of the number x.

For complex arguments, frac is applied separately to the real and imaginary part.

For real numbers, the value x-floor(x) represented by frac(x) is a number from the interval . For positive arguments, you may think of frac as truncating all digits before the decimal point.

For integer arguments, 0 is returned. For rational arguments, a rational number is returned. For arguments that contain symbolic identifiers, symbolic function calls are returned. For floating-point arguments or non-rational exact expressions, floating-point values are returned.

Cited as:

https://www.mathworks.com/help/symbolic/mupad_ref/frac.html

https://mathworld.wolfram.com/FractionalPart.html