## Why Divide does not give the same answer?

3

I saw a question on Facebook $$8\div2 (2 + 2)=?$$

Consider these inputs.

Divide[8, 2 (2 + 2)]


1

$$8\div2 (2 + 2)$$ using esc+div+esc

16

Why the results are different.

I also tried these entries.

8/2 (2 + 2)


16

8/(2 (2 + 2))


1

Precedence /@ {Plus, Subtract, Times, Divide}


{310., 310., 400., 470.}

Question was closed 2019-08-01T23:34:24.203

Try using Trace[] to see how the evaluation is performed. – Anjan Kumar – 2019-08-01T14:58:29.173

Is Mathematica just following the usual order of operations: https://en.m.wikipedia.org/wiki/Order_of_operations ?

– JimB – 2019-08-01T15:02:49.177

@OkkesDulgerci The arguments to Divide are treated as if you had parenthesis around each one. There is no spilling from denominator to numerator because of operator precedence like you can have when you are writing / as infix operator. – Thies Heidecke – 2019-08-01T15:08:42.497

Then question is how should enter to find out the question? – OkkesDulgerci – 2019-08-01T15:11:06.670

1The answer to the question should be "It is X if I follow these rules, and Y if I follow these rules." It would be nice if that is what the Facebook poster is after. But my bias is that it is not an attempt at enlightenment. – JimB – 2019-08-01T15:20:13.047

1

"There is no Supreme Court for mathematical notation; there were no commandments handed down on Sinai concerning operational precedence; all there is, is convention, and different people are free to adhere to different conventions. Wise people will stick in enough parentheses to make it impossible for anyone to mistake the meaning. If they mean, (48÷2)(9+3), they'll write it that way; if they mean 48÷(2(9+3)), they'll write it that way." - from here.

– J. M.'s ennui – 2019-08-02T08:02:52.787

7

First, since the precedence of Divide is higher than Times, you should expect to parse 8 ÷ 2(2+2) as:

Divide[8, 2] (2+2)


You can also verify this by entering the input into a cell and using Cell | Show Expression to see what the boxes look like. The rendered version:

8 ÷ 2 (2 + 2)

and the version after using Cell | Show Expression:

Cell[BoxData[ RowBox[{ RowBox[{"8", "\[Divide]", "2"}], RowBox[{"(", RowBox[{"2", "+", "2"}], ")"}]}]], "Input", CellLabel->"In[353]:="]

The boxes show that 8 ÷ 2 (with the boxes RowBox[{"8" "\[Divide]", "2"}]) is being multiplied by 2 + 2 (with the boxes RowBox[{"2", "+", "2"}]).

1Also FullForm[Hold[8/2 (2 + 2)]] might be easier to understand than "show expression" – Gustavo Delfino – 2019-08-01T18:36:10.733

Thanks. This clears things a bit. But my main concern was, on help page for Divide it says you can use esc+div+esc for shorthand $\div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't. – OkkesDulgerci – 2019-08-01T22:58:14.040