Problem: a recipe calls for 250ml double cream (48% fat) and 100ml whole milk (3.5% fat). I only have double cream (48% fat) and semi-skimmed milk (1.5% fat).
How much do I adjust the double cream by to get the same quantity liquid and fat content?
It’s a simple simultaneous equation, so solving it with Sympy is overkill, but developers do overkill best, right?
So:
>>> linsolve([Eq(x + y, 350), Eq(x*.48 + y*.015, 250*.48 + 100*.035)], (x, y))
ie. volume must be 350ml, fat must equal the original recipe.
The answer:
{(254.301075268817, 95.6989247311828)}
Ok, so it probably doesn’t matter!