The Price of Beer - Linear Algebra Problem

In summary, a student encountered a math problem while at a pub with friends. The problem involved calculating the cost of different types of beer based on the amount consumed and the total cost of each round. Using linear algebra, the student was able to determine the cost of each type of beer, but was puzzled by the results. Other individuals offered possible explanations, such as rounding issues or happy hour discounts. However, it was concluded that the linear algebra answer was correct, even if it did not accurately reflect real-world pricing.
  • #1
diegogarcia
16
3
I came across the following problem somewhere on the web. The original site is long gone.

The problem has me stumped. May be sopmeone can provide some insight.

(The problem seems too simple to post in the "Linear/Abstract Algebra" forum.)

The Cost of Beer

It was nearing Easter, and a group of students went to a local pub for a (liquid) lunch. Unfortunately, only one of them had any money. But this student kindly offered to pay for them all on the condition that they refunded the money at a later time. During the course of this "lunch" four rounds were purchased, each consisting of combinations of bitter, lager, cider and stout. Due to an oversight the generous student made a record of who had drunk how much of each beer and what the total cost of each round was, but failed to make a record of how much a pint of each of the beers was! Fortunately the student knew all about solving simultaneous equations and realised that it was possible to calculate the cost of the beers from the information available.

The available data are summarised in the table below. (Without a mono-spaced font the table may be a bit out of alignment.)

Pints of beer bought:

Round Bitter Lager Cider Stout Cost of round
no.

1 3/2 2 5/2 1/2 8.99

2 5/2 1/2 2 5/2 10.46

3 2 5/2 3 1 11.78

4 1 2 0 5/2 7.99The student set the problem up in matrix form, denoting the costs of pints of bitter, lager, cider and stout as w, x, y and z respectively, giving a linear equation system.

The student was aware of the problems that could occur if the matrix was less than full rank, and checked that the determinant was indeed non-zero. Thus in full confidence the student proceeded to calculate the cost of each beer. The results were:

A pint of bitter cost: -3.86

A pint of lager cost: 0.60

A pint of cider cost: 4.58

A pint of stout cost: 4.26

The student was puzzled! On checking the calculations no errors were found! The charges made by the publican were also correct.

If nobody made any error why does it look like the students were being paid to drink bitter? What are the correct prices?
 
Mathematics news on Phys.org
  • #2
I verified the matrix calculation, and the costs for each drink are correct. As to why the results are as they are and what the correct prices should be, I have no idea.
 
  • #3
Random ideas: every order includes a tip of some size. The half pints generate half penny prices which are rounded and messing up the linear algebra. The cost of a half pint is not half the cost of a full pint. All of these except the rounding issue don't lead to a solvable price though, and I would be surprised if rounding broke things this badly.
 
  • #4
Just because we know linear algebra, doesn't mean it solves all problems. Is pricing in a bar really linear? Can a beer cost less than zero, or $1.3267?
 
  • Like
Likes scottdave and russ_watters
  • #5
Yes, I have questions about the 1/2 pints. When they say that 5/2 pints were purchased is that 2 pints plus 1 half-pint? 1 pint plus 3 half-pints? I think the problem is under determined, with 8 variables; 4 types x 2 sizes.
 
  • #6
Unless the problem is ill-conditioned, you can trust the linear algebra answer. There are no linear algebra police to guarantee that every problem is a realistic real-world problem. The negative cost of bitter is just because some of the totals are so low that there is no way to get there unless the cost of bitter is negative.
 
  • Like
Likes russ_watters
  • #7
One or more rounds were during a happy hour?
 
  • Love
Likes russ_watters
  • #8
DaveE said:
Yes, I have questions about the 1/2 pints. When they say that 5/2 pints were purchased is that 2 pints plus 1 half-pint? 1 pint plus 3 half-pints? I think the problem is under determined, with 8 variables; 4 types x 2 sizes.
Yes. 5/2 pints = 2 pints + 1/2 pint.

For whatever it is worth, I have posted the original HTML file, found in my digital scrapbook, at this link:

[Link to questionable website deleted by the Mentors]
 
Last edited by a moderator:
  • #9
diegogarcia said:
why does it look like the students were being paid to drink bitter?
It's probably American beer. 😁

Linear algebra should answer this problem, so if the result doesn't make sense then there's a mistake somewhere. Obvious options include half pints not costing half what a pint costs (very common) or some sort of price change (2-for-1 "happy hour"). I also note "coming up to Easter" in the problem description. The only possible drink related thing I can think of "coming up to Easter" is St Patrick's day, so pricing shenanigans on Guinness (a stout) are also possible.

