I have a math problem that I've been struggling with for a while, and I hope you guys can help me figure this out.
Say that I have a recipe containing the 3 ingredients with varying amount of grams of each ingredient:
Protein: 10g, Carbs: 20g, Fat: 8g
Protein: 0g, Carbs: 2g, Fat: 0g
Protein: 3g, Carbs: 2g, Fat: 1g
In total, this is 13g of protein, 24g of carbs, and 9g of fat. The percentage split is: 28% protein, 52% carbs and 20% fat.
I wan't to be able to change the percentage split dynamically. So for instance, say that I would like 40% protein, 40% carbs and 20% fat in the whole recipe - how would I update the weights of each ingredient to end up with that particular split in the whole recipe?
Looking forward to the responses!