Abstract: even in mathematics, ambiguities can be hard to spot. The phenomenon seen here in arithmetic goes beyond the usual PEMDAS rule and illustrates an ambiguity which can lead to heated arguments and discussions. |
"The problem 2x/3y-1 with x=9 and y=2 was actually posed for a 5th grade homework question and it is interesting how much debate has occurred between our parents. The students who had help from parents had the answer of 2. The teacher explained that the correct answer was 11." |
x=9; y=2; (2x/3)y-1 gives 11 2x/(3y)-1 gives 2It is not clear what the textbook had intended with the 3y. As written, it can be interpreted both ways. Yes, one could argue that without brackets the given order matters. One can however also argue that "3y" is a unit which belongs together. So, everybody is right and that the textbook problem has just been unclear."
x/3x 2 x Out[1]= -- 3 x/(3x) 1 Out[2]= - 3The computer has chosen to do the division first. This is natural if one looks as division and multiplication as operations on the same level. To play the devils advocate, note however that the famous PEMDAS (parenthesis, exponents, multiplication, division, addition and subtraction) has the M before the D so that we would have to accept the second one ...
gives both 10/3. Try it out. Funny by the way (and totally unrelated to the topic discussed here) that the results are different
3.333333333333333 3.3333333333333335illustrating that computers do not honor basic laws of arithmetic. The mathematics of rounding error arithmetic is subtle. My PhD advisor Oscar Lanford knew much about this. By the way, also Mathematica adhers to BEDMAS and does division before multiplication. It is in line with Excel and javascript as probably most programming languages like Perl.
3+4-3 = (3+4)-3 = 3+(4-3)This is called associativity. But already this is trickier if one tries to modify this because
3-4+3 = (3-4)+3 = 3-(4+3)How come, associativity does not hold here? You find out. Since the logarithm gives an isomorphism between the group (R,+) and (R -{0}, *), where * is multiplication, we also have ambiguities in the multiplicative case evenso the multiplicative group (R-{0},*) is by definition associative. But it is the role of the division which must be made clear:
12/(3*2) = 2 (12/3)*2 = 8gives different answers. This can not be discovered well in algebra situations like
12/3xwhich is ambiguous. Both of the following expressions are clear, but give different results:
12/(3*x) = 4/x (12/3)*x = 4xThis is also often a source of error in addition, as the minus sign has to be carried through:
3-4+3 (3-4)+3 = 2 3-(4+3) = -5It is this case which makes the argument that the bracket should be placed to the left. The additive case is also a reason which seduces not to write the brackets in the multiplicative case. It always leads to trouble.
x/x/x ?We again have two interpretations
(x/x)/x = 1/x x/(x/x) = xBut since now, we have only divisions and no multiplication, it is even less clear what comes first. When dealing with fractions, we often make this clear by the size of the division lines
x ----- x = x - xIt has become clear that we first do the division with the smaller division line and
x - x = 1/x ---- xWhat does Mathematica do? Lets look and enter
2/100/2
2/(100/2) = 1/25 (2/100)/2 = 1/100Mathematica choses the second choice (as does javascript). It makes the first division first.
3^3^3 ?Again we have an ambiguity with two cases:
(3^3)^3 = 19683 3^(3^3) = 7625597484987Leaving out the brackets invites trouble. Yes, one could argue that the first example is more natural, but then, a printed version of a textbook might have the third 3 smaller so that the reader is seduced to first compute 3^3 and put that into the exponent, producing a much larger number. In the following example, this is even less clear what the writer intends because expressions like 10^{2} are often treated together as we write 10^{6} for a million. The 10^{6} has become a unit: so, if we write
2^10^2which of the two answers
(2^10)^2 = 1048576 2^(10^2) = 1267650600228229401496703205376is correct? Maybe we should ask our professional computer algebra system again. Mathematica 9.0 gives the second choice, if 2^10^2 is entered!
For (a/b/c) the algebra system starts evaluating from the left, while for (a^b^c) it starts evaluating from the right. |
There is only one solution: write the parenthesis. |
256 // Sqrt // Exp // Floor // PrimeQwhich takes the square root of 256, then exponentiates it, take the integer part and then answers the question whether this is prime. It is equivalent to
PrimeQ[Floor[Exp[Sqrt[256]]]]but avoids the brackets. I use the first way often when computing interactively, while the second one when writing code like the following which looks for the statistics of primes in a subexponential sequence of integers:
F[n_]:=Floor[Exp[Sqrt[n]]]; s=Table[If[PrimeQ[F[n]],1,0],{n,1000}]; G[n_]:=Sum[s[[k]],{k,n}]*Log[n]/n; ListPlot[Table[G[n],{n,Length[s]}],PlotRange->{0,1}]If you are curious: here is the Plot.
"Internet rumors claim the American Mathematical Society has written "multiplication indicated by juxtaposition is carried out before division," but no original AMS source exists online anymore (if it ever did). Still, some early math textbooks also taught students to do all multiplications and then all divisions, but most, such as this 1907 high-school algebra textbook, this 1910 textbook, and this 1912 textbook, recommended performing all multiplications and divisions in the order they appear first, followed by additions and subtractions. (This convention makes sense as well with the Canadian and British versions of PEMDAS, such as BEDMAS, BIDMAS, and BODMAS, which all list division before multiplication in the acronym.) The most sensible advice, in a 1917 edition of Mathematical Gazette, recommended using parentheses to avoid ambiguity. (Duh!) But even noted math historian Florian Cajori wrote in A History of Mathematical Notations in 1928-29, "If an arithmetical or algebraical term contains / and x, there is at present no agreement as to which sign shall be used first."The article has links to sources of textbooks. Here is entry 242 in Florian Cajoris book "A history of mathematical notation" (page 274), which is mentioned in that quote
1+2x3 = 9 Microsoft calculator in standard view 1+2x3 = 7 Microsoft calculator in programmers viewIt shows that the same vendor, in a framework where no ambiguity exists (nobody has ever questioned that multiplication should go before addition), an ambiguity in the same product. An other example from that article mentions Texas Instruments calculators
1/2x = 1/(2x) in TI-82 calculator 1/2x = (1/2)x in TI-83 calculatorSelfproclaimed rules like this are hardly helpful.
PEMDAS | BEDMAS | PE(MD)AS | |
6/2*(1+2) | 1 | 9 | 9 |
(1+2)*6/2 | 9 | 9 | 9 |
How on earth can you say it is ambiguous when it is AXIOMATIC that multiplication and division are inverse operations? How can you say it is ambiguous when ANY division can be expressed as multiplication by the reciprocal? Shame on you for perpetuating bullshit. |
Dear ..., you probably refer to http://www.math.harvard.edu/~knill/pedagogy/ambiguity/ It is not about whether the division is the inverse of multiplication. That is the definition. This is not where the ambiguity is. It is that the notation is ambiguous (and experience shows that that it is a source for errors and misunderstandings). For example, if we write x/3x, then many humans understand the result as x/(3x) which is 1/3. If you give it to a machine, then it gives the result x/3x =x^2/3. Now, the question is whether there is a definite rule which tells, what is right. The PEMDAS rule, clearly puts multiplication before division so that x/3x = x/(3x) = 1/3. Most humans follow the PEMDAS rule. Because they have been taught so. There is also the BEDMAS rule in which the division comes before multiplication. In that case the result would be x^2/3. Now, if you look at the literature and history, then it turns out that there is no definite answer what is right. And if this is the case, we call it ambiguous. There is a camp which advocates PE(MD)AS where MD are on equal footing and where the order matters if multiplication is used together. But this makes things only more complicated as we have now three different interpretations. So if one writes such an expression like x/3x, one has to be careful and put the brackets. Everything else can produce misunderstandings. You are not the only one who feels very strong and become emotional about it. |