If anybody wants to consider doubling a few prices or halving the numbers of stouts ordered, be my guest. I think the pint/half thing is hopeless unless someone knows a rule for how much more expensive two halves are than one pint.
 
  • #10
DaveE said:
Just because we know linear algebra, doesn't mean it solves all problems.
It should solve this problem.

A thought of mine is that in a 4-dimensional space the solution should reside in the octant in which all x,y,z,w are positive (i.e. > 0). Is there some condition on the coefficient matrix that should guarantee this kind of solution?
 
  • #11
diegogarcia said:
It should solve this problem.

A thought of mine is that in a 4-dimensional space the solution should reside in the octant in which all x,y,z,w are positive (i.e. > 0). Is there some condition on the coefficient matrix that should guarantee this kind of solution?
Some numbers in the total cost column are too small. That forces a negative cost of something to get totals that small. The problem is not realistic.
 
  • #12
FactChecker said:
The problem is not realistic.
Six and a half pints for 8.99? You ain't wrong...
 
  • Like
Likes PhDeezNutz and FactChecker
  • #13
diegogarcia said:
Is there some condition on the coefficient matrix that should guarantee this kind of solution?
Since the problem is non-linear (both from restriction of the domain to positive numbers and the rounding requirement), I don't see that there is a guarantee of an exact solution. I found some that were very close*, but not exact. I lost interest when I decided you needed 8 variables.

OTOH, you do have an exact linear solution. It's the one in the problem statement where they pay you to drink beer.

* $1.37, $1.46, $1.31, $1.48 per pint is one

BTW, if you think I'm going to download a file from a site I've never heard of just to see a problem statement, you are mistaken. You can do better at posting than that.
 
  • Like
Likes pbuk
  • #14
DaveE said:
BTW, if you think I'm going to download a file from a site I've never heard of just to see a problem statement, you are mistaken. You can do better at posting than that.
Quite: that site is not suitable. Anyway the question is available on the interweb: it is the bonus question in Part 1 of worksheet 3 from http://www.staff.city.ac.uk/o.s.kerr/CompMaths/.

There is also a hint: the "correct" solution does indeed appear to depend on half a pint of beer priced at £1.99 a pint being £1.00.

Edit: a little trial and error should yield the correct solution quite quickly :smile:
 
Last edited:
  • Like
Likes berkeman
  • #15
FactChecker said:
The negative cost of bitter is just because some of the totals are so low that there is no way to get there unless the cost of bitter is negative.
This is not true: in the "correct" solution the prices are all realistic (if a bit cheap by current standards unless you drink in a popular chain beginning with "W").
 
  • #16
pbuk said:
This is not true: in the "correct" solution the prices are all realistic (if a bit cheap by current standards unless you drink in a popular chain beginning with "W").
I don't understand. I guess I am missing some important parts of the problem statement. I thought that the determinant was checked to be non-zero and there was a known solution to 4 equations with 4 unknowns. Is this a second solution?
I also do not see where there is anything nonlinear in the problem statement, and why people are talking about round-off issues.
 
Last edited:
  • #17
FactChecker said:
I don't understand. I guess I am missing some important parts of the problem statement. I thought that the determinant was checked to be non-zero and there was a known solution to 4 equations with 4 unknowns. Is this a second solution?
I also do not see where there is anything nonlinear in the problem statement, and why people are talking about round-off issues.
OK, restrictions weren't literal in the problem statement. Except for the implication that the only (single) solution using linear algebra alone wasn't acceptable.

Still, if they are paying in Bitcoin, maybe there isn't a rounding restriction. IDK.
 
  • Like
Likes pbuk
  • #18
Ibix said:
I think the pint/half thing is hopeless unless someone knows a rule for how much more expensive two halves are than one pint.
Yeah, the hint helps:

Office_Shredder said:
I would be surprised if rounding broke things this badly.
Then you will be surprised, although you shouldn't be: small errors in linear equations lead to big errors in solutions, and rounds 1 and 3 are pretty similar. I think this is a good question for illustrating that.

FactChecker said:
I don't understand. I guess I am missing some important parts of the problem statement.
The only thing you are missing is the hint:
if the price of a pint of beer is £1.99, how much does half a pint cost?
And perhaps the fact that half pennies were removed from circulation in the UK in 1984 when beer was about 60p a pint.

FactChecker said:
I also do not see where there is anything nonlinear in the problem statement
The solution space is not continuous.
 
Last edited:
  • #19
