Thursday, June 30, 2005

The Scarlet Algorithm

In writing a short-story comedy about people sticking messages in library books and the like, I created a book about an algorithm or procedure for finding out who your best romantic partner is. I called this fictional book "The Scarlet Algorithm". The idea is that such an algorithm would help people find conjugal partners. This idea is something that has been around a long time. In 1966, my college was introduced to something called Operation Match. The idea is that people going to a certain dance would fill out a questionnaire about themselves and who they want as a partner, and the computer would find for each such person a list of persons of the opposite sex that are the most compatible with them. This did not always turn out right, partly because people put down on paper who they think they want rather than who they want. Nowadays this practice continues in the plethora of dating services on the Internet. To me this is not the best way to meet someone. The best way is through joining clubs or organizations that represent your interests and finding people there.

But if one were going to organize an Operation Match dance, what would be the algorithm? Probably some variant of the Hungarian algorithm, which matches elements of one set with elements of the other to optimize total worth, or of the Gale-Shapley algorithm, which eliminates the chance that "affairs" will form; i.e., two people who prefer each other to the people that they have been assigned to. Recently I used the Hungarian method to pair major league baseball teams with their AAA affiliates, and found that major league baseball could cut major-league-team-AAA-affiliate costs by 40%.

Other mathematical schemes describe love itself. John Alan Lee describes something called the "Colors of Love", in which he describes love as a two-dimensional continuum, specifically the triangle described by x + y + z = 1, with x, y, z >= 0. The three variables in this are "primary colors", which Mr. Lee describes as eros, ludus, and storge. He then describes three secondary colors, with mania between eros and ludus, pragma between ludus and storge, and agape between eros and storge. He then describes tertiary colors, but only for combinations involving mania, including manic storge, which would be a mix of a secondary color with its opposite complement. I therefore conclude that Mr. Lee is really dealing with a four-dimensional model, with four primary colors of eros, ludus, storge, and mania, however, it is hard to picture colors in four dimensions.

Then there are rating schemes. One is the familiar "10" or "perfect 10". This envisions that a man, for example, will rate women on a scale from 1-10, and that what he really wants is a perfect 10. There is even a movie with the name "10", which describes such a desirable woman. First of all, it should be a scale of 0-10. This is the most natural way of rating a scale on two extremes, with 0 at one end and 1 at the other; just multiply this scale by 10.

But another problem is that one will find that there are too many 10s out there. The scale suggests that each number from 0 to 10 will have the same number of people in them; since we meet hundreds of people there will be tens of 10s out there. A better idea is to use a logarithmic scale; see Logarithms Keep Dr. Brown in Perspective". In this scale, a 1 is one out of 10, and so is the counterpart of the "perfect 10". A 2 is one in a hundred, a 3 is one out of a thousand, out of 1,000 with 3 zeroes after the 1. A 6 would have six zeroes after the one, and would be one in a million.

So even though the two subjects of mathematics and romance don't seem to have much in common, there are ways of applying the mathematics to help out with finding a suitable partner. These ways I call "The Scarlet Algorithm".

Wednesday, June 22, 2005

Mathematical Baseball

This week I have been noticing that of all the team sports, especially those that are broadcast extensively, baseball is the most mathematical. It is a discrete game; that is, the game proceeds by innings, which are composed of outs, which are composed of trips to the plate, which are composed of discrete pitches. It is almost as though a pitch was an "atom" of baseball. Baseball games are composed into box scores, which total the number of items that occurred in the game by categories. For example, you will see the number of runs by each team, the number of hits by each player, the number of walks allowed by each pitcher, and so forth, and from these statistics can be developed, such as standings and batting averages. One can even simulate baseball based on what has happened in previous games.

One of my main interests is what can happen in baseball? What are the logical extremes? For example:

1. What is the fewest number of pitches in a game?

This one is a little tricky. Think about it a while and then come back to this blog.

Did you say 54 pitches? Each player bangs into an out on the very first pitch, 3 pitches a half inning, and so 3 x 2 x 9 = 54 pitches in a game? Almost, but not quite. If the home team is ahead, the bottom of the 9th will not be played, and that makes it 51 pitches. But that's not correct, either. If it were 51 pitches, every one would be an out, and the score would be tied, 0-0. One more pitch is needed somewhere to score a run for the home team, probably a solo home run. So the answer is 52.

2. What is the most number of pitches in a game?

The answer is infinity. This gets into a concept I have invented in games called entropy. In games, some moves are reversible; you can go back to the same situation again. Others are irreversible. In chess, for example, moving a knight to an open square is reversible; you can move him back again. But capturing a piece is irreversible, as the piece can never return, and moving a pawn is irreversible, as pawns can't move backward. And so it is with baseball. An out is irreversible; one can't undo the out and go back from 1 out to none, for instance. A hit, however, is reversible, since a team and hit and hit and hit over again and the situation will still remain the same, especially if the hits are home runs. Conceivably the team could score run after run after run as the New York Yankees did yesterday (against Tampa Bay on 2005 June 21) without ever getting the third out. So the game goes infinite. (Well actually, the Yankees stopped after 13 runs) There are four ways a game can go infinite:

a. Run infinite. A team scores run after run after run in an inning without the third out ever coming.

b. Inning infinite. The game goes into extra innings, one after another, for an infinite amount of time because the two teams score the same number of runs in each inning.

