A candy store sells bags of marshmallows for five Egyptian pounds each and cola candy for six Egyptian pounds each. A child wants to buy both types of candy and has restrictions on how many they can buy that are described by the figure shown, where 𝑥 represents the number of bags of marshmallows they buy and 𝑦 represents the number of bags of cola candy. What is the lowest price possible in this situation?
This is an example of a linear programming problem. We are given restrictions or constraints on the amount of each candy. These can be written as inequalities. These lead us to a feasible region as shown on the diagram. The optimal solution, in this case the lowest price, will be found at one of the vertices of this feasible region.
Let’s begin by finding the equations of the three lines on our diagram. The vertical line passes through the 𝑥-axis at four. Therefore, this line has equation 𝑥 equals four. As the shaded region is to the left of this and the line is solid, this corresponds to the inequality 𝑥 is less than or equal to four. The horizontal line passes through the 𝑦-axis at three. Therefore, this has equation 𝑦 is equal to three. The shaded region lies below this. And as the line is solid, the inequality here is 𝑦 is less than or equal to three.
Finally, we have a diagonal line with a negative slope. This passes through the 𝑥-axis and 𝑦-axis at six. The 𝑥- and 𝑦-coordinates of every point on this line sum to six. Therefore, the line has equation 𝑥 plus 𝑦 equals six. This is once again a solid line. However, this time, the shaded region is above the line, giving us the inequality 𝑥 plus 𝑦 is greater than or equal to six. These are the three restrictions on the number of bags of candy that the child can buy. They can buy at most four bags of marshmallows, at most three bags of cola candy, and altogether must buy six or more bags of candy.
Our next step is to find the objective function in terms of the variables 𝑥 and 𝑦. We are told that a bag of marshmallows costs five Egyptian pounds. Therefore, the total cost of marshmallows will be equal to five 𝑥. A bag of cola candy costs six Egyptian pounds. Therefore, the total cost of cola candy is equal to six 𝑦. This gives us an overall cost 𝐶 equal to five 𝑥 plus six 𝑦.
As already mentioned, the maximum and minimum values will occur at one of the vertices of the feasible region. In this question, these have coordinates three, three; four, two; and four, three. We can now substitute the values of 𝑥 and 𝑦 into our expression for the cost to work out the lowest price possible. At the point three, three, the cost is equal to five multiplied by three plus six multiplied by three. This is equal to 15 plus 18, which in turn is 33 Egyptian pounds. At the point four, two, we have 𝐶 is equal to five multiplied by four plus six multiplied by two. This is equal to 20 plus 12, which is equal to 32 Egyptian pounds. Buying four bags of marshmallows and two bags of cola candy costs 32 Egyptian pounds.
It is clear that substituting 𝑥 equals four and 𝑦 equals three will give us a higher value than this, as we are still buying four bags of marshmallows but this time three bags of cola candy. For completeness, we see that this is equal to 38 Egyptian pounds, which is six pounds more than our previous value. We are asked to find the lowest price possible. The lowest price based on the restrictions in the figure is 32 Egyptian pounds. This occurs when 𝑥 equals four and 𝑦 equals two, which means that 𝑥 plus 𝑦 is equal to six. And the child buys four bags of marshmallows, two bags of cola candy, and six bags in total.