Pemdas

I understand how to evaluate an expression via PEMDAS. But I came up with something interesting. As per PEMDAS, multiplication and division have the same precedence and should thus be evaluated from left to right. And if I violate this rule by performing multiplication before division, it can cause different results. For example if I artificially boost the precedence of multiplication as shown below the calculated value changes from 9 to 1:

6 / 2 * 3 = 9
6 / (2 * 3) = 1

So giving multiplication a higher precedence can cause a problem. However, if I instead artificially boost the precedence of division as shown below the calculated value remains the same:

2 * 3 / 6 / 2 /3 * 2 = 1
2 * (3 / 6 /2 / 3) * 2 = 1

Can anyone think of a scenario, if we always perform division with a higher precedence than multiplication (which seems to violate PEMDAS), where we can get a result that does not match PEMDAS? :grinning:

1 Like

The reason why your answers are different are because of the parenthesis, because everything that’s inside() is solved first regardless of the order of Pemdas.

@Christopher_Powell - I understand that. The parenthesis were used to simulate two scenarios that would violate PEMDAS (if evaluated that way but without the parenthesis):

  1. Forcing multiplication to take precedence over division - which can cause a different result compared to PEMDAS, which seems reasonable.

  2. Forcing division to take precedence over multiplication - which does NOT seem to cause a different result compared to PEMDAS, at least not with the limited testing I performed.

So what I am saying, is that in my testing, if I disregard PEMDAS with respect to the way multiplication and division should have equal precedence and thus be evaluated from left to right - - and instead evaluate division first, then evaluate multiplication, it seems to generate results that match PEMDAS.

I am not implying that this is problematic, just that it is an interesting observation. And I was wondering if anyone could come up with an example that when evaluating division first, then multiplication, where it would produce different results than when using equal precedence for multiplication and division, evaluating left to right, as per PEMDAS.

I might be misunderstanding what you are saying but the P in Pemdas stands for parenthesis, therefor not having, or having them can change the entire problem because of order of operations, I’m only 15 tho, maybe I’m missing something

@Christopher_Powell No worries - I may not be explaining this as clear as I want. But you are correct that the P is for parenthesis.

In my examples I am using the parenthesis to force the evaluation in two separate ways - one with the multiplication done first and one with the division done first, so I can compare if the results match what would happen using PEMDAS (without any parenthesis). And what I find is that performing multiplication first can lead to a different result than when using PEDMAS. But performing division first seems to lead to results that match PEDMAS.

1 Like

Oh I see now, nice work

Privacy & Terms