A great explanation of the comic can be found at https://www.explainxkcd.com/wiki/index.php/2319:_Large_Number_Formats.

# Category: Computer science

# Mathematics that Swings: The Math Behind Golf

From the YouTube description:

Mathematics is everywhere, and the golf course is no exception. Many aspects of the game of golf can be illuminated or improved through mathematical modeling and analysis. We will discuss a few examples, employing mathematics ranging from simple high school algebra to computational techniques at the frontiers of contemporary research.

# 999 Megabytes

This made me laugh…

…though I would have laughed harder if the band was called 1023 Megabytes.

# Wason Selection Task: Part 3

I recently read about a simple but clever logic puzzle, known as the “Wason selection task,” which is often claimed to be “the single most investigated experimental paradigm in the psychology of reasoning.” More than 90% of Wason’s subjects got the answer wrong when Wason first studied this problem back in the 1960s, and this result has been repeated time over time by psychologists ever since.

Here’s the puzzle: You are shown four different cards, showing a 5, an 8, a blue card, and a green card. You are told that each card has a number on one side and a color on the other side. You are asked to test the truth of the following statement:

If a card has an even number on one side, then its opposite side is blue.

Question: Which card (or cards) must you turn over to test the truth of this statement?

Interestingly, in the 1980s, a pair of psychologists slightly reworded the Wason selection puzzle in a form that’s logically equivalent, but this rewording caused a much higher rate of correct responses. Here was the rewording:

On this task imagine you are a police officer on duty. It is your job to make sure that people conform to certain rules. The cards in front of you have information about four people sitting at a table. On one side of the card is a person’s age and on the other side of the card is what the person is drinking. Here is a rule: “If a person is drinking beer, then the person must be over 19 years of age.” Select the card or cards that you definitely must turn over to determine whether or not the people are violating the rule.

Four cards are presented:

- Drinking a beer
- Drinking a Coke
- 16 years of age
- 22 years of age

In this experiment, 29 out of 40 respondents answered correctly. However, when presented with the same task using more abstract language, none of the 40 respondents answered correctly… even though the two puzzles are logically equivalent. Quoting from the above article:

Seventy-five percent of subjects nailed the puzzle when it was presented in this way—revealing what researchers now call a “content effect.” How you dress up the task, in other words, determines its difficulty, despite the fact that it involves the same basic challenge: to see if a rule—

if P then Q—has been violated. But why should words matter when it’s the same logical structure that’s always underlying them?

This little study has harrowing implications for those of us that teach mathematical proofs and propositional logic. It’s very easy for people to get some logic questions correct but other logic questions incorrect, even if the puzzles look identical to the mathematician/logician who is posing the questions. Pedagogically, this means that it’s a good idea to use familiar contexts (like rules for underage drinking) to introduce propositional logic. But this comes with a warning, since students who answer questions arising from a familiar context correctly may not really understand propositional logic at all when the question is posed more abstract (like in a mathematical proof).

# Wason Selection Task: Part 2

I recently read about a simple but clever logic puzzle, known as the “Wason selection task,” which is often claimed to be “the single most investigated experimental paradigm in the psychology of reasoning.”

Here’s the puzzle: You are shown four different cards, showing a 5, an 8, a blue card, and a green card. You are told that each card has a number on one side and a color on the other side. You are asked to test the truth of the following statement:

If a card has an even number on one side, then its opposite side is blue.

Question: Which card (or cards) must you turn over to test the truth of this statement?

The answer is: You must turn over the 8 card and the green card. The following video explains why:

Briefly:

- Clearly, you must turn over the 8 card. If the opposite side is not blue, then the proposition is false.
- Clearly, the 5 card is not helpful. The statement only tells us something if the card shows an even number.
- More subtly, the blue card is not helpful either. The statement claim is “If even, then blue,” not “If blue, then even.” This is the converse of the statement, and converses are not necessarily equivalent to the original statement.
- Finally, the contrapositive of “If even, then blue” is “If not blue, then not even.” Therefore, any card that is not blue (like the green one) should be turned over.

If you got this wrong, you’re in good company. More than 90% of Wason’s subjects got the answer wrong when Wason first studied this problem back in the 1960s, and this result has been repeated time over time by psychologists ever since.

Speaking for myself, I must admit that I blew it too when I first came across this problem. In the haze of the early morning when I first read this article, I erroneously thought that the 8 card and the blue card had to be turned.

# Wason Selection Task: Part 1

I recently read about a simple but clever logic puzzle, known as the “Wason selection task,” which is often claimed to be “the single most investigated experimental paradigm in the psychology of reasoning,” in the words of one textbook author.

Here’s the puzzle: You are shown four different cards, showing a 5, an 8, a blue card, and a green card. You are asked to test the truth of the following statement:

If a card has an even number on one side, then its opposite side is blue.

Question: Which card (or cards) must you turn over to test the truth of this statement?

I’ll start discussing the answer to this puzzle in tomorrow’s post. If you’re impatient, you can click through the interactive video above or else read the article where I first learned about this puzzle: http://m.nautil.us/blog/the-simple-logical-puzzle-that-shows-how-illogical-people-are (I got the opening sentence of this post from this article).

# Graph theory and plowing snow

Here in north Texas, we’re recovering from our third winter storm in two weeks, so I thought it’s timely to share this article about how mathematics can be used to efficiently plow the snow off the streets (apologies for the mild profanity):

http://www.wired.com/2015/02/mathematics-behind-getting-damned-snow-street/

# How signed integers are represented using 16 bits

Source: http://www.xkcd.com/571/

This probably requires a little explanation with the nuances of how integers are stored in computers. A 16-bit signed integer simulates binary digits with 16 digits, where the first digit represents either positive () or negative (). Because this first digit represents positive or negative, the counting system is a little different than regular counting in binary.

For starters,

represents

represents

represents

represents

For the next number, , there’s a catch. The first means that this should represent a negative number. However, there’s no need for this to stand for , since we already have a representation for . So, to prevent representing the same number twice, we’ll say that this number represents , and we’ll follow this rule for all representations starting with . So

represents

represents

represents

represents

Because of this nuance, the following C computer program will result in the unexpected answer of (symbolized by the sheep going backwards in the comic strip).

main()

{

short x = 32767;

printf(“%d \n”, x + 1);

}

For more details, see http://en.wikipedia.org/wiki/Integer_%28computer_science%29

# Tic tac toe

Source: http://www.xkcd.com/832_large/

# Sorting and interpretative dance

Algorithms for sorting a list, like Bubble Sort, Quick Sort, etc., often require some sort of visual interpretation to make dry algorithms more accessible to students. Here are some YouTube videos that brilliant do this via the medium of folk dancing.

Quick Sort

Merge Sort

Insert Sort

Select Sort

Shell Sort

Bubble Sort