next up previous
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


\begin{displaymath}
a + \frac {b} {c}
\end{displaymath}

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

(a + b) over c


\begin{displaymath}
\frac {a + b} {c}
\end{displaymath}

Here is another example.

(a+b) times c


\begin{displaymath}
\left( a + b \right) \times c
\end{displaymath}

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

(a b)c


\begin{displaymath}
\left( a b \right) c
\end{displaymath}

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)


\begin{displaymath}
{a} ^ {b + c} , \ {a} _ {b + c}
\end{displaymath}

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


\begin{displaymath}
\frac {\left( x + y \right)} {\left( {x} ^ {2} - {y} ^ {2} \right)} , \ {f} ^ {\left( 2 \right)} \left( x \right)
\end{displaymath}

There are also square brackets:

[ x over y ]


\begin{displaymath}
\left[ \frac {x} {y} \right]
\end{displaymath}

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


\begin{displaymath}
{a} ^ {{b} ^ {{c} ^ {d}}} , \ {a} _ {{b} _ {{c} _ {d}}}
\end{displaymath}

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))


\begin{displaymath}
\left.\frac {{\,d f} ^ { - 1} \left( x \right)} {\,d x}\righ...
...ft.\frac {\,d f \left( x \right)} {\,d x}\right\vert _{x = a}}
\end{displaymath}


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