DaveE said:
OK, restrictions weren't literal in the problem statement. Except for the implication that the only (single) solution using linear algebra alone wasn't acceptable.
Exactly. We have 4 equations with 4 unknowns so if the unique solution is nonsense there must be something wrong with our equations.
 
  • #20
pbuk said:
Exactly. We have 4 equations with 4 unknowns so if the unique solution is nonsense there must be something wrong with our equations.
The problem is ill-conditioned.
The costs in the original statement give the exact answer.
bitter=-$3.86; lager=$0.60; cider=$4.58; and stout=$4.26 gives these exact answers:
equ1=$8.99; equ2=$10.46; equ3=$11.78; equ4=$7.99

These costs: bitter=$1.37; lager=$1.46; cider=$1.31; and stout=$1.48 gives these close answers:
equ1=$8.99; equ2=$10.475; equ3=$11.80; equ4=$7.99;
 
  • Like
Likes DrClaude
  • #21
The assumption that half a pint costs almost exactly half what a pint costs is false. If a pint costs £3, then a half pint could cost anything up to about £2, I suggest.
 
  • #22
PeroK said:
The assumption that half a pint costs almost exactly half what a pint costs is false. If a pint costs £3, then a half pint could cost anything up to about £2, I suggest.
In that case, I suggest that this thread should not be in the linear algebra section. It should be moved to the "anything goes" section.
 
  • Like
Likes DaveE
  • #23
FactChecker said:
The problem is ill-conditioned.
Yes, I suspect that is the point of the question - to show how small errors can dramatically affect the solution to an ill-conditioned problem. And as I said above you can easily spot the ill-conditioning - look at rounds 1 and 3.

FactChecker said:
These costs: bitter=$1.37; lager=$1.46; cider=$1.31; and stout=$1.48 gives these close answers:
You should not be looking for answers that are approximately correct to the initial set of equations, you need to look for answers are exact for a set of equations that is close to the initial set of equations.

For instance in round 4 cost £7.99 but if the price of stout was an odd number, say £1.49 then it would have contributed 75p to the round. If instead you use half the price of a pint then it would have contributed 74.5p and the round would have cost £7.985. This is the only other possibility for round 4 using the information in the question.

PeroK said:
The assumption that half a pint costs almost exactly half what a pint costs is false. If a pint costs £3, then a half pint could cost anything up to about £2, I suggest.
I don't think that would be legal in the UK, but in any case for the correct solution only 'normal' rounding is applied (i.e. half pennies are rounded upwards).

FactChecker said:
In that case, I suggest that this thread should not be in the linear algebra section. It should be moved to the "anything goes" section.
No the correct solution IS the exact solution to a set of linear equations, just not the set you think it is. This is to my mind a brilliant example of how errors can happen in the real world when choosing a model.
 
  • Like
Likes DrClaude
  • #24
FactChecker said:
In that case, I suggest that this thread should not be in the linear algebra section. It should be moved to the "anything goes" section.
In general it's more economical to buy larger sizes. You should check this out next time you're in the supermarket!
 
  • #25
pbuk said:
I don't think that would be legal in the UK
I looked it up to see if there was a law about this that we were supposed to exploit, but not as far as I could see. A couple of sites made the point that the overhead of serving a half pint probably exceeds half that of a pint, so it's not unreasonable for two halves to be more than a pint. Apparently 83% of people surveyed (by who, when, I know not) expect it to be exactly half, though.

I'm going to have to play around with the rounding. I see how you're getting your answer but I'm unpleasantly surprised by how far off the linear solution is.
 
  • Like
Likes PeroK
  • #26
PeroK said:
In general it's more economical to buy larger sizes. You should check this out next time you're in the supermarket!
I do check the per-unit prices. You would probably be surprised at how many exceptions there are. People assume that the larger sizes are cheaper per unit, but they are often more expensive (same brand, same product). I don't know why.
In any case, that would eliminate this from being a mathematically well-defined problem and certainly from being a linear algebra problem.
 
  • #27
Ibix said:
I looked it up to see if there was a law about this that we were supposed to exploit, but not as far as I could see.
I believe the practice is currently derived from The Weights and Measures (Intoxicating Liquor) Order 1988.

Ibix said:
Apparently 83% of people surveyed (by who, when, I know not) expect it to be exactly half, though.
If a pint were £1.49 it couldn't be exactly half, so again those 83% would assume it to be rounded up to the nearest penny.

Ibix said:
I'm going to have to play around with the rounding. I see how you're getting your answer but I'm unpleasantly surprised by how far off the linear solution is.
That's ill conditioning for you! But note again the linear solution is EXACT, it is the equations that are rounded.
 
  • #28