c. Foul ball infinite. A foul ball after two strikes (unless it is a tip or is bunted) does not count anything in baseball - it's reversible. So have a batter hit foul after foul after foul without ever causing an out or hitting and getting safe on first. There is even a book written about this idea, "The Boy who Batted 1.000".

d. Pickoff infinite. The pitcher over and over again attempts to pick off a runner with a throw to that base, and with the runner making it back on time each time. There may be a rule against this one, something about delay of game.

If one assumes that none of these infinites can occur, then a baseball game must end. However, the maximum number of pitches depends on the limits you place on innings, batter-friendly events, foul balls, and pickoff attempts.

3. Suppose a pitcher gets 7 strikeouts in a single inning. Show that a run must have scored.

This one is strange. How can a pitcher get more than 3 strikeouts? 3 outs ends the inning. The answer is that if the catcher can't catch the ball, and there are two outs or first base is open, then the batter who is struck out can run for first base, and if he beats the ball, he is safe at first. The pitcher still gets a strikeout. So 7 strikeouts means 7 people to the plate, and one can fit only 3 of these in outs and 3 on the bases, so at least one run must have scored.

4. How many hits must a team get before a team is certain of scoring a run?

You think it may be something like 10? 15? 22? Try 55. That's right. A team must get 55 or more hits in a game before it becomes certain that a run must have occurred. A team can get 54 hits, and furthermore, 27 of these can be triples, without scoring a single run. Here's how:

A. Hits triple and is out trying to score.
B. Hits triple and is out trying to score.
C. Hits triple.
D. Hits single; 3rd base coach holds runner at 3rd.
E. Hits single; 3rd base coach holds runner at 3rd.

Here is where the problem occurs. If the next runner is out, that ends the inning with only 5 hits. If the next runner hits, with the bases loaded, a run must score. It seems like we need a hit and an out simultaneously and how do we get that? Here's how:

F. Hits ball, batted ball hits a runner. F is credited with a single. The runner is automatically out.

And there it is, 6 hits and no runs. Repeat that over 9 innings and you get 54 hits, with 27 triples, and no runs. We can fire this third base coach.

5. Can a pitcher lose a no-hitter?

Yes he can. A pitcher must win a shutout, because you need runs to win a game. A pitcher must win a perfect game, for you must get on base before you can score. But a pitcher can very well lose a no-hitter. Hits are not necessary for a win. All you need is 3 errors, as happened on 1990 July 1 with a game between the New York Yankees and the Chicago White Sox. The Yankees had 4 hits but 0 runs, and the White Sox had 0 hits but 4 runs. The no-hit White Sox won the game by a substantial margin.

Wednesday, June 15, 2005

This starts my newest blog, one devoted to mathematics and science, but mostly to mathematics. I called it Hilbert's Hotel after the fabulous hotel that was constructed with an infinite amount of space that will hold a countable infinity of guests, and there is always room for one more, since if John Q. Onemoreguest should arrive, we just tell everybody to move out of their rooms and into the room with the next highest number; e.g., from 107 to 108. Then we can fit John in room 1.

Today I got a question to the math help website I belong to, Mathnerds, concerning cubic equations. These have fascinated me since I was small. There was a formula for quadratic equations, but how about cubics? The best way to understand these is to first of all convert the general cubic

ax3 + bx2 + cx + d = 0

into one of the form
x3 + px + q = 0

by dividing everything by a and then by applying the transform y = x - a/3 (and then of course x = y). Let w be an imaginary cube root of 1; i.e., w = -1/2 + sqrt(-3)/2. Compute this product:

(x - u - v)(x - wu - w2v)(x - w2u - wv)

You get:

x3 - 3uvx - (u3+v3)

which is exactly in the form of the reduced cubic equation. Then set

-3uv = p

p3 + q3 = -q

and solve by solving for v in the first equation, and plugging into the second, yielding a quadratic in p3. Solve this using the formula, and select a cube root of the result for u. Then solve for v in the first equation, and then the roots are

u + v
wu + w2v
w3u + wv

This is essentially the method of Lagrange resolvents, and the question in Mathnerds asked about those. Another interesting way of looking at it is through Dan Kalman's circulants.

There is also a discriminant D. If D is 0, the roots are probably rational and two of them are the same. If D > 0, then there is one real root and two imaginary ones, and one can actually come up with a formula for the real root, but it will be somewhat complex looking, being a sum of the cube roots of two quadratic expressions.

The really confusing case is the irreducible one, where D < 0, and my favorite equation here is x3 - 3x + 1 = 0. If you use the formula above, you get w1/3 + w2/3 for one of the roots. The thing is, this is real, yet it is expressed in imaginary quantities. I searched all over when I was young for a real solution, until I realized that there are none. There is no way of expressing the roots of this equation in real radicals. If you are willing to use trig functions, there is a way: 2cos(40 degrees) or 2 cos (2*π/9) is one of the roots, for instance.

Cubic equations were originally solved by the Italian mathematicians Tartaglia and Cardano, and Galois added a lot to the theory by associating with equations and field extensions a structure called a Galois group, which for most cubic equations is the group of permutations of three objects, known as S3. Most of the time when confronted with one, one uses Newton's method to approximate the real roots. But cubic equations solved algebraically have a fascination with me and they will continue to do so.