A calculator is broken so that the only

April 27, 2013

A calculator is broken so that the only keys that still work are the sin, cos, tan, arcsin, arccos, and arctan buttons. The display initially shows 0. Given any positive rational number q, show that pressing some finite sequence of buttons will yield q. Assume that the calculator does real number calculations with infinite precision. All functions are in terms of radians.

I’ve started reading Zeitz’s The Art and Craft of Problem Solving. This one took me about 90 minutes, though as usual, once I had a solution it seemed obvious. Originally from USAMO 1995. Who comes up with these problems? How? You sit down and say, “Okay, it’s time to invent a problem that can be solved with elementary math, but only if you see some diabolical trick”, and then you do what?

Integration by parts

April 19, 2013

How did loving the ground-up toenails of bisexuals get an interior designer to take up geology? Simple, he went from noting decor to what the core denotes by being into grated bi-parts.

I don’t really get why this XKCD is funny.

But here is a picture explaining integration by parts:

The area of the entire rectangle is $uv$, and it is made of two parts we integrate, so

$uv = \int \!u\, \text{d}v + \int\! v\,\text{d}u$

and therefore

$\int \! u \,\text{d}v = uv - \int\! v \,\text{d}u$

Also, take $\text{d}(uv) = \text{d}(\int \!u \,\text{d}v + \int \!v\,\text{d}u)$ and you find

$\text{d}(uv) = u \,\text{d}v + v\,\text{d}u$,

which is the product rule.

Bayesian Bro Balls and Monty Hall

April 13, 2013

I don’t think this is very good, but I’m tired of working on it and I said I’d write it, so here it is. See http://yudkowsky.net/rational/bayes for a better essay on thinking about probability.

A woman and a man (who are unrelated) each have two children. We know that at least one of the woman’s children is a boy and that the man’s oldest child is a boy. Can you explain why the chances that the woman has two boys do not equal the chances that the man has two boys?

(text copied from here, which attributes the problem’s popularity to an “Ask Marilyn” column in 1996)

Given a tricky problem, some people are stumped, clever people find a tricky answer, and brilliant people find a way of thinking so the problem isn’t tricky any more. This problem is about interpreting evidence, and the brilliant person who discovered how to think about evidence is Laplace. (His method is called Bayes’ Rule. Bayes came first, but Laplace seems more important based on my cursory reading of the history.) To illustrate it, let’s start with different problem, related only by the fact that it’s also about using evidence.

I picked a day of the week by first choosing randomly between weekend and weekday, then picking randomly inside that set. I wrote my chosen day down and picked a letter at random. The letter was ‘d’. What is your best guess for the day that I picked? How confident are you? (“At random” means there was uniform probability.)

First, write out all the possibilities. These are called the “hypotheses” (plural of “hypothesis”).

• Saturday
• Sunday
• Monday
• Tuesday
• Wednesday
• Thursday
• Friday

Next, find their starting probabilities, the ones we have before learning what letter was picked. Half the probabilities goes to the weekend, so they’re 1/4 each. The rest goes to the five weekdays, so they’re 1/10 each. This is called the “prior”. The picture shows lengths proportional to probability.

Let’s imagine we did this experiment 10,080 times (a number I’m choosing since it will work out well later). Then the weekends come up 2520 times each and the weekdays 1008 times each. (This is the expectation value for how many times these days would show up. In a real experiment there would be random deviations.)

Next we look at the evidence – the letter ‘d’. Out of our 10,080 experiments, how many have the letter ‘d’ result? It turns out this will happen 1565 times – 315 times on Saturday, 420 times on Sunday, etc.

The illustration looks like this (partially filled in)

The bottom bar represents all the trial where the letter ‘d’ popped up. It is too small to read, so we’ll blow it up.

We can divide by the total number of times the letter ‘d’ came up to get the probabilities. (Individually this step is called “normalizing”, but it’s really part of updating.)

