Comments on the original post indicate that if you do 6/7(1+2) then you get 2 as well and the iPhone is just throwing away whatever digit is in the position of the 7.
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)".
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)
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.
I don't like calling one interpretation of an ambiguous notation a bug but not the other. Either they are both possible bugs or neither are. The ambiguity comes in when we try to apply rules we learned for encoding (handwritten notation) to another encoding scheme (the calculator). Handwritten math uses positional information to encode order of operations. Calculator math can either try to mimic this (like one Casio did) or ignore this and revert to strict "all multiply and divide operations have equal precedence" (which the other Casio did)
Fractions and exponents are other areas where handwritten notation and calculator notation don't overlap very well.
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?
6
6%
6%2
6%(
At this point the 2 (or any value in that slot) has been dropped
6%(1
6%(1+
6%(1+2
6%(1+2)
and the result is processed in this order:
6%(3)
6%3
2
giving the result.
It appears what most people are objecting to is that it performs an unexpected operation when it discards the value at 2 (because opening the parenthesis without giving 2 an operator has been designed to be 'invalid') but it does NOT indicate this in ANY way.
It is also interesting to note that all of his other examples had the entire formula written out, where the iPhone did not. If it had, it would have been more clear when the 2 was dropped.
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.
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.
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.
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).
I don't think it's ambiguous in the least. Sure, if I were programming I would add another set of parentheses and the implied * symbol so that it's crystal clear and more reader friendly, but I would toss any calculator that gave me anything other than 6÷2(1+2)=9. I've never read or heard anywhere that an implied * symbol has higher priority than an explicit one. But if that is a reasonable interpretation, Casio has a responsibility to give consistent results across it's entire calculator line.
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.
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.
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.
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.
Why does the multiplication in "2x" have the same precedence as in "2 * x"? The previous poster is saying that the no-operator version binds stronger than the versions with operations. I agree that the no-symbol version has different rules than the explicit symbol.
Consider the expression "h-bar is h over 2 pi". That's "h = h/2p", and is definitely not the same as "(h/2) * p". This is because of the convention that you write the numerator terms and then the denominator terms. That is, if you wanted "h/2 * p" then you would tend to write it hp/2.
As another example, consider Schrödinger's equation, with (-h²/2m) * ?(r, t). There too the 'm' is well-understood as being in the denominator.
Exactly. This whole thing seems extremely artificial to me; notation is fluid and ambiguous, despite what elementary-school teachers may say. If you're calculating something, you can use whatever rules you want, and if you're reading some else's work, you can complain if they're being ambiguous.
My intuitions (astrophysics/finance background) say multiplication-by-juxtaposition is higher-precedence than multiplication-by-symbol, so "x/y(1+y)" would be "x/(y(1+y))"; interpreting it as "(x/y)(1+y)" seems wrong.
Then again, "x/y*(1+y)" already looks wrong. The solidus is too powerful. I'd write "(x/y)(1+y)" explicitly.
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.
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.
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...
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.
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 ?).
reply