Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
8 user(s) are online (5 user(s) are browsing encyclopedia)

Members: 0
Guests: 8

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

Order of operations

In arithmetic and elementary algebra, certain rules are used for the order in which the operations in algebraic expressions are to be evaluated. These precedence rules (which are mere notational conventions, not mathematical facts) are also used in many programming languages and by most modern Calculators. In Computing the standard algebraic notation is known as infix notation. This article assumes the reader is familiar with addition, division (mathematics), exponentiations, multiplication, and subtraction.

=The standard order of operations=

:1. Evaluate subexpressions contained within parentheses, starting with the innermost expressions. (Brackets [ ] are used here to indicate what is evaluated next.)

::(4+10/2)/9=(4+[10/2])/9=[4+5]/9=1 ,

:2. Evaluate exponential powers; for iterated powers, start from the right:

::2^{3^2}=2^{[3^2]}=[2^9]=512 ,

:3. Evaluate multiplications and divisions, starting from the left:

::8/2 imes3=[8/2] imes3=[4 imes3]=12 ,

:4. Evaluate additions and subtractions, starting from the left:

::7-2-4+1=[7-2]-4+1=[5-4]+1=[1+1]=2 ,

The expression: 2 + 3 × 4 is evaluated to 14, and not 20, because multiplication precedes addition. If the intention is to perform the addition first, parentheses must be used: (2 + 3) × 4 = 20.

In Australia and Canada, an acronym BEDMAS is often used as a mnemonic for B rackets, E xponents, D ivision, M ultiplication, A ddition, and S ubtraction.

In the United Kingdom and New Zealand, the acronym BODMAS is used for B rackets, O rders, D ivision, M ultiplication, A ddition, S ubtraction. This is sometimes written as BOMDAS , BIDMAS or BIMDAS where I stands for I ndices.

In the United States, the acronym PEMDAS (for P arentheses, E xponentiation, M ultiplication/ D ivision, A ddition/ S ubtraction) is used instead, sometimes expressed as the mnemonic P lease E xcuse M y D ear A unt S ally .

== Example ==

*Given: ::3-(5-(7+1))^2 imes(-5)+2 ,

*Evaluate the innermost subexpression (7 + 1): ::3-(5-8)^2 imes(-5)+2 ,

*Evaluate the subexpression within the remaining parentheses (5 − 8): ::3-(-3)^2 imes(-5)+2 ,

*Evaluate the power of (−3)2: ::3-9 imes(-5)+2 ,

*Evaluate the multiplication 9 × (−5): ::3-(-45)+2 ,

*Evaluate the subtraction 3 − (−45): ::48+2 ,

*Evaluate the addition 48 + 2: ::48+2=50 ,

= Proper use of parentheses and other grouping symbols =

When you are 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 numbers on top of the fraction) in one set of parentheses, and the denominator (the numbers on the bottom of the fraction) in another set of parentheses. This is not required for fractions formed with underlines:

: y = ( x +1)/( x +2)

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:

: y = ( x +1)^( x +2)

3) Whenever there is a trig function, you may put the argument of the function, typically shown in bold and/or italics, in parentheses:

: y = sin( x +1)

4) The rule for trig functions also applies to any other function, such as sqrt . That is, the argument of the function should be contained in parentheses:

: y = sqrt( x +1)

5) An exception to the rules requiring parentheses applies when only one item is present. While correct either way, it is more readable if these parentheses are omitted:

: y = (3)/( x ) or y = 3/ x

: y = (3)/(2 x ) or y = 3/(2 x )

: y = ( x )^(5) or y = x ^5

: y = (2 x )^(5) or y = (2 x )^5

: y = ( x )^(5 z ) or y = x ^(5 z )

Note that this exception does not apply to trig functions or any other function, which should use parentheses even if only one value is present:

: y = sqrt(2)

: y = tan(30)

6) Whenever anything can be interpreted multiple ways, put the part to be done first in parentheses, to make it clear.

7) You may alternate use of the different grouping symbols (parentheses, braces, and brackets) to make it more readable. For example:

: y = { 2 / [ 3 / ( 4 / 5 ) ] }

is more readable than:

: y = ( 2 / ( 3 / ( 4 / 5 ) ) )

Note that certain applications, like computer programming, will restrict you to certain grouping symbols.

=Special cases=

In the case that a factorial is in an expression, it is evaluated after parentheses or other grouping symbols, but before everything else (the common mnemonics would be B F EDMAS, B F ODMAS, B F IMDAS, and P F EMDAS, if an F were included for factorials).

When new operations are defined they are generally presumed to take precedence over other operations unless defined otherwise. In the case where repeated operators of the same type are used, such as in

::a/b/c

the expression is evaluated from left to right, as

::((a/b)/c)

=See also=

  • Common operator notation (for a more formal description)
  • associativity
  • commutativity
  • distributivity
  • =External links=

    * *For a rationale behind the use of the order of operations, see [http://www.mathandtext.blogspot.com/2005/05/order-of-operations.html MathandText].