We don’t really need to consider doing the experiment 10,080 times; I just thought that made it more convenient to visualize. What’s important is the probability distribution at the end. This solves the problem. We now know, given that ‘d’ was the chosen letter, the probability for each day of the week.

To recap, an outline for the procedure is

1. Find all the possibilities (i.e. define the hypotheses).
2. Determine how likely the hypotheses are beforehand (i.e. choose the prior).
3. Update the hypotheses based on how well they explain the data (i.e. multiply them by their probabilites of producing the evidence).
4. Finish updating by making the hypotheses’ probability add up to one (i.e. normalize).

Let’s reword the original problem to make it clear exactly what evidence we’re collecting, then apply the method:

There are two bros who like to tan their balls. Unfortunately, this can cause testicular cancer. Given their amount of ball-tanning, each testicle of each bro has a 50% chance of having cancer. (The testicles are all statistically independent of each other.) The two bros decide to conduct testicular exams to see whether they have cancer, and their self-administered exams are perfectly accurate. The first bro decides to examine both his testicles, then report whether or not at least one of them has cancer. The second bro decides to examine only his left testicle because he thinks that examining both would count as cradling them and be gay. Suppose the first bro reports that indeed, at least one of his balls has cancer. The second bro reports that his left ball has cancer. Do they have the same probability of having two balls with cancer?

The bros go about collecting different data. The evidence they bring to bear is different, so a good way of handling evidence should be able to show us that the probabilities are different. But there is no need to be clever about finding the solution when you have a general method at hand.

The hypotheses we’ll use are left/right both cancerous, left cancerous/right healthy, left healthy/right cancerous, both healthy. They are all equally likely.

In this case, updating is very simple. Each hypothesis explains the results either perfectly or not at all. Here is what updating looks like for the bro who tested both balls:

Here it is for the bro who tested on the left ball:

So the bro who tested both balls has a 1/3 chance of having cancer in both balls, while the bro who tested the left ball has a 1/2 chance. Both came back with a positive result, but the bro who tested both balls has weaker evidence. It is easier to satisfy “at least one ball has cancer” than to satisfy “the left ball has cancer”, so when he comes back and reports that at least one ball has cancer, he hasn’t given as much information, and his probability doesn’t shift upwards as much. A strong test is one which the hypothesis of interest passes, but which eliminates the competing hypotheses. More hypotheses pass the test “at least one ball has cancer”, so that test doesn’t eliminate as much and is not as strong.

Let’s apply the same method to the Monty Hall problem. Your hypotheses are that the prize is behind door one, door two, or door three. These are equally-likely to begin. You choose door one, and Monty Hall opens door two. That’s the evidence.

If the prize is behind door one (the door you chose), Monty Hall could have opened either door 2 or door 3, so there was a 50% chance to see the observed evidence. If the prize was behind door 2, there was 0% chance, so that hypothesis is gone. If the prize was behind door 3, Monty Hall was forced to open door two, so that hypothesis explained the evidence 100% and becomes more likely.

Here’s a diagram for the probabilities after updating:

So you should switch doors. The usefulness of this method is you don’t need a clever trick specific to the Monty Hall problem. As long as you understand how evidence works, you can solve the problem without thinking and spend your limited thinking power somewhere else.

Within this framework, we can notice some things that help make the problem more intuitive, even after it’s solved. Suppose you have a hypothesis and you collect some evidence. How much more-likely does the hypothesis become? What matters is how much better the hypothesis explains the data than the other hypotheses, not just how well it does by itself. So, if you have two hypotheses and they both explain the data equally well, that data isn’t evidence either way.

You can apply this idea to the bro who tested his left testicle. Whether the right testicle has cancer or not, the data on the left testicle is equally-well explained. Therefore, the right testicle’s probability remains unchanged from 50%, so the bro has a 50% chance of two cancerous balls.

