[Jodavaho.io]

Stuff by Josh Vander Hook

Dieting and Differential Equations: Part 0, Calories and Steady State Weight

In the first of a series, I discuss the math behind dieting, and how to use data to estimate your calorie needs and weight loss goals. view full post

OK, let’s talk about my diet.

After I stopped boxing, and biking to work, and in general doing anything, food became a problem. Snacking was constant, meals were added on when someone else made them, and treats were prevalent. Turns out, when you’re burning 2500 calories in roadwork every day, this isn’t a problem. No longer.

I’ve started a diet, with the goal of losing 32 lbs, or ~15% of my bodyweight, to get back to my circa 2000-2005 weight. I’m happy if I achieve 80% of that loss, ending up under 200. This is a long post, in which I describe the plan, and some misunderstandings I had about dieting and weight loss.

Along the way, I built an estimator that uses data to determine my real calorie intake, needs, and activity level. The results, for me, were surprising.

In practice, the hardest part about calorie deficits is tracking calories. Burying the lede a little, it turns out LLM / ChatGPT-4 is fantastic at counting calories for you from pictures, descriptions, or rough notes.

I’ll cover all that.

What’s a diet

My definition of diet is extended calorie deficit for the purposes of losing bodyfat. I do not differentiate types of food, but I prefer high protein for appetite control. I also don’t do time-based restriction, though I find that skipping breakfast and not eating after dinner is sustainable, and that’s roughly an 18/6.

First step: How many calories do I need?

A 222lb, tall biological male my age requires at least 2025 calories to maintain his weight. How do I know that, and what do I mean by at least? The value is given by the Basal Metabolic Rate equation, for which the most accurate form from Mifflin-St Jeor1 $ BMR = 10 \times weight(kg) + 6.25 \times height(cm) - 5 \times age(y) + G$, where $G$ is 5 for men, and -161 for women.

Hereafter, shortened to

$$ BMR = 10 w + 6.25 H - 5A + G $$

Let’s get started calculating, using Python of course.

def bmr_m(weight, height, age):
    """
    Given weight (kg), height (cm), and age (years), return
    the 'sustaining calories' for males
    """
    return 10 * weight + 6.25 * height - 5 * age + 5

def bmr_f(weight, height, age):
    """
    Given weight (kg), height (cm), and age (years), return
    the 'sustaining calories' for females
    """
    return 10 * weight + 6.25 * height - 5 * age - 161

A close approximation of me, bmr_m(JoshWeight, JoshHeight, JoshAge)~=2000.

This is the amount of calories you need to maintain your weight if you were in a coma. Your daily activity increases this need. The activity factor varies from 1.2 (sedentary) to 1.9 (strenuous exercise daily).

Factoring in activity, we have “TDEE” (Total Daily Energy Expenditure), as:

$$ TDEE = BMR \cdot L \label{tdee}$$

Where $L$ is Activity Level, a constant from 1.2 to 1.9.

A helpful enum here (to match the literature) is:

from enum import Enum

class Activity(Enum):
    SEDENTARY = 1.2
    LIGHT = 1.375
    MODERATE = 1.55
    VERY = 1.725
    EXTRA = 1.9

def calc_tdee(bmr, activity):
    if (activity < 1.2 or activity > 1.9):
        raise ValueError("Activity must be between 1.2 and 1.9")
    return bmr * activity

If you’re like me, you jumped to 1.3 or so, thinking “well of course I’m not super active, but I do play with my kids and run around a bit, etc”. In a bit, we’ll build an estimator to bound these free-ish variables, so let’s proceed with SEDENTARY=1.2 and see how that shakes out.

Or, in my case, calc_tdee(2000, Activity.SEDENTARY.value) ~= 2400.

Losing weight on calorie restriction and “steady state” weight

OK, any amount of daily calories below your TDEE will result in weight loss, right? The generally accepted value is 3500 calories per pound of bodyfat, so if I cut 300 calories a day, I can expect to lose 1 lb every 12 days, right?

Just eat 2100 calories and lose 1 lb/12 days!

Wait a minute. If that’s true I’ll reach negative weights in about 7 years. There’s clearly something else going on. That something is the fact that your BMR is a function of your weight. So your “steady state” weight where you’ll stop losing weight is a function of gender, age, height, and calories. It’s the weight at which (ideally) bmr_m(wt,ht,age)*1.375 == 2100

Stated another way, there is a 6’ 6" male somewhere that eats 2100 calories /day , is not very active, and loses/gains no weight. That could be future me! So, BMR can tell us how much that man weighs.

Rearrange the TDEE equation to solve for weight:

$$ \begin{aligned} TDEE & = L [ BMR ] \\ cal &= L [ 10 w + 6.25 H - 5 A + G ]\\ \frac{cal}{L} &= 10 w + (6.25 H - 5 A + G) \\ 10 w &= \frac{cal}{L} - (6.25 H - 5 A + G) \\ w &= \frac{cal - L\left[6.25 H - 5 A + G\right]}{10} &\text{ ✅ } \\ \end{aligned} $$

def steady_state_weight(calories, activity, height, gender, age):
    """
    Reverse BMR to find weight given calories,
    Returns kg!
    """
    L = activity
    if gender=='m':
        wt = calories /  L - (6.25 * height - 5 * age + 5)
        wt = wt / 10
        return wt
    if gender == 'f':
        wt = calories /  L - (6.25 * height - 5 * age - 161)
        wt = wt / 10
        return wt
    raise ValueError('sex: m|f only')

Result for ~2100 calories given my person? ~171 lbs. Not bad! This uses 1.2 as activty. Look carefully at the above equation - the activity is in the denominator. This should sound alarm bells of the “That’s a sensitive arrangment” variety. What happens with “Light activity” values of 1.375?

The steady state weight drops 50 lbs. I think I knew this, from my boxing days, but I didn’t know it.2

Light bulb #1, adding a tiny bit of exercise will shed a ton of extra weight over time.

Let’s look at what a snack-a-day does to your SSW. Adding 10% to your intake (equivalent of a cookie, short IPA, or a 20oz soda /day) to an otherwise perfect diet, would raise my Sedentary SSW from 171 to 210 lbs.

That’s a gain of 40 lbs over time from a small treat daily.

Light bulb #2, a tiny bit of extra food will add a ton of extra weight over time.

That’s a lot of weight. Taking the stairs might burn 50 calories, which is how much you lose each decade from your BMR. Walking 30 extra minutes would burn 200, offsetting that 40 lb weight gain from the IPA. The battle of the bulge is won and lost in these tiny daily decisions. Anyone can tell you though, that the feedback is over years, not days, so your daily habits set in before you see the noticeable weight gain (or loss).

So the big question is, how long does it take for the effects to be fully realized? This goes back to the original question - how long does it take to lose 1 lb if I cut 300 calories / day?

Now, let’s figure that out, and, that will allow me to, answer, if I want to lose 30 lbs by mid-summer, how many calories do I need to cut?

That’s next.


  1. https://en.wikipedia.org/wiki/Basal_metabolic_rate ↩︎

  2. For reference, if my SSW was 205, and I was doing a couple hours of workouts / day and biking everywhere, my calories must have been ~3500-3800/day. ↩︎

Comments

I have not configured comments for this site yet as there doesn't seem to be any good, free solutions. Please feel free to email, or reach out on social media if you have any thoughts or questions. I'd love to hear from you!