I'm trying to adjust recipes to meet specific macro-nutrient targets. Consider a recipe with a bunch of ingredients, each of which is composed of macro-nutrients (fat, carbohydrate, protein, etc.).
For example, a beef chilli recipe might be:
Ingredient | Weight (g) | Carbohydrate (g) | Fat (g) | Protein (g)
+-----------------+------------+------------------+---------+-------------+
Beef Mince | 150.0 | 0.0 | 6.0 | 37.5
Carrot | 50.0 | 3.5 | 0.5 | 0.0
Chilli | 5.0 | 0.8 | 0.7 | 0.7
Cumin | 3.0 | 0.8 | 0.5 | 0.7
Garlic | 10.0 | 1.7 | 0.8 | 0.1
Kidney Beans | 30.0 | 3.9 | 2.1 | 0.3
Onion | 30.0 | 3.3 | 0.6 | 3.0
Rice | 60.0 | 16.2 | 2.4 | 0.6
Tinned Tomatoes | 150.0 | 6.0 | 1.5 | 0.0
+-----------------+------------+------------------+---------+-------------+
36.2g | 15.1g | 42.9g
+------------------+---------+-------------+
And I want to change the weight of the ingredients to meet a given target, in this case 122g of Carbohydrate, 23g of Fat, 45g of Protein.
I'm not having any luck taking each individual ingredients and adjusting to meet the target because they obviously affect all 3 macro-nutrients. It's been a while since I did any matrix multiplication, but it feels like this might be helpful trying to solve the problem.
Is this a well-documented algorithm? Do you have any advice? My Google-foo is failing me.