The same is not true for the bro who tested both testicles. If that bro has cancer in his right testicle, that explains the result better than if he doesn’t. That is to say, if the bro has cancer on his right testicle, that explains the result perfectly. But if he doesn’t, there’s only a 50% chance of explaining the result. As a result, the 1:1 odds for the right testicle get multiplied by 2:1 to give 2:1 odds. The probability for his right ball to have cancer increases to 2/3. (The probability for his left testicle to have cancer is also 2/3, but they are not independent.)

In the Monty Hall problem, Monty Hall will reveal an empty door no matter what, so the hypothesis “the prize was behind your original door” explains the data just as well as “the prize was not behind your original door”. Therefore, the probability that the prize was behind your original door doesn’t change; there was no evidence for it. So your original door still has a 1/3 chance. So good Bayesians are not confused by the Monty Hall problem.

Spinning Room (puzzle)

January 21, 2013

Some discussion on Facebook led me to this puzzle:

You’re in a room with four holes, and through each hole is a button. Each time you press the button, it toggles between on and off, but you don’t know what it is to begin with and can’t tell the difference when you press the button. You have two hands, so you stick them through any two holes you choose, then either press the buttons or not. After you press the buttons, they spin around a random number of quarter turns. You can then do it again, but you don’t know whether you’re pressing the same or different buttons as last time. You’ll be free from the room when all four buttons are on or all four are off. How can you escape the room with 100% accuracy in finite time?

Here’s how I thought about it:

First, it doesn’t matter if, for example, you use the holes front and left or left and back. These are both adjacent holes, and since you don’t know how the thing’s been spun, it’s functionally the same. Thus, on each turn you only have three choices:

1) Press a single random button.

2) Press two opposite buttons.

3) Press two adjacent buttons.

Next, let’s consider the possible states of the buttons. For example, you could have three on and one off. There are four different way to do this, but since the thing spins randomly, they are all the same as each other and we can count them as one. Also, the problem is symmetric with respect to switching “on” and “off”, so we can consider three on/one off and three off/one on to be the same state. Thus, there are only four states:

F: freedom

A: 3/1

B: 2/2, with opposite switches the same

C:2/2, with adjacent switches the same

Next we draw a graph showing how choices 1,2, and 3 take us between states. Blue is 1, Red is 2, Green is 3. When there are different arrows of the same color, that choice has the ability to take us different places at random.

It’s now pretty easy to make sure we escape to F. The red choice is convenient. With it, we either escape or stay put, so start with red. If you’re still stuck, you’re in either A or C. Green is now convenient because it leaves A alone while reducing C to a previously-solved case, so use green, and if not free, red. If you’re still not free, you must be on A, so do blue, red, green, red and you’ll be free.

Translating this back into the original problems, you do:

Opposite buttons

Opposite buttons

One button

Opposite buttons

Opposite buttons

and by the time you finish all that, you’re guaranteed free.

Most of the work here was just in finding a decent way to re-visualize the problem. Once we drew the graph, finding the way out was trivial. I’ve frequently found this to be the case with tricky problems. Of course, the other main tool to solve them is “assume a clever solution exists, then work backwards.”

On the Height of a Field

January 1, 2013

This is a short story about belief and evidence, and it starts with the GPS watch I use when I go for a run. Here’s the plot of my elevation today:

It looks a little odd until I show you this map of the run:

Each bump on the elevation plot is one lap of the field. In the middle, I changed directions, giving the elevation chart an approximate mirror-image symmetry. (I don’t know what causes the aberrant spikes, but my friend reports seeing the same thing on his watch.)

According to the GPS data, the field is sloped, with a max height of 260 feet near the center field wall and 245 feet near home plate. It’s insistent on this point, reiterating these numbers each time I do the run (except once when the tracking data was clearly off, showing me running across parking lots and through nearby buildings.) I disagreed, though. The field looked flat, not sloped at 3 degrees. I was disappointed to have found a systematic bias in the GPS data.