FactChecker said:
I do check the per-unit prices. You would probably be surprised at how many exceptions there are. People assume that the larger sizes are cheaper per unit, but they are often more expensive (same brand, same product). I don't know why.
In any case, that would eliminate this from being a mathematically well-defined problem and certainly from being a linear algebra problem.
It's a very narrow view of mathematics if it doesn't apply to the price of beer!
 
  • Like
Likes pbuk
  • #29
PeroK said:
It's a very narrow view of mathematics if it doesn't apply to the price of beer!
I makes a problem with twice as many variables as equations.
 
  • #30
FactChecker said:
In any case, that would eliminate this from being a mathematically well-defined problem and certainly from being a linear algebra problem.
No, the correct solution is the exact solution to a linear system which can be deduced from the information in the question.
 
  • #31
I might just as well propose that the bitter was bad and the proprietor ended up paying those who drank it $3.86 per pint.
In any case, "exact" means exact, not "nearly correct".
 
  • #32
FactChecker said:
I makes a problem with twice as many variables as equations.
Yeah, but @pbuk's approach is to restrict the price of a half to half the price of a pint or half plus a half penny. There's also the problem of interpreting things like 5/2 - there are three ways of making that total. That reduces it to solving and checking a relatively small number of linear problems, even if you don't make further insights into the pricing before you start.
 
  • Like
Likes pbuk
  • #33
Suit yourself. IMO, this is a much better exercise if it is used to illustrate what can happen in an ill-conditioned problem than to illustrate that it is ok to call a problem "linear algebra" and fudge the "linear" part.
 
Last edited:
  • Like
Likes PeroK
  • #34
FactChecker said:
Suit yourself. IMO, this is a much better exercise if it is used to illustrate what can happen in an ill-conditioned problem than to illustrate that it is ok to call a problem "linear algebra" and fudge the "linear" part.
Yes, but that is something that you should take up with the OP: I suggest looking at the original problem in its original context (which is a Computational Maths course, not linear algebra):
pbuk said:
it is the bonus question in Part 1 of worksheet 3 from http://www.staff.city.ac.uk/o.s.kerr/CompMaths/.
.. and perhaps also noting from the course notes linked on the same page:
There are two principal types of error that occur when solving the equations.
• Errors in the data. By which is meant that some of the coefficients may only be quoted to say two decimal places, this immediately gives a possible error ±0.005. This type of error is a problem when the solution to the equations are sensitive to small changes in the coefficients - this will always be a problem and is referred to
as ill conditioning. Although this problem is not that common we must always be on our guard to identify when it may occur...

Ibix said:
Yeah, but @pbuk's approach is to restrict the price of a half to half the price of a pint or half plus a half penny. There's also the problem of interpreting things like 5/2 - there are three ways of making that total. That reduces it to solving and checking a relatively small number of linear problems, even if you don't make further insights into the pricing before you start.
The original table from the link I posted above is
1671532028420.png

When there are multiple ways of interpreting e.g. ## 2 \frac 1 2 ## it is usually best to start with the simplest.
 
  • #35
pbuk said:
Yes, but that is something that you should take up with the OP: I suggest looking at the original problem in its original context (which is a Computational Maths course, not linear algebra):
Ok, I'll buy that. It would have also helped a lot if the hint had been included in the original post.
pbuk said:
.. and perhaps also noting from the course notes linked on the same page:
Yes. I note, especially, this part: "This type of error is a problem when the solution to the equations are sensitive to small changes in the coefficients - this will always be a problem and is referred to as ill conditioning."
pbuk said:
The original table from the link I posted above is
View attachment 319105
When there are multiple ways of interpreting e.g. ## 2 \frac 1 2 ## it is usually best to start with the simplest.
I guess this leads to questions like whether '2' is two pints, or four half pints, or one pint and two half pints, etc.
In an ill-conditioned problem, I would hate to guess how many reasonable solutions there might be, and what the standard of "reasonable" is.
 

Similar threads

Replies
7
Views
1K
  • STEM Academic Advising
Replies
16
Views
499
  • Math Proof Training and Practice
Replies
25
Views
2K
  • Precalculus Mathematics Homework Help
Replies
32
Views
838
  • General Math
Replies
2
Views
6K
  • General Math
Replies
1
Views
2K
  • General Math
Replies
4
Views
3K
Replies
6
Views
1K
  • Calculus and Beyond Homework Help
Replies
8
Views
620
  • STEM Academic Advising
Replies
6
Views
4K
Back
Top