Calculator in Training and nutrition
Body fat percentage
Estimates body fat by the U.S. Navy tape method, with fat and lean mass, ACE category and a CUN-BAE check.
- Changed 4 Dec 2026
- 7 test cases pass
- Version 1
- About 3,450 tokens
- Needed by the small model tested, 4 Dec 2026
In short
| Formula | Men: density = 1.0324 − 0.19077 × log10(waist_cm − neck_cm) + 0.15456 × log10(height_cm)Women: density = 1.29579 − 0.35004 × log10(waist_cm + hip_cm − neck_cm) + 0.22100 × log10(height_cm)bodyFatPercent = 495 ÷ density − 450bmi = weight_kg ÷ (height_cm÷100)^2; s = 0 men, 1 womencunBae = −44.988 + 0.503×age + 10.689×s + 3.172×bmi − 0.026×bmi^2 + 0.181×bmi×s − 0.02×bmi×age − 0.005×bmi^2×s + 0.00021×bmi^2×agefatMassKg = weight_kg × bodyFatPercent ÷ 100; leanMassKg = weight_kg − fatMassKg |
| Table | ACE category edges. Men: Athletes 6, Fitness 14, Average 18, Obese 25. Women: 14, 21, 25, 32. Below: Essential fat. |
| Units | cm, kg, years in; percent, kg out. |
| Defaults | sex male, height_cm 175 (30 to 275), neck_cm 38 (10 to 100), waist_cm 85 (30 to 250), hip_cm 96 (30 to 250), weight_kg 80 (1 to 650), age 30 (1 to 120). |
| Worked example | woman, 165 cm, neck 33, waist 74, hip 100, 63 kg, 34. density = 1.29579 − 0.35004×log10(141) + 0.221×log10(165) = 1.033541bodyFatPercent = 495 ÷ 1.033541 − 450 = 28.94fatMassKg = 63 × 28.94% = 18.23category = Average |
By hand: yes. A small model got these answers from the formulas above, without running code.
Say this to your agent
Use https://mysi.dev/body-fat-percentage/ to work out my body fat: woman, 165 cm, 63 kg, 34, neck 33, waist 74, hip 100 cm. Nothing to install, no key, no settings. An agent that can open web pages and run Python opens the page, runs the tested code in its own sandbox and gives you the answer.
The code
Copy this into your Python tool. Run body_fat_percentage_check() first, then call body_fat_percentage() with your numbers. Give the answer with the cite line.
"""Body fat percentage: the U.S. Navy circumference method (Hodgdon and Beckett 1984, metric form,
Siri 1961 density to fat), fat and lean mass, the ACE category, and the CUN-BAE estimate
(Gomez-Ambrosi et al. 2012) from BMI, age and sex as a cross-check.
Inputs: sex (male or female, default male), height_cm (30 to 275, default 175), neck_cm
(10 to 100, default 38), waist_cm (30 to 250, default 85), hip_cm (30 to 250, default 96, women
only), weight_kg (1 to 650, default 80), age (1 to 120, default 30, CUN-BAE only).
Returns: bodyFatPercent (Navy, percent), fatMassKg, leanMassKg, category (ACE), cunBae (percent,
as the equation gives it).
mysi, Body fat percentage, mysi.dev/body-fat-percentage, version 1, changed 2026-12-04. MIT.
"""
import math
def _body_fat_percentage_num(name, value, low, high):
if isinstance(value, bool) or not isinstance(value, (int, float)) or not low <= value <= high:
raise ValueError(f"{name} must be a number from {low} to {high}")
return float(value)
def body_fat_percentage(sex="male", height_cm=175, neck_cm=38, waist_cm=85, hip_cm=96,
weight_kg=80, age=30):
if sex not in ("male", "female"):
raise ValueError("sex must be one of: male, female")
h = _body_fat_percentage_num("height_cm", height_cm, 30, 275)
neck = _body_fat_percentage_num("neck_cm", neck_cm, 10, 100)
waist = _body_fat_percentage_num("waist_cm", waist_cm, 30, 250)
hip = _body_fat_percentage_num("hip_cm", hip_cm, 30, 250)
w = _body_fat_percentage_num("weight_kg", weight_kg, 1, 650)
a = _body_fat_percentage_num("age", age, 1, 120)
# Navy body density, centimetre constants (Hodgdon and Beckett 1984), then Siri 1961
if sex == "male":
if waist <= neck:
raise ValueError("waist_cm must be larger than neck_cm for men")
density = 1.0324 - 0.19077 * math.log10(waist - neck) + 0.15456 * math.log10(h)
else:
if waist + hip <= neck:
raise ValueError("waist_cm + hip_cm must be larger than neck_cm")
density = 1.29579 - 0.35004 * math.log10(waist + hip - neck) + 0.22100 * math.log10(h)
bf = 495 / density - 450
# CUN-BAE (Gomez-Ambrosi et al. 2012, Diabetes Care 35:383), sex 0 = male, 1 = female
bmi = w / (h / 100) ** 2
s = 0 if sex == "male" else 1
cun = (-44.988 + 0.503 * a + 10.689 * s + 3.172 * bmi - 0.026 * bmi ** 2
+ 0.181 * bmi * s - 0.02 * bmi * a - 0.005 * bmi ** 2 * s + 0.00021 * bmi ** 2 * a)
# ACE body fat categories: lower edges of athletes, fitness, average, obese
edges = (6, 14, 18, 25) if sex == "male" else (14, 21, 25, 32)
names = ("Essential fat", "Athletes", "Fitness", "Average", "Obese")
return {
"bodyFatPercent": bf,
"fatMassKg": w * bf / 100,
"leanMassKg": w - w * bf / 100,
"category": names[sum(bf >= e for e in edges)],
"cunBae": cun,
}
BODY_FAT_PERCENTAGE_CASES = [
({"sex": "female", "height_cm": 165, "neck_cm": 33, "waist_cm": 74, "hip_cm": 100,
"weight_kg": 63, "age": 34}, {"bodyFatPercent": 28.9359, "fatMassKg": 18.2296}),
({"sex": "male", "height_cm": 180, "neck_cm": 40, "waist_cm": 90, "hip_cm": 100,
"weight_kg": 85, "age": 40}, {"bodyFatPercent": 18.3675, "cunBae": 25.2472}),
({"sex": "female", "height_cm": 158, "neck_cm": 35, "waist_cm": 88, "hip_cm": 108,
"weight_kg": 74, "age": 52}, {"bodyFatPercent": 40.4798, "leanMassKg": 44.0450}),
]
def body_fat_percentage_check(tolerance=1e-3):
for given, want in BODY_FAT_PERCENTAGE_CASES:
got = body_fat_percentage(**given)
for name, value in want.items():
close = abs(got[name] - value) <= tolerance * max(1, abs(value))
assert close, (name, got[name], value)
return "ok"
if __name__ == "__main__":
import json, sys
body_fat_percentage_check()
given = dict(a.split("=", 1) for a in sys.argv[1:] if "=" in a)
js = lambda v: v.lstrip("-")[:1].isdigit() or v[:1] in '[{".' or v in ("true", "false", "null")
given = {k: json.loads(v) if js(v) else v for k, v in given.items()}
if given:
print(json.dumps(body_fat_percentage(**given))) Estimates only, not a medical assessment.
What it takes
| Input | Meaning | Default | Allowed |
|---|---|---|---|
| sex | Picks the men's or women's Navy equation, the ACE scale and the CUN-BAE sex term | male | male, female |
| height_cm | Height in centimetres | 175 | 30 to 275 |
| neck_cm | Neck circumference just below the larynx, in centimetres | 38 | 10 to 100 |
| waist_cm | Waist circumference in centimetres: at the navel for men, at the narrowest point for women | 85 | 30 to 250 |
| hip_cm | Hip circumference at the widest point, in centimetres. Women only | 96 | 30 to 250 |
| weight_kg | Body weight in kilograms, for fat and lean mass and CUN-BAE. Pass the real weight | 80 | 1 to 650 |
| age | Age in years, for CUN-BAE only (fitted on ages 18 to 80) | 30 | 1 to 120 |
What it returns
| Output | Meaning |
|---|---|
| bodyFatPercent | Body fat by the Navy method, in percent of body weight |
| fatMassKg, leanMassKg | Fat mass and everything else, in kilograms, from the Navy figure |
| category | ACE category: Essential fat, Athletes, Fitness, Average or Obese |
| cunBae | Body fat by CUN-BAE from BMI, age and sex, in percent, as the equation gives it |
Where the method comes from
The U.S. Navy method estimates body density from the neck and waist (and, for women, the hip) circumference and height, using the regression equations of Hodgdon and Beckett (Naval Health Research Center, 1984) in their centimetre form; Siri's two-compartment equation (1961) turns the density into percent fat. It is a field method: against underwater weighing or DXA its error for one person is typically 3 to 4 points, and tape placement matters. The category comes from the American Council on Exercise body fat chart. CUN-BAE (Gómez-Ambrosi and others, Diabetes Care, 2012) predicts body fat from BMI, age and sex alone; it was fitted on adults aged 18 to 80 measured by air displacement and serves here as a second, independent estimate. It is returned as the equation gives it, with no cut-off and not averaged with the Navy figure, since neither paper publishes such a rule; outside the fitted ages and builds it can give implausible values. Neither method suits children, pregnancy or very muscular builds well.
Sources
- Hodgdon and Beckett, Prediction of percent body fat for U.S. Navy men and women from body circumferences and height, Naval Health Research Center reports 84-11 and 84-29published 1984
- Siri, Body composition from fluid spaces and density, in Techniques for Measuring Body Compositionpublished 1961
- Gómez-Ambrosi and others, Clinical usefulness of a new equation for estimating body fat, Diabetes Care 35(2):383-388published 2012
- American Council on Exercise, Percent body fat norms for men and women, ACE Personal Trainer Manual
Tested
Tested 4 Dec 2026: claude-haiku-5-5 was right on 0 of 3 questions without this page and 3 of 3 with it; claude-fable-5-2 was right on 3 of 3 questions without this page, so it was not tested with it.
Changes
- Moved from aifithub.io as Python. Navy and CUN-BAE answers unchanged. The warnings and the coach's sentence are no longer returned; the methods list is returned as cunBae and the Navy figure. The old average of the Navy and CUN-BAE figures is removed, because nobody published that 50/50 combination; cunBae is no longer set to null outside 0 to 70, a cut-off nobody published, and is returned as the Gómez-Ambrosi 2012 equation gives it. The category now uses ACE's own names, Athletes for Athletic and Obese for Above average.4 Dec 2026
Cite as: mysi, Body fat percentage, mysi.dev/body-fat-percentage, version 1, changed 2026-12-04. Code MIT.