But I occasionally thought of some minor consideration that impacted my belief. I remembered that when I went biking, I often found that roads that look flat are actually uphill, as can be verified by changing directions and feeling how much easier it becomes to go a given pace. I Googled for the accuracy of GPS elevation data, and found that it’s only good to about 10 meters. But I didn’t care about absolute elevation, only change across the field, and I couldn’t find any answers on the accuracy of that. (Quora failed me.) I checked Google Earth, and it corroborated the GPS, saying the ground was 241 ft behind home plate and 259 in deep center field. But then I read that the GPS calibrated its elevation reading by comparing latitude/longitude coordinates with a database, and so may have been drawing from the same source as Google Earth.

People wouldn’t make a sloped baseball field, would they? That would dramatically change the way it plays, since with a 15-foot gain, what was once a solid home run becomes a catch on the warning track. Googling some more, I found that baseball fields can be pretty sloped; the requirements are fairly lax, and in fact they are typically sloped to allow drainage.

I was starting to doubt my initial judgment, and with this in mind, when I looked at the field, it made more and more sense that it’s sloped. Along the right field fence, there’s a short, steep hill leading up to the street. It’s about five feet high and at least a 30-degree slope. It’s completely unnatural, as if it exists because the field as a whole used to be considerably more sloped, but was dug out and flattened. The high edge of the field was then below street level, so there’s that short, steep hill leading up. And if the field was dug out and flattened, maybe they didn’t flatten it all the way. The entire campus is certainly sloped the same general direction as the GPS claimed for the field. It drops about 70 feet from north to south, and it’s frequently noticeable as you walk or bike around. There’s another field I run on with essentially the same deal, and I found that when I knew what to look for, I could indeed see the slope there.

Eventually, the speculation built up enough to warrant a little effort to make a measurement. I asked a wise man what to do, and he suggested I find a protractor, hang a string down to detect gravity, and site from one side of the field to the other. I did so, expecting to feel the boldness of an impartial, truth-seeking scientific investigator as I strode across the grass. That wasn’t what I got at all.

First, I felt continuous fluctuations in my confidence. “I’m 60% confident I’ll find the field is sloped,” I told myself, then immediately changed it to 75, not wanting to be timid, then felt afraid of being wrong, and went back to 50. I’ve played The Calibration Game and learned what beliefs mean, and mostly what it’s done is give me the ability to not only be uncertain about things, but to be meta-uncertain as well – not sure just how uncertain I am, since I don’t want to be wrong about that!

Second, I felt conflicting desires. I couldn’t decide what I wanted the result to be. I wanted the field to be flat to validate my initial intuition, not the stupid GPS, but I also wanted the field to be sloped so I could prove to myself my ability to change my beliefs when the evidence comes in, even if it goes against my ego. (A strange side-effect of wanting to believe true things is that you find yourself wanting to do things not because they help you believe the truth, but because you perceive them to be the sort of things that truth-seekers would do.) I recalled a video I had seen years ago about Gravity Probe B, and the main thing I remembered from it was a scientist with long, gray hair and huge unblinking eyeballs explaining in perfect monotone that he didn’t have a desire for the experiment to confirm or refute general relativity; he only wanted it to show what reality was like.

On top of all this, there was the sense of irony at so much mental gymnastics over a triviality like the slope of a baseball field, and the self-consciousness at the absurdity of standing around in the cold pointing jerry-rigged protractors at things. So at last I crossed the field and lined up my protractor for the moment of truth

It didn’t work. I had placed my shoes down on the grass as a target to site, but from center field they were hidden behind the pitcher’s mound. I recrossed the field and adjusted them, and went back. I still couldn’t see the shoes; they were too small and hidden in the grass. I could see my backpack, though, so I sited off that. But it still didn’t really work. I didn’t have a protractor on hand, so I had printed out the image of one from Wikipedia and stapled it to a piece of cardboard, but the cardboard wasn’t very flat, making siting along it to good accuracy essentially impossible.

I scrapped that, and after a few days went to Walgreens and found a cheap plastic protractor and some twine that I used to tie in my water bottle as a plumb bob. Returning to the field, I finally found the device to be, well, marginal. Holding it up to my eye, it was impossible to focus along the entire top of the protractor at once, and difficult to establish unambiguous criteria for when the protractor was accurately aimed. I was also holding the entire thing up with my hands, and trying to keep the string in place between siting along the protractor and moving my head around to get the reading.

Nonetheless, my reading came to 87 degrees from center field to home plate and 90 degrees from home plate back to center field. This three-degree difference seemed pretty good confirmation of the GPS data. In a final attempt to confirm my readings, I repeated the experiment in a hallway outside my office, which I hope is essentially flat. It’s 90 strides long, (and I’m about two strides tall) and I found 88 degrees from each side, roughly confirming that the protractor readings matched my expectations. (I’d have used the swimming pool, which I know is flat, but it’s closed at the moment.)

I’m now strongly confident that the baseball field is sloped – something around 95% after considering all the points in this post. That’s enough that I don’t care to keep investigating further with better devices, unless maybe someone I know turns out to have one sitting around.

Still, there is some doubt. Couldn’t I have subconsciously adjusted my protractor to find what I expected? There were plenty of ways to mess it up. What if I had found no slope with the protractor? Would I have accepted it as settling the issue, or would I have been more likely to doubt my readings? It’s perfectly rational to doubt an instrument more when it gives results you don’t expect – you certainly shouldn’t trust a thermometer that says your temperature is 130 degrees – but it still feels intuitively a bit wrong to say the protractor is more likely to be a good tool when it confirms what I already suspected.

The story of how belief is supposed to work is that for each bit of evidence, you consider its likelihood under all the various hypotheses, then multiplying these likelihoods, you find your final result, and it tells you exactly how confident you should be. If I can estimate how likely it is for Google Maps and my GPS to corroborate each other given that they are wrong, and how likely it is given that they are right, and then answer the same question for every other bit of evidence available to me, I don’t need to estimate my final beliefs – I calculate them. But even in this simple testbed of the matter of a sloped baseball field, I could feel my biases coming to bear on what evidence I considered, and how strong and relevant that evidence seemed to me.  The more I believed the baseball field was sloped, the more relevant (higher likelihood ratio) it seemed that there was that short steep hill on the side, and the less relevant that my intuition claimed the field was flat. The field even began looking more sloped to me as time went on, and I sometimes thought I could feel the slope as I ran, even though I never had before.

That’s what I was interested in here. I wanted to know more about the way my feelings and beliefs interacted with the evidence and with my methods of collecting it. It is common knowledge that people are likely to find what they’re looking for whatever the facts, but what does it feel like when you’re in the middle of doing this, and can recognizing that feeling lead you to stop?

Things I Should Not Eat

November 9, 2012

According to various sources, the following will make me get fat, die of cancer, have bad brain functioning, smell bad, or otherwise turn me into a semi-perambulatory excrement pile

