views:

1049

answers:

6

The fundamental equation of weight loss/gain is:

weight_change = convert_to_weight_diff(calories_consumed - calories_burnt);

I'm going on a health kick, and like a good nerd I thought I'd start keeping track of these things and write some software to process my data. I'm not attentive and disciplined enough to count calories in food, so I thought I'd work backwards:

  • I can weigh myself every day
  • I can calculate my BMR and hence how many calories I burn doing nothing all day
  • I can use my heart-rate monitor to figure out how many calories I burn doing exercise

That way I can generate an approximate "calories consumed" graph based on my exercise and weight records, and use that to motivate myself when I'm tempted to have a donut.

The thing I'm stuck on is the function:

int convert_to_weight_diff(int calorie_diff);

Anybody know the pseudo-code for that function? If you've got some details, make sure you specify if we're talking calories, Calories, kilojoules, pounds, kilograms, etc.

Thanks!

+5  A: 

Look at The Hacker's Diet and physicsdiet.com - this wheel has already been invented.

Ken
I *knew* I'd seen information about this before somewhere -- I totally forgot about the hackers diet, and it didn't come up in my google searches. I'll be writing my own code anyway, just for the fun of it. :-)
Stewart Johnson
The exact figure is 3500 calories per pound, as confirmed in the Hackers Diet: http://www.fourmilab.ch/hackdiet/www/subsection1_2_2_0_5.html
Stewart Johnson
A: 

I dunno how accurate this is because it's Wikipedia but it looks like a good basis for a rule-of-thumb-o-meter.

http://en.wikipedia.org/wiki/Food_energy

+2  A: 

I think the conversion factor is about 3500 calories per pound. Google search (not the calculator!) seems to agree: http://www.google.com/search?q=calories+per+pound

Greg Hewgill
I tried google myself but being Australian I was doing calories-per-kilogram. The hacker's diet confirms that number: http://www.fourmilab.ch/hackdiet/www/subsection1_2_2_0_5.html
Stewart Johnson
offtopic: Sorry that you've been too early, now that America is finally adopting the metric system - inch by inch
Olaf
A: 

As you will only burn fat, the conversation is as follows:

To burn 1g of fat you'll have to work out 9kcal.

Source: http://en.wikipedia.org/wiki/Food_energy

Markus Lux
A: 

I think everyone else has summed it up well, however there is something (maybe more) that you have forgotten:

water and stimulants (your a developer right, so caffeine is a standard drug, like Spice is in dune)

For example, if I have 2000cal of food in a day, and thru metabolism and exercise I burn 1750 (I get stuff all exercise at the moment, should be 2500 or so), I have 350cal left, which goes as fat, so I'm about +50 grams (were 3500 cals == about 500g of fat. Not sure if thats right, but lets go with it for the moment)

If I do the exact same thing tomorrow, but I have 2 cups of coffee (keep in mind my coffee of choice is Espresso with nothing else in it, so close to zero cals), I have to take two things into account:

  • caffeine ups my metabolism, so I burn more - so my burn may be +100cals
  • caffeine is a diuretic, so I'll lose more water - so my WEIGHT will be down maybe -200g, depending on my bodys reaction to it.

So, I think for a basic idea, your proposal is a good one, but once you start getting more specific, it gets NASTY complex.

Another example: If you are doing exercise, and burn 500cals during a RUN, you will continue to burn cals for a number of hours after. If you burn 200 cals thru weight training, you'll do the same post-exercise burn (maybe more), and your baseline metabolic burn (how much you burn if you just sit on your backside) will be higher until that muscle atrophies back to whatever it was before.

I think you are right tho - not really a SO question, but fun none the less.

Nic Wise
A: 

I would add that you find a different measurement than BMI into your considerations because it doesn't take body composition into consideration. For example, I remember seeing an article about Evander Holyfield being considered "dangerously obese" based on his high BMI. He looked like he had barely an ounce of fat on him. Anyway, just a consideration.

Dan