2

Let ~ be a function from R2 to R. Let x (~) y = ~(x,y). Let priority(P) be a function that maps functions (R2 to R) to integers. Set P(+) = 1, P(*) = 2, P(^)=3

An expression that follows the order of operations is an expression that evaluates subexpressions with the highest priority before evaluating any other subexpression.

An expression is well-ordered iff the expression follows the order of operations and for each subexpressions that contain a function with a priority k, the subexpressions are evaluated from left to right.

ie 4^3^2 = 262,144 contains an expression, 4^3^2, that follows the order of operations but is not well-ordered since 4^3^2 != (4^3)^2.

I couldn't find a better standard than what I saw on Wikipedia. So I don't know if there is a better standard that already exists. I've seen too many memes on reddit of 6÷2(2+1) that I thought it'd be nice to have a reference against claims that 6÷2(2+1)=1.

Michael
  • 105
  • Binary operations have both precedence and associativity direction to them. Most operations associate left-to-right $a+b+c = (a+b)+c$, but exponentiation associates right-to-left a^b^c = a^(b^c). Many computer languages have had to deal with this problem: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence – TomKern Dec 03 '21 at 05:36
  • It seems like powers are misaligned. Instead of base then exponent, it seems like it would be better if it was exponent then base. – Michael Dec 03 '21 at 06:27

0 Answers0