1. Tomatoes
2. Sugar
3. Fake sugar
4. High Fructose Corn Syrup
5. CAFO-meat
6. any red meat
7. any meat
8. any animal product
9. refined grains
10. any wheat
11. any grain
12. potatoes
13. sweet potatoes
14. corn
15. french fries
16. potato chips
17. anything my ancestors didn’t eat for a million years
18. anything cooked
19. anything that tastes good
20. anything with a health warning
21. anything with a health claim
22. anything domesticated
23. farmed salmon
24. farmed fish
25. wild fish with too much mercury
26. milk
27. any dairy
28. spicy food
29. non-spicy food
30. things with the wrong glycemic index
31. things consumed at the wrong time of day
32. things consumed in the wrong combination
33. carbohydrates
34. cholesterol
35. saturated fats
36. unsaturated fats
37. protein
38. soy
39. bottled water
40. unbottled water
41. anything with caffeine
42. any non-water drink
43. fruit
44. beans
45. anything remotely like a bean in a taxological sense
46. pizza
47. anything fried
48. anything that comes in a box or wrapper
49. anything marked as “light”
50. almonds
51. peanuts
52. any dietary supplements
53. turkey
54. anything cooked by someone else
55. anything made in another county
56. anything in a can
58. pasta
59. canola oil
60. candy
61. ice cream
62. peanut butter
63. anything from America
64. anything not from Okinawa or a secluded Himalayan valley
65. anything I didn’t kill myself
66. anything with sodium
67. anything without potassium
68. diet food
69. workout food
70. things that are not diet food or workout food
71. anything domesticated
72. white rice
73. brown rice
74. food that isn’t organic
75. food that isn’t raw
76. food that is raw or organic
77. margarine
78. anything synthesized
79. anything with a face
80. fugu
81. shellfish
82. monkey brains
83. herbs
84. lasagna
85. anything too acidic
86. bananas
87. eggplant with cucumber
88. chocolate
89. anything that didn’t get to run free when alive
90. anything not from the farmer’s market
92. anything genetically-modified
93. anything that doesn’t rot
94. anything advertised on television
95. anything with long-named ingredients
96. anything with more than five ingredients
97. things I eat too quickly
98. things I eat without appreciating
99. things I eat alone
100. anything my grandmother wouldn’t recognize as food

Essentially, in order to avoid a self-inflicted existence of crippling non-optimality, I can eat only Brazil nuts and wild truffles that I collect myself.

Transitive Evidence

July 31, 2012

A snippet from a conversation, paraphrased:

A: I’m worried about my posture. People will think I’m not attractive because I slouch.

B: Don’t worry, you can improve your posture because you’re intelligent.

A: What? How does that follow?

B: I notice that rich people tend to be able to improve their posture. Meanwhile, it is usually easy for intelligent people to become rich. Therefore, intelligent people can usually improve their posture.

Regardless of the somewhat-questionable factualness of these assertions, is the statement logically sound? If A is evidence for B and B is evidence for C, is A evidence for C? Mathematically, it is quite easy to see this is not the case. Check out this probability distribution, for example:   A few moments of staring will show you that it’s a counterexample (A is evidence for B, B is evidence for C, but A is not evidence for C). Good thing, too! Imagine if it were true:

• Being a Native Hawaiian is evidence for being in Hawaii. Being in Hawaii is evidence for being a tourist. Therefore, being a Native Hawaiian is evidence for being a tourist.
• If an object is an insect, that’s evidence that it can fly. If an object can fly, that’s evidence that it’s an airplane. Therefore, being an insect is evidence that an object is an airplane.
• Having sex is evidence that you are breathing hard. Breathing hard is evidence that you’re jogging. Therefore, having sex is evidence that you’re jogging.
• If it’s raining, that’s evidence that there are umbrellas around. If there are umbrellas around, that’s evidence that you’re in an umbrella factory. Therefore, rain is evidence that you’re in an umbrella factory.

Dropping a Slinky (calculation)

July 30, 2012

Let’s do a quick bit of math related to Dropping a Slinky. Last time, I estimated that it takes about 0.3 seconds for the slinky to collapse. To get a more precise answer, note that however the slinky falls, its center of mass must accelerate downwards at gravitational acceleration.

Where is the slinky’s center of mass? When it’s just hanging, the slinky is in equilibrium, so the derivative of the tension is proportional to the density. Also, if we assume an ideal spring with zero rest length, the tension is inversely proportional to the density (why?). Therefore, we write

$\frac{\mathrm{d}T}{\mathrm{d}x} = g \rho$

$T = \frac{\alpha}{\rho}$

This can be solved to show that the density follows

$\rho \propto \frac{1}{\sqrt{x}}$

Integrating, we find that the center of mass is one third the way up the slinky. The time for the slinky to collapse is the same as the time for the center of mass to fall to the bottom, or

$t = \sqrt{\frac{2 (1/3 l)}{g}}$

This is the same answer, but modified by a factor of 0.81. Notice that this only depends on the “slinkiness” – the zero rest length ideal spring. We expect thick and thin slinkies of different stiffnesses to act in essentially the same way.

