The Student Room Group

Order of execution

BODMAS (BIDMAS) depending if you want to use the term order or indices, is the general rule that is applied in calculations.

For example, a + b x c is calculated as follows:

Step 1. b x c (= d, say)
Step 2. a + d

This is the accepted rule and there is no ambiguity.

However, recently I have seen this written down:

Evaluate a x b / c x d

How would one interpret that? Excel does the following:

Step 1. a x b (= e, say)
Step 2. e / c (= f, say)
Step 3. f x d

In other words, it interprets it as:

((a x b) / c) x d

Regardless of how Excel interprets it, mathematically what is the correct sequence?

Could you argue that it should be:

(a x b) / (c x d)?
(edited 9 years ago)
Original post by powwer
BODMAS (BIDMAS) depending if you want to use the term order or indices, is the general rule that is applied in calculations.

For example, a + b x c is calculated as follows:

Step 1. b x c (= d, say)
Step 2. a + d

This is the accepted rule and there is no ambiguity.

However, recently I have seen this written down:

Evaluate a x b / c x d

How would one interpret that? Excel does the following:

Step 1. a x b (= e, say)
Step 2. e / c (= f, say)
Step 3. f x d

In other words, it interprets it as:

((a x b) / c) x d

Regardless of how Excel interprets it, mathematically what is the correct sequence?

Could you argue that it should be:

(a x b) / (c x d)?



a x b / c x d means only the c is in the denominator as far as I can see

It would be written as a×bc×da \times \dfrac{b}{c} \times d

Whereas a×bc×d\dfrac{a\times b}{c\times d} would need to be (a x b)/(c x d)
Reply 2
Original post by powwer
BODMAS (BIDMAS) depending if you want to use the term order or indices, is the general rule that is applied in calculations.

For example, a + b x c is calculated as follows:

Step 1. b x c (= d, say)
Step 2. a + d

This is the accepted rule and there is no ambiguity.

However, recently I have seen this written down:

Evaluate a x b / c x d

How would one interpret that? Excel does the following:

Step 1. a x b (= e, say)
Step 2. e / c (= f, say)
Step 3. f x d

In other words, it interprets it as:

((a x b) / c) x d

Regardless of how Excel interprets it, mathematically what is the correct sequence?

Could you argue that it should be:

(a x b) / (c x d)?


Strictly speaking, Excel is perfectly correct. Multiplication and division have equal priority, so you evaluate the calculation working from left to right:
first a x b
then divide by c
then multiply by d

However, the question is really academic (no pun intended) because no sensible mathematician would ever write down something like a x b / c x d without either (a) using brackets to eliminate any ambiguity, or (b) using formatting (e.g. Latex) to make it clear how the fraction should be arranged.
Reply 3
Original post by davros
Strictly speaking, Excel is perfectly correct. Multiplication and division have equal priority, so you evaluate the calculation working from left to right:
first a x b
then divide by c
then multiply by d

However, the question is really academic (no pun intended) because no sensible mathematician would ever write down something like a x b / c x d without either (a) using brackets to eliminate any ambiguity, or (b) using formatting (e.g. Latex) to make it clear how the fraction should be arranged.


Precisely! The problem was posed by some "normal" person!

Whilst I've got your attention, mathematically what is a^b^c?

Is it (a^b)^c or a^(b^c)?

I think it's the latter, years ago read something about evaluating from right to left.

FYI, Excel does the former, ie (a^b)^c
Reply 4
Original post by powwer
Precisely! The problem was posed by some "normal" person!

Whilst I've got your attention, mathematically what is a^b^c?

Is it (a^b)^c or a^(b^c)?

I think it's the latter, years ago read something about evaluating from right to left.

FYI, Excel does the former, ie (a^b)^c


It's the latter.

If it were the former, it could immediately be simplified to abca^{bc}
Reply 5
Original post by davros
It's the latter.

If it were the former, it could immediately be simplified to abca^{bc}


So Excel's wrong!

BTW, don't understand your logic.

Just because the former can be simplified to

abca^{bc}

that doesn't explain why it can't be that.

Is there some rule about reading from right to left?
(edited 9 years ago)
Original post by powwer
So Excel's wrong!

BTW, don't understand your logic.

Just because the former can be simplified to

abca^{bc}

that doesn't explain why it can't be that.

Is there some rule about reading from right to left?


It is not about right to left

You have a to the power of something - to the power of what - to the power of b^c - so you need to do that before you can do a to it
Reply 7
Original post by powwer

BTW, don't understand your logic.

Just because the former can be simplified to

abca^{bc}

that doesn't explain why it can't be that.



It doesn't mean that it "can't", it just means that it would be inefficient to do so, because every time you saw your original expression you could replace it with the simplified version. It's just one of the ways I remember which interpretation is the correct one (the other way being what TenOfThem says).
Original post by TenOfThem
It is not about right to left

You have a to the power of something - to the power of what - to the power of b^c - so you need to do that before you can do a to it
I agree (of course) with the conclusion, but I'm not 100% convinced by the argument. Compare with:

"a^b^c: You have a to the power of something, and that something is b. Then you have a^b to the power of something, and that something is c. So a^b^c = (a^b)^c."

It's not immediately obvious to me that one argument here is better than the other, particularly if I "justify" it by saying "If your argument was valid, then surely so is this one: a-b-c = a-(b-c), because I have a minus something - minus what - minus b-c so you need to do that before you can take it away from a".

(I'm happy to be swayed on this one if you can...)

FWIW, my reasoning on this follows Davros's (to the point that I am fairly sure that if the laws of mathematics were different and a^(b^c) = a^(bc) while (a^b)^c was the interpretation that couldn't be trivially rewritten, then we would end up with the convention that a^b^c = (a^b)^c).
Original post by powwer
Precisely! The problem was posed by some "normal" person!

Whilst I've got your attention, mathematically what is a^b^c?

Is it (a^b)^c or a^(b^c)?

I think it's the latter, years ago read something about evaluating from right to left.


You're in danger of confusing two concepts, namely operator precedence and operator associativity.

You can define a precedence order for a set of operators (such as BIDMAS/BODMAS/PEMDAS/etc). Having done that, it may be that more than one operator has been assigned the same precedence, and you need to decide how to evaluate expressions containing operators of the same precedence. This problems arises in a practical context for people defining programming languages, and those who write parsers for them.

If you write, for example, "2+3-5" in certain programming languages (like C et al), the problem arises, since "+" and "-" have the same precedence, and it arises trivially if you write "10-2-2" since "-" and "-" have the same precedence.

There is no unique answer to the question of evaluation order here: you simply have to agree on an interpretation to be used. Usually, you are going to have either left, right, or no associativity e.g.

left: 10-2-2 = (10-2)-2
right: 2+3-5 = 2+(3-5)
none: a@b@c = undefined

where @ is some operator where we want to forbid expressions of that kind. Note also that sometimes the associativity doesn't matter e.g. (2+3)-5=2+(3-5)=0.

Ultimately, the choice of operator associativity is convention, and the conventions adopted by mathematicians need not be those adopted by people defining computing languages.

Quick Reply

Latest