Kill Time At Work With Recreational Math: Caffeine Half-LifesteemCreated with Sketch.


Pixabay.com link CC0 license

This is the 7th in my series of killing time at work using math (the others are listed at the bottom of this post).

If you have read my posts before you already know that there are a few prerequisites for this:

  • You like recreational math.
  • You work at a computer and have access to Microsoft Excel.
  • You are bored out of your tree.
  • You don't want to get caught slacking off.

Let's get started.


Caffeine is the world's most popular psychoactive drug and it is my drug of choice. In fact, when I was in University I was quite the coffee fiend drinking at least 6-8 cups a day, even well into the evening. I believe that without caffeine there would be no mathematics.

Caffeine is a drug that you metabolize and eliminate and this means that you can describe its reduction fairly well via the half-life mathematical method.

The half-life for the typical person is somewhere between 4 to 6 hours. I had my DNA analyzed by 23andMe and then re-assessed using the Promethease DNA genotype system and I learned that I was a fast caffeine metabolizer (i.e. a half-life of ~3 hours):

rs762551(A;A) Fast Caffeine Metabolizer. Unlike the majority of people, caffeine is broken down faster in your liver, so it has less effect on you. Supposedly this decreases heart attack risk, although other studies show caffeine is generally good for the heart.

This no doubt explains why I was able to consume vast amounts of coffee while being little affected.

So on to the post. Here we are going to simulate the caffeine concentration in your bloodstream as a function of time through the day.

The Half-Life Coefficient

In the image above we determine the half-life coefficient for a typical person who eliminates half of the caffeine in their body in 6 hours (50% left). In the following 6 hours they eliminate half of the remaining amount (25% left). In the 6 hours following that they eliminate half of the remaining amount (12.5% left). And so on and so forth.

Here we just start with an arbitrary amount in cell B3. I set it to 1 to make the math easier to understand.

Then in column A we set up a small series from time 0 to time 6 hours.

In column B we set up the calculation. Each hour we multiply the previous value by some fraction to be determined soon. By the definition of half-life we know that at time t = 6 hours it must be equal to one-half (i.e. 0.5).

The half-life coefficient is in cell B1. To start just put any number in that cell between 0 and 1.

Now let's go to the Excel solver (called goal seek) as shown below:

Set the target cell to B9 (first field in the dialogue below). We want it to be equal to 0.5 so set the second field to be equal to 0.5. The cell we want Excel to change is B1 so just select cell B1 and press OK.

Excel will find the value of B1 that will make the value in B9 equal to 0.5. This saves you a lot of tedious trial and error and is a very handy feature in Excel.

Here is a graph of the result of using this coefficient. We see that at 6 hours the concentration (y-axis) drops to 0.5. In a further 6 hours (t = 12 hours) the concentration drops to 0.25 as expected. Looking at the graph you also notice that the coffee elimination is fast at first and then it becomes slower and slower. This is one good reason why you don't want to drink coffee after the lunch hour.

Aside: Why Not Just Use The Half-Life Formula?

There is an explicit formula that you can use to determine the half-life coefficient and it can be found here. I typically do not use formulas like this because in real life situations it is rare to find such a clean and simple relationship. Usually they are more complicated so rather than spend a lot of time working out an exact solution it is often more prudent to just use a solver.

Simulate Your Daily Caffeine Habit

Now we want to set up a simulation of your daily caffeine habit. Let's start with a coffee drinker who ingests 6 hours of coffee per day.

The caffeine content in a typical brewed coffee ranges between 80 to 135 mg in a 7 ounce cup of coffee. For our simulation let's just assume an even 100 mg per cup of coffee.

The figure above shows the spreadsheet that I set up.

Column A is just the hour counter and is useful for graphing the results.

Column B is the hour in the day. Let's start the day at 8 am and increment it by 1 in each cell. When the value in the cell hits 25, just reset it back to 1 for 1 am.

Column C is the column in which we simulate the addition and the elimination of caffeine in the body. The formula just multiplies the value in the cell above it by the half-life coefficient (cell C$1). Notice the $ sign which makes it in absolute reference so when you copy that formula down the column, the value "C$1" will not be altered. The formula also checks the value in the cell beside it in Column D and adds it to the amount in your body (if it is an hour when you are not drinking coffee that value is zero, otherwise it is 100).

Column D is the coffee consumption column. We insert 100 in a cell in which our person drinks a coffee. In this case a coffee is consumed at 9 am, 11 am, 1 pm, 3 pm, 6 pm and at 9 pm. Quite the coffee addict.

Cell C1 contains the half-life coefficient that we calculated earlier. This particular coefficient simulates a person who has a 6 hour caffeine half-life.

The Results

Looking at the graph above we see the caffeine concentration in our subject's body as a function of time. On the x-axis the value of 24, 48, 72, 96 and so on represents midnight of each day.

We can see the caffeine concentration spikes up for the first coffee of the day and drops as it is metabolized. It then spikes up again and drops down again. The process is repeated through the day.

It takes a few days for the concentration to reach some repeated equilibrium pattern.

Sleeping at Night

So what is the concentration for this person when they try to go to bed at midnight? Looking at the results for the last day we find that somewhere around 240 mg of caffeine still remains in the body. That's about 2.5 cups of coffee still circulating through the blood system.

No wonder coffee fiends have trouble sleeping. In fact, even when this person wakes up they still have something like a cup of coffee still in their system.

A Reduced Coffee Habit

Let's reduce the subject's coffee habit to 2 cups a day, one a 9 am and one at noon. Let's see what we get.

The results look much better. I left the y-axis at the same range as in the previous graph to make the comparison between the two cases easier.

We see that the build-up over the days is less severe and also that the amount of caffeine in the body at midnight is also much reduced and is now at much more reasonable 45 mg. When this person wakes up in the morning there is only about 20 mg of caffeine in their system.

Closing Words

If you are a fast caffeine metabolizer like me then set your half-life to 3 hours and calculate the half-life coefficient.

If you are a slow caffeine metabolizer then set your half-life to 9 hours and calculate the half-life coefficient. You will also want to be careful about when your last coffee or tea is in the day if you are one of these people.

Drinking tea is usually a good way to get less caffeine into your system as a cup of tea may contain about half the amount as a cup of coffee. To simulate a cup of tea, replace the 100 in Column D with 50 and see what happens.

Thank you for reading my post.

Other Posts In My Recreational Math Series

  1. Testing the excel random function.
  2. Make Your Own Bell Curve
  3. Strange Attractors.
  4. Let's Travel To Alpha Centauri
  5. Calculate Sunset and Sunrise Times
  6. Conway's Game of Life.

Post Sources

https://www.caffeineinformer.com/caffeine-metabolism
https://www.23andme.com/
https://promethease.com/
https://en.wikipedia.org/wiki/Half-life
https://en.wikipedia.org/wiki/Coffee
https://en.wikipedia.org/wiki/Tea#Chemical_composition

Sort:  

I am scared to try this o.O I love my 5 o'clock coffee...

Me too but it is too late for me I already know the results.

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 62912.13
ETH 2544.21
USDT 1.00
SBD 2.84