How The Math Works

Complete documentation of all mathematical formulas and algorithms used in HealthSpan AI for metabolic calculations, body composition analysis, and weight change projections.

1. BMR (Basal Metabolic Rate)

Basal Metabolic Rate is the number of calories your body burns at complete rest to maintain basic physiological functions like breathing, circulation, and cell production.

Mifflin-St Jeor Equation (Primary Formula)

Well-validated for general populations. Default formula in HealthSpan AI.

For Males:
BMR = (10 × weightkg) + (6.25 × heightcm) − (5 × age) + 5

For Females:
BMR = (10 × weightkg) + (6.25 × heightcm) − (5 × age) − 161
Example (30-year-old male, 80kg, 175cm):
BMR = (10 × 80) + (6.25 × 175) − (5 × 30) + 5
BMR = 800 + 1093.75 − 150 + 5 = 1749 kcal/day

Katch-McArdle Formula

Preferred when body fat percentage is known. Uses lean body mass for greater accuracy.

BMR = 370 + (21.6 × lean_masskg)

Where: lean_masskg = weightkg × (1 − body_fat_pct / 100)
Example (80kg, 20% body fat):
lean_mass = 80 × (1 − 0.20) = 64 kg
BMR = 370 + (21.6 × 64) = 1752 kcal/day

Harris-Benedict Equations

Original (1918):

Males: BMR = 66.47 + (13.75 × weightkg) + (5.00 × heightcm) − (6.76 × age)
Females: BMR = 655.10 + (9.56 × weightkg) + (1.85 × heightcm) − (4.68 × age)

Revised (1984):

Males: BMR = 88.36 + (13.40 × weightkg) + (4.80 × heightcm) − (5.68 × age)
Females: BMR = 447.59 + (9.25 × weightkg) + (3.10 × heightcm) − (4.33 × age)

Cunningham Formula

Designed for athletes with lean body mass known:

BMR = 500 + (22 × lean_masskg)

2. TDEE (Total Daily Energy Expenditure)

Total calories burned per day including physical activity.

TDEE = BMR × Activity_Factor

Activity Multipliers

Activity LevelFactorDescription
Sedentary1.2Little to no exercise, desk job
Light1.375Light exercise 1-3 days/week
Moderate1.55Moderate exercise 3-5 days/week
Heavy1.725Heavy exercise 6-7 days/week
Athlete1.9Professional training or 2x/day
Example (BMR = 1749, Moderate activity):
TDEE = 1749 × 1.55 = 2711 kcal/day

Target Calories

Target_Calories = TDEE + Calorie_Delta

Where Calorie_Delta is:
• Negative for weight loss (e.g., −500 kcal/day)
• Zero for maintenance
• Positive for weight/muscle gain (e.g., +300 kcal/day)

Weight Change Estimation

Weekly_Changelbs = (Daily_Delta × 7) / 3500
Weekly_Changekg = (Daily_Delta × 7) / 7700

3. Body Composition

Fat Mass and Lean Mass

Fat_Mass = Total_Weight × (Body_Fat_Pct / 100)
Lean_Mass = Total_Weight − Fat_Mass

Target Weight Calculation

Assuming lean mass is preserved:

Target_Weight = Current_Lean_Mass / (1 − Target_BF_Pct / 100)
Example (64kg lean mass, target 15% body fat):
Target_Weight = 64 / (1 − 0.15) = 64 / 0.85 = 75.3 kg

BMI (Body Mass Index)

