The order of operations, or precedence, is expressed in the following chart.
In the absence of parentheses, horizontal fraction lines, a bar over a radicand, or other symbols of grouping, do all exponents and roots first. Stacked exponents must be done from the top down. After taking all exponents and roots, then do all multiplication and division. Finally, do all addition and subtraction.
It is helpful to treat division as multiplication by the reciprocal and subtraction as addition of the opposite. Thus 3/4 = 3 ÷ 4 = 3 • ¼ and −4 + 3 is the sum of negative four and positive three.
If an expression involves parentheses, then do the arithmetic inside the innermost pair of parentheses first and work outward, or use the distributive law to remove parentheses. Root symbols have a bar (called vinculum) over the radicand which acts as a symbol of grouping: . A horizontal fractional line also acts as a symbol of grouping: .
The order in which the unary operator − (usually read "minus") acts is often problematical. In written or printed mathematics, , but in some applications and programming languages, notably the application Microsoft Office Excel and the programming language bc, unary operators have a higher priority than binary operators, that is, the unary minus (negation) has higher precedence than exponentiation, so in those languages , .
In the UK, Australia, New Zealand and South Africa, the acronym BODMAS is commonly used for Brackets, Order, Division, Multiplication, Addition, Subtraction. Since multiplication and division are of the same rank, this is sometimes written as BOMDAS, BIDMAS or BIMDAS where I stands for Indices.
Warning: Multiplication and division are of equal precedence, and addition and subtraction are of equal precedence. Using any of the above rules in the order addition first, subtraction afterward would give the wrong answer to
The correct answer is 9, which is best understood by thinking of the problem as the sum of positive ten, negative three, and positive two.
It is usual, wherever one needs to calculate operations of equal precedence to work from left to right. The following rules of thumb are useful:
First: perform any calculations inside parentheses (brackets)
Second: Next perform all multiplication and division, working from left to right
Third: Lastly perform all addition and subtraction, working from left to right
is much easier when worked from right to left, where here the answer is 34.
When restricted to using a straight text editor, parentheses (or more generally "grouping symbols") must be used generously to make up for the lack of graphics, like square root symbols. Here are some rules for doing so:
1) Whenever there is a fraction formed with a slash, put the numerator (the number on top of the fraction) in one set of parentheses, and the denominator (the number on the bottom of the fraction) in another set of parentheses. This is not required for fractions formed with underlines:
2) Whenever there is an exponent using the caret (^) symbol, put the base in one set of parentheses, and the exponent in another set of parentheses:
3) Whenever there is a trig function, put the argument of the function, typically shown in bold and/or italics, in parentheses:
4) The rule for trig functions also applies to any other function, such as square root. That is, the argument of the function should be contained in parentheses:
5) An exception to the rules requiring parentheses applies when only one character is present. While correct either way, it is more readable if parentheses around a single character are omitted:
Calculators generally require parentheses around the argument of any function. Printed or handwritten expressions sometimes omit the parentheses, provided the argument is a single character. Thus, a calculator or computer program requires:
while a printed text may have:
6) Whenever anything can be interpreted multiple ways, put the part to be done first in parentheses, to make it clear.
7) One may alternate use of the different grouping symbols (parentheses, brackets, and braces) to make expressions more readable. For example:
is more readable than:
Note that certain applications, like computer programming, will restrict one to certain grouping symbols.
In the case of a factorial in an expression, it is evaluated before exponents and roots, unless grouping symbols dictate otherwise. When new operations are defined, they are generally presumed to take precedence over other operations, unless overridden by grouping symbols.
Sometimes a dash or a heavy dot is used as a multiplication sign which has higher precedence than division. For example
are all equivalent.
Different calculators follow different orders of operations. Cheaper calculators without a stack work left to right without any priority given to different operators, for example giving
The "cheap" calculator expects two operands and an operator. When the next operator is pressed, the expression is immediately evaluated and the answer becomes the left hand of the next operator. Advanced calculators allow entry of the whole expression, grouped as necessary, and only evaluates when the user uses the equals sign.
Calculators may associate exponents to the left or to the right depending on the model. For example, the expression on the TI-92 and TI-30XII (both Texas Instruments calculators) associates two different ways:
The TI-92 associates to the right, that is
whereas, the TI-30XII associates to the left, that is
An expression like 1/2x is interpreted as 1/(2x) by TI-82, but as (1/2)x by TI-83. While the first interpretation may be expected by some users, only the latter is in agreement with the standard rules stated above.
Many programming languages use precedence levels that conform to the order commonly used in mathematics, though some, such as APL, have no operator precedence rules (in APL evaluation is strictly right to left).
The logical bitwise operators in C (and all programming languages that borrowed precedence rules from C, for example, C++, Perl and PHP) have a precedence level that the author of the language considers to be less than ideal. The relative precedence levels of operators found in many C-style languages is as follows:
|1|| -> . ::||Grouping, scope, array/member access|
|2||! ~ - + * & sizeof type cast||(most) unary operations, sizeof and type casts|
|3||* / %||Multiplication, division, modulo|
|4||+ -||Addition and subtraction|
|5||<< >>||Bitwise shift left and right|
|6||< <= > >=||Comparisons: less-than, ...|
|7||== !=||Comparisons: equal and not equal|
|9||^||Bitwise exclusive OR|
|10|||||Bitwise inclusive (normal) OR|
|13||?:||-||14||= += -= *= /= %= &= |= ^= <<= >>=||Assignment operators|
Wipo Publishes Patent of Microsoft for "Graphical Representation of an Order of Operations" (American Inventor)
Aug 06, 2013; GENEVA, Aug. 6 -- Publication No. WO/2013/112388 was published on Aug. 1.Title of the invention: "GRAPHICAL REPRESENTATION OF AN...
US Patent Issued to International Business Machines on Feb. 15 for "System and Computer Program Product for Dynamic Queue Splitting for Maximizing Throughput of Queue Based Operations While Maintaining Per-Destination Order of Operations" (Massachusetts Inventor)
Feb 17, 2011; ALEXANDRIA, Va., Feb. 17 -- United States Patent no. 7,890,674, issued on Feb. 15, was assigned to International Business...
MyScript Calculator: Easy to Figure out (Posted 2013-07-28 14:29:59) ; MyScript Calculator Offers the Option of Just Scribbling Down Your Equations Rather Than Trying to Remember How, Exactly, to Use the Order of Operations
Jul 28, 2013; MyScript CalculatorHaving trouble figuring out the tip on that bill or the discount on that shirt? Getting frustrated fiddling...