Next: Functions Up: The basic commands Previous: Operations

## Order of Operations and Brackets

Natural Math does a careful analysis, pulling apart the expressions so as to figure out what comes first. So in the following example, the division is done before the addition.

a + b over c


You can change the order of operations: in this example the addition is done before the division.

(a + b) over c


Here is another example.

(a+b) times c


In this last example, the brackets appeared when typeset. Usually, brackets written in will appear as you wrote them:

(a b)c


In a few cases, brackets are needed to change the natural order of doing operations, but it would not be right to typeset them. This happens with fractions (as above), and also with powers and subscripts. (It also happens with the square root and absolute value, and with limits of integration, and with the substitution operator -- see below.) However, you can always force the brackets to appear in this situation by adding an extra pair of unneccesary brackets:

a^(b+c), a_(b+c)


((x+y)) over ((x^2 - y^2)) , f^((2))(x)


There are also square brackets:

[ x over y ]


What is the order in which natural math would evaluate the operations without brackets? First powers and subscripts. Then fractions. Then multiplication and division. Then addition and subtraction. Then the tends to'. Then the comma'. Finally the relational operators. Otherwise the operations are performed left to right, except that the power and subscript operators are performed from right to left.

a^b^c^d , a_b_c_d


Here is an example with the substitution operator. Notice that in this case, a rather large number of brackets is needed. Natural Math has its limitations!

((df^-1(x)) over dx) subst (x=f(a))
=
1 over (((df(x)) over dx) subst (x = a))


Next: Functions Up: The basic commands Previous: Operations
Stephen Montgomery-Smith 2003-05-26