BMI = weightkg / (heightm

Imperial: BMI = (weightlbs / (heightinches)²) × 703

4. Macronutrient Distribution

Protein Requirements

Proteingrams = Lean_Masskg × Protein_Multiplier
Activity LevelMultiplier (g/kg LBM)
Sedentary1.6
Light1.8
Moderate2.0
Heavy2.2
Athlete2.4

During caloric deficit, protein is increased to preserve muscle:

Deficit_Protein = Base_Protein + (Lean_Masskg × 0.2)

Complete Macro Calculation

Step 1: Protein
Proteincal = Proteing × 4

Step 2: Fat (minimum 20% for hormonal health)
Remainingcal = Target_Calories − Proteincal
Fatcal = max(Target_Calories × 0.20, Diet_Fat_Ratio × Remainingcal)
Fatg = Fatcal / 9

Step 3: Carbohydrates
Carbcal = Remainingcal − Fatcal
Carbg = Carbcal / 4

Step 4: Fiber
Fiberg = min((Target_Calories / 1000) × 14, 50)

Dietary Approach Ratios

ApproachCarbsFat
Balanced50%30%
Low-Carb30%50%
Ketogenic10%70%
High-Carb60%20%

5. Metabolic Adaptation

As the body remains in a caloric deficit, metabolic rate decreases beyond what would be expected from weight loss alone (adaptive thermogenesis).

Adaptation_Factor = 1.0 − Adaptation_Percentage

Adaptation Components

Weight Loss Component:
Weight_Loss_Pct = (Initial_Weight − Current_Weight) / Initial_Weight × 100
Weight_Component = min(Weight_Loss_Pct × 0.01, 0.15)

Time-Based Component (Exponential):
Time_Component = 1 − e(−weeks / 12)

Body Fat Protection Component:
BF_Component = max(0, (25 − Current_BF_Pct) / 100)

Total Adaptation (capped at 15%):
Total = min((0.15 × Time_Component) + Weight_Component + BF_Component, 0.15)
GLP-1 Medication Adjustment:
If using GLP-1: Total_Adaptation = Total_Adaptation − 0.10
Final Adapted Rate:
Adapted_BMR = Original_BMR × Adaptation_Factor

6. Weight Change Simulation

The simulator models weekly progress accounting for metabolic adaptation and body composition changes.

Weekly Algorithm

Step 1: Current Metrics
Current_BMR = calculateBMR(weight, height, age, gender, bf_pct)
Adapted_BMR = Current_BMR × Adaptation_Factor
Current_TDEE = Adapted_BMR × Activity_Factor

Step 2: Energy Balance
Actual_Delta = Target_Calories − Current_TDEE
Weekly_Energy = Actual_Delta × 7

Step 3: Weight Partitioning
Fat_Ratio = getFatRatio(current_bf_pct) // Higher BF% = more fat loss
Fat_Change = (Weekly_Energy / 7700) × Fat_Ratio
Lean_Change = (Weekly_Energy / 7700) × (1 − Fat_Ratio)

Step 4: Update State
New_Weight = Current_Weight + (Fat_Change + Lean_Change)
New_BF_Pct = (New_Fat_Mass / New_Weight) × 100

Repeat each week with updated values.

7. MATADOR Protocol

Minimum Advertised Trial of weight loss Achieved by Dietary Overhaul with Recovery

Based on Byrne et al. (2018) research showing intermittent dieting produces greater fat loss and less metabolic adaptation than continuous energy restriction.

Protocol Structure

ParameterDefaultRange
Diet Phase14 days7-56 days
Break Phase14 days7-28 days
Total Duration24 weeksConfigurable

MATADOR Adaptation

The research found 12% less metabolic adaptation compared to continuous dieting:

AdaptationMATADOR = (1 − baseadaptation) × 0.88

Where: baseadaptation = 1 − (0.02 × week), minimum 0.70

Break Phase Recovery

During maintenance weeks, metabolic rate partially recovers:

Adaptationfactor = min(Adaptationfactor + 0.05, 1.0)
Example MATADOR Schedule (24 weeks):
• Weeks 1-2: Diet (caloric deficit)
• Weeks 3-4: Break (maintenance)
• Weeks 5-6: Diet
• Weeks 7-8: Break
• Pattern repeats for 24 weeks total

Reference: Byrne NM, et al. (2018). "Intermittent energy restriction improves weight loss efficiency in obese men: the MATADOR study." International Journal of Obesity

8. Diet Profiles

Pre-configured macronutrient ratios for different dietary approaches:

ProfileProteinCarbsFatDescription
Balanced30%40%30%Standard balanced diet
Low-Carb35%25%40%Reduced carbohydrate
Keto25%5%70%Ketogenic (<20g net carbs)
High-Protein40%35%25%Muscle preservation focus
Mediterranean20%45%35%Heart-healthy fats
Zone (40-30-30)30%40%30%Balanced hormonal response

Profile Selection by Goal

GoalRecommended Profiles
Weight LossBalanced, Low-Carb, High-Protein
Muscle GainHigh-Protein, Balanced
MaintenanceBalanced, Mediterranean, Zone
PerformanceBalanced, High-Protein

9. Unit Conversions

Weight

kg → lbs: weightkg × 2.20462
lbs → kg: weightlbs / 2.20462

Height

cm → inches: heightcm / 2.54
inches → cm: heightinches × 2.54
feet/inches → cm: (feet × 12 + inches) × 2.54

Energy

1 lb fat ≈ 3,500 kcal
1 kg fat ≈ 7,700 kcal
(More precise: 1 kg adipose = 1000g × 0.87 × 9 kcal/g = 7,830 kcal)

10. Constants Reference

All constants used in calculations with their exact values and purposes:

Unit Conversion (NIST Standard)

ConstantValueReference
LB_TO_KG0.45359237NIST exact
KG_TO_LB2.204622621851/0.45359237
IN_TO_CM2.54NIST exact
CM_TO_IN0.3937007874021/2.54

Body Fat Limits

ConstantMaleFemale
Essential Fat %5%12%
Min Healthy Fat %8%15%
Max Body Fat %70%

Caloric Limits (Safety Guardrails)

LimitValuePurpose
MIN_DAILY_CALORIES1200 (F) / 1500 (M)Conservative minimum (non-clinical)
MAX_DAILY_DEFICIT1000 kcalConservative maximum deficit
CALORIES_PER_KG_FAT7,716 kcalAdipose tissue energy density
CALORIES_PER_LB_FAT3,500 kcalCommon approximation
MAX_WEEKLY_LOSS_PCT1.5%Maximum % body weight loss/week

Metabolic Adaptation

ConstantValueDescription
MAX_ADAPTATION15%Maximum BMR reduction
TIME_CONSTANT (τ)12 weeksExponential approach time
GLP-1_REDUCTION10%Medication modifier (optional)

Protein Requirements

Activity Levelg/kg Lean Mass
Sedentary1.2
Light1.4
Moderate1.6
Active1.8
Very Active2.0
Athlete2.2

Note: During caloric deficit, protein increases by 10% for muscle preservation.

Simulation Limits

ParameterValue
MAX_SIMULATION_WEEKS104 (2 years)
DEFAULT_WEEKS16
MIN_BMR800 kcal
MAX_BMR4000 kcal

11. Scientific References

All formulas are based on peer-reviewed research:

  1. Mifflin MD, et al. (1990). "A new predictive equation for resting energy expenditure in healthy individuals." American Journal of Clinical Nutrition 51(2):241-7
  2. Harris JA, Benedict FG (1918). "A Biometric Study of Human Basal Metabolism." Proceedings of the National Academy of Sciences 4(12):370-3
  3. Roza AM, Shizgal HM (1984). "The Harris Benedict equation reevaluated: resting energy requirements and the body cell mass." American Journal of Clinical Nutrition 40(1):168-82
  4. Katch VL, et al. (1996). "Essentials of Exercise Physiology." Lippincott Williams & Wilkins
  5. Hall KD, et al. (2011). "Quantification of the effect of energy imbalance on bodyweight." The Lancet 378(9793):826-37
  6. Thomas DM, et al. (2013). "Time to correctly predict the amount of weight loss with dieting." Journal of the Academy of Nutrition and Dietetics 113(2):235-42
  7. Rosenbaum M, Leibel RL (2010). "Adaptive thermogenesis in humans." International Journal of Obesity 34:S47-S55
  8. Trexler ET, et al. (2014). "Metabolic adaptation to weight loss: implications for the athlete." Journal of the International Society of Sports Nutrition 11(1):7
  9. Byrne NM, et al. (2018). "Intermittent energy restriction improves weight loss efficiency: the MATADOR study." International Journal of Obesity 42(2):129-138
  10. ACSM (2017). "ACSM's Guidelines for Exercise Testing and Prescription" - 10th Edition
  11. ISSN Position Stand (2017). "International Society of Sports Nutrition Position Stand: protein and exercise"
  12. ACSM/AND/DC Joint Position Statement (2016). "Nutrition and Athletic Performance"

Calibration & Validation Notes

All formulas are population-based estimates. For scientific defensibility: