Diet and mixing problems · Mathematics Class 11–12 | StemPy Lab
Course 19.3·Lesson 2 of 3
Diet and mixing problems
A diet or mixing problem asks for the cheapest mix of two foods that still meets minimum needs. The needs give inequalities with ≥, so the feasible region is unbounded, and the objective is a cost to be minimised. Find the corners, work out the cost at each, and take the smallest. Confirm that it is a true minimum with the half-plane test, and say the answer in kilograms and rupees.
about 25 min1 simulation
Lesson 2 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
write the constraints and the cost of a diet problem;
see why its region is unbounded and why a minimum still exists;
find the cheapest mix and say how its price changes when a food gets dearer or cheaper.
The shape of a diet problem
A canteen mixes two foods. Food P has 3 units of protein and 1 unit of iron in each kilogram. Food Q has 1 unit of protein and 2 units of iron in each kilogram. A meal needs at least 18 units of protein and at least 16 units of iron. Food P costs 6 rupees a kilogram and food Q costs 5 rupees a kilogram. What is the cheapest mix?
The unknowns. Let x kg of P and y kg of Q go into a meal.
The objective. The cost is Z=6x+5y rupees. We want it as small as possible.
The constraints. Protein: 3x+y≥18. Iron: x+2y≥16. Also x≥0 and y≥0.
Notice the signs. The needs are minimums, so the signs are ≥. A resource limit in a factory was ≤. In a diet it is the other way round. Eating more of a food never hurts the needs, so the region has no upper edge. It is unbounded.
Solve it
The corners. Multiply 3x+y=18 by 2 to get 6x+2y=36. Subtract x+2y=16 to get 5x=20, so the lines meet at x=4, y=6. The line 3x+y=18 meets the y axis at (0,18). The line x+2y=16 meets the x axis at (16,0). The corners are (0,18), (4,6) and (16,0).
A graph of the diet region, with kilograms of food P on the x axis and kilograms of food Q on the y axis. The unbounded region 3x + y at least 18, x + 2y at least 16, x and y at least 0 is shaded light blue above and to the right of the corners (0, 18), (4, 6) and (16, 0). Each corner is labelled with its cost in rupees: 90, 54 and 96. The corner (4, 6) is red and labelled as the cheapest, with a red dashed line for a cost of 54 rupees touching the region only there. Arrows at the top and right edges show that the region does not end.
The costs. At (0,18), Z=90. At (4,6), Z=24+30=54. At (16,0), Z=96. The smallest is 54.
The test. The region is unbounded, so check the half-plane 6x+5y<54. The line 6x+5y=54 has slope −56. The two edges at (4,6) have slopes −3 and −21. Since −3<−56<−21, the line touches the region only at (4,6), and the half-plane has no feasible point.
The answer. The cheapest meal uses 4 kg of P and 6 kg of Q and costs 54 rupees.
Check the needs. Protein is 3(4)+6=18 units and iron is 4+2(6)=16 units. Both are exactly met.
What if the price changes?
Suppose food P gets cheaper. At 2.5 rupees a kilogram, the corner (4,6) costs 4(2.5)+30=40 rupees and the corner (16,0) costs 16(2.5)=40 rupees. They tie. Below 2.5 rupees, the all-P diet at (16,0) is cheaper.
So the best diet changes when the prices change, and the corner where it changes is found by setting two corner costs equal.
Practise with new numbers
Try it in Python
The program works out the cost at each corner and asks linprog. The needs use ≥, so each row is multiplied by −1. Then it sweeps the price of food P.
Common mistakes
Using ≤ for a need. A need is a minimum, so it is ≥.
Looking for a maximum cost. A diet problem asks for the minimum. The maximum does not exist on an unbounded region.
Taking the smallest corner without the test. On an unbounded region, test that no feasible point is cheaper.
Mixing up units. Say kilograms of each food and rupees for the cost.
Remember these
Diet problems have ≥ constraints, a cost to minimise, and an unbounded region.
Work out the cost at every corner. The smallest corner cost is the minimum when the prices are positive.
If a price changes, the cheapest corner changes where two corner costs tie.
Answer in the units of the story.
References
NCERT, Mathematics Textbook for Class XII, Part II, Chapter 12, Linear Programming (diet problems).
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Food A has 2 units of calcium in each kilogram and food B has 1 unit. A meal needs at least 12 units. Write the rule.
The corners of a diet region are (0,10), (3,4) and (8,0). Food A costs 4 rupees a kilogram and food B costs 3 rupees. Find the lowest cost.
Why does a diet problem have no maximum cost?
A diet uses x kg of P and y kg of Q. Food P costs 6 rupees a kg and food Q costs 5 rupees. Write the cost of 3 kg of P and 4 kg of Q.
Two corners cost the same. What does that tell you?
Enroll free in Linear Programming Problems from Words
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.