May 30, 2008
Bedtime Conversation

Last night I went downstairs to turn off the lights and check the doors and windows, and as usual got caught up in my computer. After about five minutes my wife called down to me, and I came up. This is the conversation we had, more or less:

Wife: What were you doing? It sounded like you were on the computer.

Me: Yeah. I was looking at porn.

W: [incredulous look]

Me: You can go down and look, I left it up.

W: You were reading Eugene Volokh?

Me: No, I was checking out some hot graph-on-graph action.

W: Oh, you were reading xkcd.

We both laugh.

Actually I was reading this algorithm for finding strongly connected components in parallel.

Posted by Sam at 01:27 PM
May 26, 2008
Inventions We'd Like To See

Driving down highway 5 today, I realized that a GPS isn't the be-all, end-all of driving bliss. Even when you have a database of stores, schools, shops, etc.

What you really want is a feature that will tell you "Turn on recirc. Five miles to Coalinga feedlot."

Posted by Sam at 12:42 AM
May 18, 2008
Why there is no Litmus Paper for Caffeine (III) - Non-Destructive Assessment of the Caffeine Content of Coffee

Third in an occasional series. Links to the first entry, category archive.

Last time I described how we could find the caffeine content of a cup of coffee using standard lab techniques. Unfortunately, this destroyed the cup of coffee we were testing. So now let's see how we would do the same thing non-destructively.

The destructive procedure is a standard introductory organic chemistry lab. The non-destructive procedure, even though in addition to being non-destructive it is faster, easier, and more accurate, is to my knowledge not used instructionally, with maybe one or two exceptions. I would bet that any professional analytical laboratory -- especially if they have to frequently assess caffeine content -- would do it this way, though.

First, prepare deuterated caffeine. This can be done readily with a deuterating agent such as CD3I, tri-deuterio-iodomethane, in an SN2 reaction using theophylline as the nucleophile. (Theophylline is a close relative of caffeine, differing in that it lacks a methyl group. Theophylline is readily isolated from tea, and is available from chemical supply houses).

Having prepared and purified your caffeine-d3 (this is more work than it sounds like!), dissolve a carefully measured amount in some handy solvent (e.g., ethanol) and store it.

When you want to determine the caffeine content of a cup of coffee, take your caffeine-d3 solution and add a known amount -- ideally, a known mass, but a known volume will be good enough if you avoid solvents like methanol that vary wildly in density. This is called "spiking" the sample, and it is the key step in making this analysis faster, more accurate, etc. So it's worth a lot at this point to know how much caffeine-d3 you added, to four decimal places or so.

Now mix the sample thoroughly and remove three 5-mL aliquots. (Chemists love to say "aliquot".) Treat each of the aliquots separately as in the previous procedure: use base, filter, and neutralize, then extract with small portions (1 mL each) of methylene chloride. But now comes the good part: no recrystallizations! Instead take your methylene chloride and inject it into a GC/MS (gas chromatograph / mass spectrometer).

This is why spiking with caffeine-d3 is so clever. Once the spiked product is thoroughly mixed into the sample, it will behave for almost all purposes identically to the normal caffeine in the sample. It will be extracted -- and lost -- in equal proportions, so that the ratio of caffeine to caffeine-d3 will remain constant.

But the one way in which the compounds differ is in their mass. So we program our mass spectrometer to monitor the range of 193-198 (caffeine- 194; caffeine-d3- 197 ). The relative area of the two peaks will give you the relative proportion of caffeine to caffeine-d3 in the spiked sample. (There's also a calibration factor, but I'm handwaving that away.) With the proportion and the known amount of spike solution that was added, we can easily get the mass of caffeine in the original sample, and then (knowing the volume) the concentration.

But we don't need the concentration, because again, as long as there is less than 3 mg caffeine, it's decaf. If there's more than that, it's caffeinated.

So: if you have the resources of a medium-sized analytical lab (GC/MS, make your own labeled reagents), you can easily determine the caffeine content without destroying the cup of coffee.

Next time: But what about litmus paper?

Posted by Sam at 08:21 AM
May 07, 2008
Anti-Resume

The other day I was talking about resumes with a friend (apparently two pages is the norm now, is that shocking or what! Shows you how long it's been since I had to put one together) and we came up with the concept of the anti-resume.

Not the anti-resume as presented in trendy business book The Black Swan:


People don't walk around with anti-resumes telling you what they have not studied or experienced (it's the job of their competitors to do that), but it would be nice if they did.

No, our version of an anti-resume is a list of all the true and unpleasant things about yourself you would normally attempt to conceal or mitigate while on a job interview. Something more like the examples here. You know: I'm arrogant, I don't work well with others, I only want this job for the money and I don't care about the product/professional development/customer, I like to play office politics and backstab.

I think I may write it all up as a formal document. Could be fun!

Posted by Sam at 10:29 AM
May 04, 2008
Why there is no Litmus Paper for Caffeine (II) - Assessing the Caffeine Content of Coffee

Second in an occasional series. Links to the first entry, category archive.

