Deceptive Simple Maths Question (1 Viewer)

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:29
Joined
Sep 12, 2006
Messages
15,660
Evaluate this expression

48 / 2 (9+3)

(consider the / as a divide sign - you know a line with dots above and below)


Is this 2 or 288.

Caused enormous discussion on another dicussion board.
 

Banana

split with a cherry atop.
Local time
Yesterday, 20:29
Joined
Sep 1, 2005
Messages
6,318
Though the statement appears ambiguous because it can be read as:

48 / (2 * (9+3))

or

(48 / 2) * (9 + 3)

There are specific rules on how one is to read a mathematical statement and proceed. Generally, do the inside first, then do multiply/division and add/subtract last.

For that reasons, I use the 2nd reading, which would give 288. If they wanted to keep the (9 + 3) then they should have had put it in a group explicitly. Else, it's just a separate term apart from the fraction with implicit multiplier.
 
Last edited:

dan-cat

Registered User.
Local time
Today, 04:29
Joined
Jun 2, 2002
Messages
3,433
I came to 288. There isn't any specification that the 2 must be applied to the group (9 + 3) separately from the 48. Thus I did the same as Banana. Calculated the first group (9+3) then calculated 48 / 2 as a separate group then applied one against the other.
 

dan-cat

Registered User.
Local time
Today, 04:29
Joined
Jun 2, 2002
Messages
3,433
If it helps VS 2010 calculates x as 288 for the following:

Code:
Dim x as Double

x = 48 / 2 * (9 + 3)
 

Banana

split with a cherry atop.
Local time
Yesterday, 20:29
Joined
Sep 1, 2005
Messages
6,318
dan-cat,

It'd be more convincing if we could stick closer to the original statement without adding a multiply operator. Out of curiosity, I tried this in VBA:

Code:
?48/2(9+3)
 24  12

So, VBA doesn't handle implicit operators but it does at least hint that it didn't try to lump the (9+3) with the 2 in the denominator.

Tangent: Is there a way to get Visual Studio to evaluate an arbitrary expression without having to actual run a piece of code? It irks me that I can't use immediate windows in VS unless I'm already running in debug mode. VBA can do that. Surely VS should be able to do that. (I realize that VBA is interpreted and thus can evaluate lot of things that VS has to compile & run but I'm not talking about evaluating any actual objects; just simple expressions that doesn't involve any objects)
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:29
Joined
Feb 28, 2001
Messages
27,217
The original expression is improperly formed because it has an implied operator. Therefore, it has no correct answer that is a number. It might, however, be possible to derive an answer if you agree to a particular computer language's operator precedence rules.

48/2 = 24. (9+3) = 12. Because the parentheses were explicit, you never anything except 12 for that sub-clause. If you use FORTRAN and assume the multiplication operators between the "2" and the "(" then you have a sequence of operators with equal precedence, so you do them in left-to-right order. In that case, the answer is 288.

Note that to evaluate this expression, you need to make two assumptions. If you disallow either one, then the expression value must be undefined.

Just thought I'd toss in my 2 cents' worth (or 2 pence, for our UK friends.)
 

Banana

split with a cherry atop.
Local time
Yesterday, 20:29
Joined
Sep 1, 2005
Messages
6,318
The_Doc_Man -

I've always thought that the precedence rules were defined by mathematicians and compilers simply followed those same set of rules.

You're right that there's an assumption being made about how one is to evaluate the expression, but I'll be darned if I can find a example of precedence rules supporting 2 as the answer. There's indeed few other ways to write a mathematical expressions but tehy wouldn't fit here (e.g. Polish notation where we'd be reading something like:
Code:
/ 48 2 * + 9 3
(Note: I pulled this out of my areshole and thus should be laughed at if I'm wrong!)
)
 

stopher

AWF VIP
Local time
Today, 04:29
Joined
Feb 1, 2006
Messages
2,395
The original expression is improperly formed because it has an implied operator. Therefore, it has no correct answer that is a number. It might, however, be possible to derive an answer if you agree to a particular computer language's operator precedence rules.
Well it depends on the context (undefined here). In mathematics the "implication" is clear. It's quite reasonable to write x(x+1) or even 2(1+x).

Just thought I'd toss in my 2 cents' worth (or 2 pence, for our UK friends.)
The expression in the UK is "two penneth" (two pence worth). So in the US it should really be "my 3.244 cents worth" at today's exchange rate since the expression originates in the UK:p ;)
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:29
Joined
Sep 12, 2006
Messages
15,660
interesting that everyone here is coming up with 288 - my initial reaction was 2

wikipedia is interesting on all sorts of ambiguities

http://en.wikipedia.org/wiki/Ambiguity

in particular discussing the similar expression a/2b

which to use BODMAS is (a/2) * b

but would surely be more commonly evaluated as a / (2 * b)
 

Bodisathva

Registered User.
Local time
Yesterday, 23:29
Joined
Oct 4, 2005
Messages
1,274
Since I don't come around much anymore, I may as well make myself useful...(well, I suppose that's debatable) :rolleyes:

I was always taught:
Please Phone My Dear Aunt Sally -> Powers Parenthesis Multiplication Division Add Subtract
therefore, the implied multiplication precedes the division, and I'll side with Dave...2
 

Thales750

Formerly Jsanders
Local time
Yesterday, 23:29
Joined
Dec 20, 2007
Messages
2,146
This is not so much math question, as a cultural one.

If the expression was more complex it might make this easier to see.

In Latin based languages we are culturally inclined to “evaluate” information from left to right. Short of any other explicit instructions we will follow our norm.

So the implicit expectation is that the answer is 48 times 2 divided by 12. However in the world of engineering, or software design, it would be remiss indeed to allow such ambiguity to exist in a real world scenario.
 

Users who are viewing this thread

Top Bottom