
3 caculators = 3 different answers to one math problem - msredmond
http://www.mathmagical.co.uk/Mathematics/CalcPuz.html
======
mrgoldenbrown
1 ambiguous notation, 3 different interpretations. The Casios both have
reasonable interpretations, but the iPhone should probably give some kind of
warning that it is about to ignore entire numbers.

~~~
jetti
How is that ambiguous? PEMDAS and since multiplication and division have the
same rank, you go left to right. Pretty clear if the calculators follow the
basic order of operations.

~~~
baddox
All infix notations (without sufficient parentheses) require an agreement
(implicit or explicit) among all concerned parties. This is nothing new. The
same ambiguity occurs with the unary negation operator, as in -5^2.

While I wouldn't choose it, I don't think it's entirely unreasonable to give
the "multiplication by juxtaposition" operator greater precedence than the
normal multiplication and division operators.

~~~
uiri
If you write the expression as a fraction without anything beside it being
multiplied, it is ambiguous as to whether (1+2) ought to go above or below the
fraction bar. The fact that parentheses/brackets ought to be resolved before
anything else complicates things because 6/2 * 3 could reasonably be
interpreted either way. An unambiguous way to write it would be either as
(6/2) * 3 or as 6/(2*3).

------
xamuel
Math PhD student here. The issue is that people are confusing two symbols
which are distinct: the solidus (/) and the obelus (÷). The latter is rather
obsolete and it's not clear why exactly calculators use it. Anyway, this blog
post clears up the issue better than I could hope to in a comment:
[http://www.matthewcompher.com/posts/trouble-with-
semantics-t...](http://www.matthewcompher.com/posts/trouble-with-semantics-
the-obelus-or-division-symbol-%C3%B7/)

~~~
batista
No, this is not the problem in this case at all. Read the article. Besides,
both calculators use the obelus, and still give different results.

------
cytzol
Mentally, I perform no-written-operator multiplication first, then anything
else, so I can see why the calculators (and WolframAlpha, in some cases) are
getting the intention wrong:

"6 ÷ 2x" gets parsed as "6 / (2 * x)"

"6 ÷ 2 * x" gets parsed as "(6 / 2) * x"

All that's done in the equation in the article is having a pair of brackets
instead of a variable, but the result is the same to my brain.

~~~
merijnv
> "6 ÷ 2x" gets parsed as "6 / (2 * x)"

Edit: I'm probably wrong about precedence for 2x, which should be stronger.
Which would leave 2(1+2) still really ambiguous. I guess the true lesson here
is to always parenthesize explicitly or use over/under notation,

But this is wrong! Division and multiplication have the same precedence and
left-to-right application order!

Hence, "6 ÷ 2x" should be parsed as "(6 ÷ 2) * x", which I admit is a bit
confusing, so you probably should write out either the parenthesis or the
multiplication. But, just because the notation is confusing doesn't mean the
rules no longer apply.

~~~
chc
But this makes almost everybody wrong. Going by this, you would evaluate 6x ÷
2x to 3(x^2) rather than 3. That is clearly not the intention, so _somebody_
is wrong here, but it's a matter of opinion whether it's the writer (for not
precisely following standard notation) or the standard notation (for being
counterintuitive) that deserves the blame.

~~~
droithomme
Yes, this is correct and is the reason why I set implicit multiplication to a
higher precedence in the calculators I've written. Obviously not everyone
agrees though, but it's certainly the way it's always been interpreted in
written algebra textbooks. Precedence rules are essentially arbitrary. We have
to make them up. Going by most common historical use is a reasonable choice.

------
snitzr
RPN (Reverse Polish Notation) gets things done on a calculator. This article
shows one reason why it's not just for finance.

~~~
kstrauser
You beat me to it. Enter one of

    
    
        6 [enter] 2 [enter] 1 [enter] 2 + * /
    

or

    
    
        6 [enter] 2 / 1 [enter] 2 + *
    

depending on how you prioritize the implicit *, and never have to wonder how
your calculator might interpret the input.

~~~
michaelcampbell
> depending on how you prioritize the implicit *,

I believe this is the crux if the issue, RPN notwithstanding.

------
Rust
I enjoyed the bit at the end where the writer managed to use the wrong (IMO)
formula to arrive at the correct answer.

Using BEDMAS as I was taught, so many moons ago:

6 ÷ 2 ( 1 + 2 )

6 ÷ 2 ( 3 )

6 ÷ 2 * 3 // because 2(3) is not an exponent or algebraic construct, it's
straight multiplication

3 * 3 // division and multiplication are in left-to-right order, no precedence

9

