Difference between revisions of "Order of Operations"

From Department of Mathematics at UTSA
Jump to navigation Jump to search
Line 5: Line 5:
 
These conventions exist to eliminate notational ambiguity, while allowing notation to be as brief as possible. Where it is desired to override the precedence conventions, or even simply to emphasize them, parentheses ( ) can be used to indicate an alternative order of operations (or to simply reinforce the default order of operations). For example, (2 + 3) × 4 = 20 forces addition to precede multiplication, while (3 + 5)2 = 64 forces addition to precede exponentiation. If multiple pairs of parentheses are required in a mathematical expression (such as in the case of nested parentheses), the parentheses may be replaced by brackets or braces to avoid confusion, as in [2 × (3 + 4)] − 5 = 9.
 
These conventions exist to eliminate notational ambiguity, while allowing notation to be as brief as possible. Where it is desired to override the precedence conventions, or even simply to emphasize them, parentheses ( ) can be used to indicate an alternative order of operations (or to simply reinforce the default order of operations). For example, (2 + 3) × 4 = 20 forces addition to precede multiplication, while (3 + 5)2 = 64 forces addition to precede exponentiation. If multiple pairs of parentheses are required in a mathematical expression (such as in the case of nested parentheses), the parentheses may be replaced by brackets or braces to avoid confusion, as in [2 × (3 + 4)] − 5 = 9.
  
A common acronym used to memorize the order of operations is "PEMDAS": parentheses, exponents, multiplication and division, and addition and subtraction.
+
==Definition==
 +
The order of operations, which is used throughout mathematics, science, technology and many computer [[programming language]]s, is expressed here:
 +
# parentheses
 +
# exponentiation and root extraction
 +
# multiplication and division
 +
# addition and subtraction
 +
 
 +
This means that if, in a mathematical expression, a subexpression appears between two [[Operator (programming)|operators]], the operator that is higher in the above list should be applied first. Expressions in parentheses take precedence over expressions outside of them (for example, (3 + 4) × 7 = 7 × 7 = 49, and not 3 + 4 × 7 = 3 + 28 = 31, despite the fact that multiplication takes precedence over addition). Within a single set of parentheses, the normal order of operations applies.
 +
 
 +
The commutative property and associative property laws of addition and multiplication allow adding terms in any order, and multiplying factors in any order—but mixed operations must obey the standard order of operations.
 +
 
 +
In some contexts, it is helpful to replace a division by multiplication by the reciprocal (multiplicative inverse) and a subtraction by addition of the opposite (additive inverse). For example, in computer algebra, this allows one to handle fewer binary operations, and makes it easier to use commutativity and associativity when simplifying large expressions. Thus 3 ÷ 4 = 3 × (1/4); in other words, the quotient of 3 and 4 equals the product of 3 and 1/4. Also 3 − 4 = 3 + (−4); in other words the difference of 3 and 4 equals the sum of 3 and −4. Thus, 1 − 3 + 7 can be thought of as the sum of 1 + (−3) + 7, and the three summands may be added in any order, in all cases giving 5 as the result.
 +
 
 +
A common acronym used to memorize the order of operations is "PEMDAS": parentheses, exponents (which includes calculating roots), multiplication and division, and addition and subtraction.
  
 
==Resources and Examples==
 
==Resources and Examples==

Revision as of 12:08, 14 September 2021

In mathematics and computer programming, the order of operations (or operator precedence) is a collection of rules that reflect conventions about which procedures to perform first in order to evaluate a given mathematical expression.

For example, in mathematics and most computer languages, multiplication is granted a higher precedence than addition, and it has been this way since the introduction of modern algebraic notation. Thus, the expression 1 + 2 × 3 is interpreted to have the value 1 + (2 × 3) = 7, and not (1 + 2) × 3 = 9. When exponents were introduced in the 16th and 17th centuries, they were given precedence over both addition and multiplication, and could be placed only as a superscript to the right of their base.[1] Thus 3 + 52 = 28 and 3 × 52 = 75.

These conventions exist to eliminate notational ambiguity, while allowing notation to be as brief as possible. Where it is desired to override the precedence conventions, or even simply to emphasize them, parentheses ( ) can be used to indicate an alternative order of operations (or to simply reinforce the default order of operations). For example, (2 + 3) × 4 = 20 forces addition to precede multiplication, while (3 + 5)2 = 64 forces addition to precede exponentiation. If multiple pairs of parentheses are required in a mathematical expression (such as in the case of nested parentheses), the parentheses may be replaced by brackets or braces to avoid confusion, as in [2 × (3 + 4)] − 5 = 9.

Definition

The order of operations, which is used throughout mathematics, science, technology and many computer programming languages, is expressed here:

  1. parentheses
  2. exponentiation and root extraction
  3. multiplication and division
  4. addition and subtraction

This means that if, in a mathematical expression, a subexpression appears between two operators, the operator that is higher in the above list should be applied first. Expressions in parentheses take precedence over expressions outside of them (for example, (3 + 4) × 7 = 7 × 7 = 49, and not 3 + 4 × 7 = 3 + 28 = 31, despite the fact that multiplication takes precedence over addition). Within a single set of parentheses, the normal order of operations applies.

The commutative property and associative property laws of addition and multiplication allow adding terms in any order, and multiplying factors in any order—but mixed operations must obey the standard order of operations.

In some contexts, it is helpful to replace a division by multiplication by the reciprocal (multiplicative inverse) and a subtraction by addition of the opposite (additive inverse). For example, in computer algebra, this allows one to handle fewer binary operations, and makes it easier to use commutativity and associativity when simplifying large expressions. Thus 3 ÷ 4 = 3 × (1/4); in other words, the quotient of 3 and 4 equals the product of 3 and 1/4. Also 3 − 4 = 3 + (−4); in other words the difference of 3 and 4 equals the sum of 3 and −4. Thus, 1 − 3 + 7 can be thought of as the sum of 1 + (−3) + 7, and the three summands may be added in any order, in all cases giving 5 as the result.

A common acronym used to memorize the order of operations is "PEMDAS": parentheses, exponents (which includes calculating roots), multiplication and division, and addition and subtraction.

Resources and Examples