Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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

I mean, if this is what you're looking for, you should be set.

Supposely, in Einstein's Theory of Relativity he states that a calorie does have an exact weight(0.000000000000046 grams).

With this said, something like this should work:

int convert_to_weight_diff(int calories)
{
    return 0.000000000000046 * calories;
}

That would return, in grams, how much weight was lost. To make it more reasonable, I would do something like find out how many calories are in like half a pound or whatever.

From what I read, that is what you are trying to do. Tell me if not.

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

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top