Order of Operations and Simple Nesting
Basic Order of Operations
Latin script as used in all Western languages, is read and written from left to right. Thus it is not surprising that both mathematics and logic are also solved from left to right unless certain operators have priority or unless otherwise specified. Logical operators are all equal in priority unless otherwise specified:
1 Or 2 And 1 Or 2 = 1
The And operator is not given priority
(which would have given 2)
2 And 1 Or 1 Or 2 = 1 The function is not solved from right to left (which would have given 2)
Note that while changing the order of operations can give a different result, this is not always the case!
Nesting is a method designed to give certain functions priority within the overall expression when the standard order of operations does not accurately fit the expression to the situation that it is being used to model.
The use of brackets asserts that the functions inside the brackets have priority over those outside the brackets and must be solved in the appropriate order. brackets are a useful tool for relating complex functions to the structure of real world problems. The left to right order of operations still remains when brackets are present, although it is subordinate to the priority assigned to the functions inside the brackets.
1 Or (1 And 2) = 1
If the brackets are ignored, the function gets an
incorrect value of 2
2 Or (1 Or (1 And 2) And 1) = 1 If the brackets are ignored, the function gets an incorrect value of 2
Nesting is the key to expressing context in logical equations, and contextual complexity defines the number of dimensions the system defined by the equation has.