July 30, 2012

A short video of what it looks like to drop a slinky. It’s surprising and elegant.

So what’s the speed that waves propagate in a slinky? A slinky is a bit tricky, because as you pull on it, it stretches out so that the density goes down. Meanwhile, the tension goes up. Both these effects increase the speed of wave propagation, so waves travel much more quickly at the top of a hanging slinky than at the bottom.

Since the only material properties around are the linear density $\lambda$ and the tension $T$, we must put these together to get a velocity, which we do by

$v = \sqrt{\frac{T}{\lambda}}$

As the slinky hangs, it should be in equilibrium, so the gradient of the tension at any point is equal to gravity times the density there. This yields the result that the tension is a square root of how far up you go from the bottom of the spring. As a rough estimate, though, the tension should on average be about half the spring’s weight, while the density on average is the spring’s weight divided by its length. Thus

$v = \sqrt{\frac{weight}{mass/length}} = \sqrt{g l}$

where $g$ is gravitational acceleration and $l$ is the slinky’s length. The characteristic time of such a slinky is

$t = \frac{l}{v} = \sqrt{\frac{l}{g}}$

For a one meter slinky we get a time of .3 seconds (and a speed of only a few meters per second), meaning it’s an effect we can see quite well even without high-speed photography!

The same basic mechanism is there in dropping anything else, but typical sound speeds are on the order of thousands of meters per second, so usually it’s much too fast.

Unwinding: Physics of a spool of string

June 1, 2012

It’s been a long day. Let’s unwind with a physics problem.

This problem was on the pre-entrance exam I took before arriving at Caltech for my freshman year. I’ve seen it from time to time since, and here I hope to find an intuitive solution.

You have a spool of thread, already partially unwound. You pull on the thread. What happens?

Here it is in side view. The dashed circle is the inside of the spool and the green line is the thread. Take a minute to see if you can tell how it works. Does the spool go right or left?

The usual method is to work it out with torques. The forces you must account for are the force of tension from the string and the force of friction from the table.

Torques are actually a pretty easy way to solve this problem, especially if you calculate the torque around the point of contact between the spool and the table (since in that case friction has no moment arm and exerts no torque).

This method is direct, but it’s useful to find another viewpoint if you can.

Let’s first examine a different case where the string is pulled up rather than sideways.

In this case, even if the first situation was unclear, you probably know that the spool will roll off to the left. To see why, let’s imagine that the thread isn’t being pulled by your hand, but by a weight connected to a pulley.

I put a red dot on the string to help visualize its motion.

The physics idea is simply that the weight must fall, so the red dot must come closer to the pulley. Which way can the spool roll so the red dot moves upward?

When the spool rolls (we assume without slipping), the point at the very bottom, where it touches the table, is stationary. The spool’s motion can be described, at least instantaneously, as rotation around that contact point.

Googling, I found a nice description of this by Sunil Kumar Singh at Connexions. This image summarizes the point:

If the spool rolls to the right, as above, the point where the string leaves the spool (near point B), will have a somewhat downward motion. This will pull the red dot down and raise the weight. That’s the opposite of what we want, so what really happens is that the spool rolls to the left, the string rises, and the weight falls.

With this scenario wrapped-up (or unwrapped, I suppose), let’s return to the horizontal string segment.

Again, the weight must fall and so the red dot must go towards the pulley.

If we check out Mr. Singh’s graphic, we’re now concerned with the motion of a point somewhere near the bottom-middle, between points A and C. As the spool rolls to the right, this point also moves to the right. This is indeed what happens as the weight falls.

Notice that the red point actually moves more slowly than the spool as a whole. This means the spool catches up to the string as we move along – the spool winds itself up. If the inside of the spool is 3/4 as large as the outside (like it is in my picture), the spool rolls 4 times as fast the string moves, and so for every centimeter the weight falls, the spool rolls four centimeters.

Here’s a short video demonstration: