views:

134

answers:

6

This is probably an easy math question but what is the reason for the order of PEMDAS. I mean, why isnt' it SADMEP?

Parenthesis, Exponents, Multiplication, Division, Addition, Subtraction

Below was added because it does require knowledge of PEMDAS albeit a very basic concept it's one that I thought was more interesting in terms of why not how.

def time_left_for_reservation(terms_and_conditions_on)
   time_lapsed = (Time.now - terms_and_conditions_on)
   if (2.weeks.seconds - time_lapsed) > 1.day.seconds
      "about #{pluralize(((2.weeks.seconds - time_lapsed) / (60 * 60 * 24)).ceil, 'day')}"
   else
      "about #{pluralize(((2.weeks.seconds - time_lapsed) / (60 * 60)).ceil, 'hour')}"
   end
end
+3  A: 

Partial answer: Parenthesis were invented to be first?

Nate Zaugg
Ok, that one I got cause it's merely syntax... but the others?
Sam
Besides the parenthesis, I think the rest is just agreed upon. If you need it done differently then you make use of the ( and )
Nate Zaugg
+1  A: 

As noted previously, Parenthesis are (mostly) just syntax. For the rest, it's convention, more than anything else. Mathemeticians needed a standard way to describe their mathematical formulae.

In its way, PEMDAS is not actually a mathematical concept, it's a way of understanding and communicating mathematical concepts.

AllenG
Ok, that makes more sense
Sam
+2  A: 

I'l go for the more philisophical answer today: Why not PEMDAS?

Justin Niessner
I guess that is the whole point, but I'm really just curious about the logic behind it.
Sam
+11  A: 

There's an asymmetry between multiplication and addition -- multiplication distributes over addition, but addition does not distribute over multiplication.

a * (b + c) = (a * b) + (a * c) 

but

a + (b * c) != (a + b) * (a + c)

Assigning higher precedence to multiplication allows the first expression to be simplified to a*b + a*c . The opposite convention would be a perverse choice, because you couldn't omit the parentheses, and then your programs would start looking like Lisp code, no matter what language they were written in. (Lisp programmers...I kid, I kid!)

Jim Lewis
Finally got some substance.
Sam
+1 for the jab at lisp.
Alex Bliskovsky
+2  A: 

As previously stated, the whole point of parenthisis is to have highest precedence. The order of the actual operators is mostly just convention, but probably originates in polynomial notation:

a2x2 + a1x1 + a0x0

a2x2 + a1x + a0

(a2 * x2) + (a1 * x) + a0

( a2 * (x ** 2) ) + (a1 * x) + a0

(It might be worth noting that the index operator (C's a[i], "ai" in the above) has even higher precedence than exponentiation.)

David X
+2  A: 

Its a somewhat arbitrary ordering designed to make the syntax of expressions unambiguous.I believe that its one of many possible orderings that solves the issue. But we need a convention so that we can unambiguously communicate expressions.

The need for an ordering is tied to our preference for infix operator expressions ( 3 + 5 ), rather than prefix operator expressions (+ 3 5) or postfix operator expressions (3 5 + ). Both prefix and postfix are unambiguous and do not require any operator precedence or parentheses.

The language having parentheses is a consequence of infix expressions requiring precedence.

Now why that particular ordering was chosen is not clear to me - important points are

  1. parenthesis is clearly must be first as it is used to override other precedences.
  2. It "feels right" to put operators and their inverse next to each other so that implies adddition and subtraction should be next to each other, and multiplication and division should be next to each other.
  3. Again it "feels right" that symmetric operators ( + * ) have higher precedence than assymteric operators ( -, / )
  4. I believe that exponentiation was given higher precedence in an attempt to reduce the total number of parenthesis required.

I suspect that historic and chance factors have also played a big role in determining this convention

Michael Anderson
didn't think about the exponents reducing the need for parenthesis so +1 for that
Sam