# Cat Food Dry Matter Carb & Phosphorus Calculator — Algorithm (`#cat-food-carb-and-phosphorus-calculator-algorithm`)

Plain-text mathematical specification for `https://pacebowl.com/tools/cat-food-carb-and-phosphorus-calculator/`.

## Clinical Reference Standards
Calibrated against **AAFCO Guaranteed Analysis dry-matter conversion rules**, **NRC (National Research Council) 2006 Modified Atwater Metabolizable Energy factors** for commercial pet food, **AAHA Diabetes Management Guidelines for Dogs and Cats**, and **IRIS (International Renal Interest Society) CKD dietary phosphorus benchmarks**.

## Core Equations
```
dry_matter_pct     = 100 - moisture_pct
ash_pct            = custom_ash_pct (or format default: Wet 2.5%, Dry 7.0%, Freeze-Dried 5.0%)
carbs_as_fed_pct   = max(0, 100 - protein_pct - fat_pct - fiber_pct - moisture_pct - ash_pct)

# Dry Matter Basis (DMB %)
carbs_dmb_pct      = (carbs_as_fed_pct / dry_matter_pct) * 100
protein_dmb_pct    = (protein_pct / dry_matter_pct) * 100
fat_dmb_pct        = (fat_pct / dry_matter_pct) * 100
fiber_dmb_pct      = (fiber_pct / dry_matter_pct) * 100
ash_dmb_pct        = (ash_pct / dry_matter_pct) * 100

# Modified Atwater Metabolizable Energy (% kcal Breakdown)
kcal_protein_100g  = protein_pct * 3.5
kcal_fat_100g      = fat_pct * 8.5
kcal_carbs_100g    = carbs_as_fed_pct * 3.5
total_me_100g      = kcal_protein_100g + kcal_fat_100g + kcal_carbs_100g
protein_kcal_pct   = (kcal_protein_100g / total_me_100g) * 100
fat_kcal_pct       = (kcal_fat_100g / total_me_100g) * 100
carb_kcal_pct      = (kcal_carbs_100g / total_me_100g) * 100

# Renal Phosphorus (DMB % & mg / 100 kcal)
phos_dmb_pct       = (phos_as_fed_pct / dry_matter_pct) * 100
can_grams          = can_oz * 28.349523125
label_kcal_per_kg  = (kcal_per_can / can_grams) * 1000
phos_mg_per_100kcal = (phos_as_fed_pct * 1000000) / label_kcal_per_kg
```

## Educational Screening Thresholds (Verify with Your Veterinarian)
- **Diabetic Carb DMB Range**: `< 10% DMB` (Low-Carb Friendly), `10%–15% DMB` (Moderate Carb), `> 15% DMB` (High Carb).
- **CKD / Renal Phosphorus Range**: `< 0.5% DMB` or `< 125 mg / 100 kcal` (Renal Low-Phos Range), `0.5%–0.8% DMB` or `125–200 mg / 100 kcal` (Moderate Phosphorus), `> 0.8% DMB` or `> 200 mg / 100 kcal` (Higher Phosphorus).
- **Important Label Boundary**: US AAFCO Guaranteed Analysis labels list minimums (Protein, Fat) and maximums (Moisture, Fiber); request the manufacturer's **Typical Analysis (as-fed or dry-matter basis)** for exact clinical renal/diabetic dosing.