~~~
Rust
Update: after reading the article at
[http://www.matthewcompher.com/posts/trouble-with-
semantics-t...](http://www.matthewcompher.com/posts/trouble-with-semantics-
the-obelus-or-division-symbol-%C3%B7/) , the writer used the ÷ as a line
operator, not a natural division operation.

I would maintain that since this is not taught in any school I've ever
attended, it is at least questionable. I've never seen a math textbook use the
/ symbol for natural division either.

~~~
falling
I never knew about the distinction either. But if interpreted that way

    
    
        6 ÷ 2 (1 + 2)
    

should then translate to

    
    
        6 / (2 * (1 + 2)) = 1
    

I guess this only reaffirms the fact that the expression is ambiguous.

------
ghshephard
In Microsoft Excel we get:

"Microsoft Excel found an error in your formula you entered. Do you want to
accept the correction proposed below?"

=6/2*(1+2)

Which then gives 9.

------
kylec
Hm, Calcbot on the iPhone also returns 2 if entered without a multiplication
after the first "2". Hitting the open parenthesis key removes the "2" from the
calculation. Since Calcbot displays what you've entered below the answer, it's
easy to see the mistake with a trivial calculation like this, but if you're
not watching for it it's easy to miss. Better than the built-in calculator and
PCalc, which provide no feedback and give the wrong answer, but surprising.

------
trjordan
OK, I get the first two. Strictly speaking, mult and div have the same
precedence (6 / 2 * 3 should be the same as 6 * 3 / 2 , both 9), but in one
case, the calculator interpreted the multiplication in 2(1+2) as having higher
precedence than 2*(1+2). Arguably a bug, but nothing crazy.

But ... the iPhone gives 2? I don't get it.

(FWIW, Android says 9)

~~~
ricardobeat
The iPhone ignores any input before opening a group if you don't give it an
operator.

 _5(2) = 2

999(2+2) = 4_

~~~
nsns
So it should have given 3.

~~~
Someone
'before…within the term or factor":

    
    
      2*2455(6) = 12
      2+47435)7 = 14
    

(according to the iPhone calculator in scientific mode)

~~~
ColinDabritz
I'm guessing you meant: 7+47435)7 = 14 for the second example?

I get 9 as written on my iPhone. The correction above gives 14.

The interesting thing to me is that the close parenthesis cause the same
behavior. The consistent logic appears to be "an operator entered in error
causes input to reset" or something like that. Also errors are silently
ignored in the easiest way possible, perhaps internally the value never gets
pushed to the stack or something along those lines.

I wonder what other 'errors' could show this behavior?

------
rometest
when i was a kid, i was told to use the BODMAS rule i.e Brackets, Orders,
Division or Multiply, Addition or Substraction

After you have done "B" and "O", just go from left to right doing any "D" or
"M" as you find them.

Then go from left to right doing any "A" or "S" as you find them.

~~~
alexchamberlain
I was taught the same, but with strict precedence - division comes first.
Having said that, a mathematician would never write those down anyway, as it's
too confusing.

------
anonymous
Multiplication and division have the same precedence, so you do them left-to-
right as written. Like addition and substitution.

Or better yet, realise that writing it all on one line is stupid and
ambiguous, and write properly.

------
nraynaud
to me, elided multiplication has a higher precedence than the explicit one
(and by transitivity, than the explicit division), but I don't remember in
which grammar I read that (mathematica, matlab ?).

------
jonsen
In WolframAlpha 6÷2(1+2) gives 9 but 6÷2x with x=(1+2) gives 1.

~~~
Rust
I might be remembering incorrectly, but 2x and 2(x) are totally different
things in algebra.

2x would be expanded as (2 * x), whereas 2(x) expands as 2 * x.

In this case, since the equation is 2(1+2) which results in 2(3), it's final
DMAS form is 6 ÷ 2 * 3 = 9, instead of 6 ÷ ( 2 * 3 ) = 1

------
ernesth
I would have expected an answer of 3 as 2(1+2) cannot mean anything else than
applying the constant function 2 to the sum.

------
joejohnson
Anyone have a guess to how the iPhone calculator computed 2?

~~~
martingordon
It seems that pushing "(" doesn't push the entered value onto the stack, even
though it's still visible on the screen. "6 / 2 (2 + 1)" becomes "6 / (2 +
1)".

~~~
pacaro
The calculator on WP7 does the same thing, but is a little more explicit - it
shows the current expression as it is being built, so you see that while the
first 2 was entered, the final expression is 6 ÷ (2 + 1)

------
hcarvalhoalves
...about time we start teaching prefix notation on schools.

------
thekungfuman
I'm happy to say my mental math and my phone's (Nexus S) math get 9.