OK. So suppose you're in the situation of having been served a cup of coffee, and wanting to determine whether it is decaffeinated (as you ordered) or regular. You have a cup (4-6 oz) or a mug (about 8 oz) of steaming hot liquid in front of you. It contains a variety of different chemicals leached out of the crushed roasted seeds from the fruit of Coffea arabica or if you're not so lucky, Coffea robusta. There are flavorful oils, and a number of water-soluble compounds including caffeine and its close relatives theophylline and (to a much smaller extent in coffee) theobromine.

Fortunately you have the complete resources of a chemical lab available to you. So you take your cup of coffee into the lab, weigh it in a tared flask, measure its volume, and proceed to the caffeine extraction procedure.

First you add concentrated sodium hydroxide solution to basify the solution and precipitate out some junk. (Typically tannins, but why be technical?) Sodium hydroxide is household lye, by the way. I hope you weren't planning on drinking this coffee. In fact, once you brought it into the lab, it became undrinkable by the standards of good lab practice.

We'll filter off the gummy precipitate and buffer the solution back to neutral. Now we extract the caffeine into a non-polar solvent. Let's use methylene chloride, also known as "dry cleaning chemical". Yum yum yum! It has a lovely heavy sweet scent and is only a little carcinogenic. Use a hood to avoid sniffing too much of the vapors.

We extract with three 50-mL aliquots of methylene chloride. (I don't know why, but somehow all chemists love to say "aliquot"). This process involves putting the water and MeCl2 in a separatory funnel and shaking to improve surface area contact between the two immiscible liquids. Always remember to periodically vent the funnel, since mixing liquids can cause them to significantly expand in volume, and the overpressure can break your funnel. Not only do you lose your product, you wind up wearing the methylene chloride.

Next we get the crude yield by evaporating off the methylene chloride. Put your solution in a round-bottom flask, attach it to the rotary evaporator, get a nice cold dry ice trap and put it in line between the aspirator and the rotovap. (If we didn't have a nice cold trap, we'd be sending methylene chloride down the drain, which is not the approved way to dispose of chlorinated organic solvents.) Place a warm water bath or gentle steam bath under the round-bottom flask, and let 'er rip. Low-boiling methylene chloride will evaporate on heating, and recondense in the trap, leaving behind any solids dissolved in it. Including our caffeine. And anything else that liked non-polar solvents more than water. Weigh and record crude yield.

So now -- last step -- recrystallize your caffeine to remove the other solids. Add your crude product to a clean Erlenmeyer flask. In a hood, heat acetone over a steam bath to just below boiling and add dropwise until the crude product dissolves. Plan on doing a hot filtration to remove impurities that were soluble in MeCl2 but not acetone. Slowly allow the acetone to cool to room temperature, then place in a salted ice bath. Collect the crystals and dry on a watch glass in a drying chamber. Collect any crystals from filter paper, rotovap off the acetone, and assess whether another recrystallization is useful. Weigh and record yield, and after drying, dry yield.

Caffeinated coffee contains between 100 mg - 200 mg caffeine per cup, and decaf contains about 3 mg per cup. So if the amount of caffeine you recovered was over, say, 30 mg, it's safe to assume that the coffee was caffeinated. If the amount was less than 3 mg or nonexistent (as long as you didn't screw up the procedure), it's safe to assume the coffee was decaffeinated. In that case, it's safe to go back to the restaurant and ... order a new cup of coffee. Which we again won't know whether it's caffeinated or not.

Next time: nondestructive lab-based testing.

This procedure is based on my memory of the procedure outlined in Pavia, Lampman, and Kriz.

Posted by Sam at 11:42 AM
Crib Notes for the Turing Test

Crib notes for the Turing test. Personal favorite: "3. Constipation's gone!"

(I don't even what to think what sort of Google hits I am now going to get.)

Posted by Sam at 03:38 AM
Why there is no Litmus Paper for Caffeine (I) - Introduction

I used to have a web page with some pictures of caffeine I had optimized and ray-traced, some caffeine information, links to the MSDS for caffeine, that sort of thing. This was in 1995 or so, before blogs existed and when people still wrote web pages in vi. (Mine was cool because I wrote it in emacs.)

I used to get one or two emails a year from people who had come up with A GREAT IDEA! And if only I could help them put it into practice, theywe could make LOTS OF MONEY! It would be these little strips of paper, you see, small enough to keep a container in your purse or pocket, and then when you ordered decaf coffee in a restaurant, you could test it by dipping the strip into the coffee and if it turned color (say, blue) then DA DA DUM you would know that the waiter had messed up your order and brought you regular caffeinated coffee instead. Thus saving you from the harm of drinking the real, unleaded stuff. And presumably giving you a reason to yell at the waiter/manager.

I hope it's clear that I have always considered this to be a stupid business idea. But what I tried to do -- first in email, and then by adding another web page -- was explain WHY this is technically infeasible. I never finished it. Perhaps I will finish it now, in serial form. (Don't hold your breath).

Posted by Sam at 03:35 AM
Just another attempt

Just another attempt to sell that despicable man, John McCain on the basis of his alleged conservatism. Jonathan Rauch claims that McCain is more Catholic than the pope, or rather, contra Gingrich and Reagan, a true adherent to the conservative ideals of Edmund Burke.

For homework: please explain how his promotion of unconstitutional speech restrictions can be reconciled with his newly discovered Burkean roots. Extra credit: square the circle.

Hillary in '08. The devil you know, etc. etc.

Posted by Sam at 03:22 AM