# Priority of parentheses and brackets in basic arithmetic.

Wolfram alpha is giving inconsistent results to this problem:

When I enter:

16÷2( 8-3(4-2) )+1 the result is 17.

When I enter:

16÷2[ 8-3(4-2) ]+1 the result is 5.

and

16÷2*[ 8-3(4-2) ]+1 brings us back to 17.

I attribute the third case to the explicit multiplication, meaning the division occurs before the 2 is distributed over the bracket. But should the first two not yield the same result?

NOTE: The original problem was intentionally ambiguous, with the purpose of showing the dangers of the ÷ operator, so lets not talk about that.

-
If your question is just about the mathematics, then it is a duplicate of this question. If it is about how Wolfram Alpha decides to evaluate expressions, it is probably better for mathematica.SE (though I think they prefer questions about Mathematica proper, not Wolfram Alpha). –  Zev Chonoles Feb 25 '12 at 16:57
@Chris Are you actually asking a question, or just making an observation about Wolfie's behavior? –  Tanner Swett Feb 25 '12 at 17:47

It has nothing to do with $÷$ at all. It is all about how Alpha interprets "$2*[..]$" vs "$2[..]$".
The square bracket means a function application. Alpha gives precedence to $f[x]$ (expression $f$ applied to expression $x$, or $f(x)$) over other arithmetic operators. But since $2$ is not a function, $2[\cdots]$ is interpreted as $(2\times \cdots)$ before the rest of the expression.
You can easily see the difference is a simpler example: $16 ÷ 2[3]$ is $$\frac{16}{2 \times 3}$$ but $16 ÷ 2*[3]$ is $$\frac{16}{2}\times 3.$$