next up previous contents
Next: Distributivity Up: Algebra Previous: Dividing both sides of   Contents

Order Convention for Mixed Forms

Parentheses do start to matter for mixed forms, expressions that contain both multiplication/division and addition/subtraction.

Suppose we look at the following equation:

\begin{displaymath}
y = a*x + b
\end{displaymath} (3.21)

We know that we can factor this somehow, but how we factor it depends a bit on how we group terms with parentheses. It could mean this:
\begin{displaymath}
y = a*(x + b)
\end{displaymath} (3.22)

or it could mean this:
\begin{displaymath}
y = (a*x) + b
\end{displaymath} (3.23)

These are different! Consider $a = 2$, $b = 3$, $c = 4$:
\begin{displaymath}
y = 2*(3+4) = 14 \ne (2*3) + 4 = 10
\end{displaymath} (3.24)

Hmmm, looks like order matters!

Parentheses can always be used to make the order of evaluation unambiguous, and if there is any doubt as to what the correct order should be they should be. However, algebracians and computer scientists (who often have to implement ``algebra'' in computer programs) don't want to always have to use them to resolve these conflicts. They (and we) introduce and ordering convention to tell us which operations to do first in an expression that mixes things like taking powers, multiplying and adding.

Starting at the deepest level of parentheses and working recursively outward:

  1. Evaluate all powers
  2. Evaluate all products
  3. Evaluate all sums
where at any given level it should not matter if you work from left to right or right to left across the terms because both addition and multiplication are separately both commutative and associative.

Here's an example of an expression both with and without the (redundant) parentheses:

\begin{displaymath}
a*x*y^n + b*y + c = (a*x*(y^n)) + (b*y) + c
\end{displaymath} (3.25)

First evaluate $y^n$. Multiply it by $a$ and $x$. Multiply $b$ and $y$. Add the results together.

With this rule defined, we can actually shorten our expression still further by adding another convention and still have expressions be quite unambiguous. From now on, if we put two symbols next to each other with no sign in between them, they are assumed to be multiplied with an implicit $*$ operator. That is:

\begin{displaymath}
axy^n + by + c = a*x*y^n + b*y + c = (a*x*(y^n)) + (b*y) + c
\end{displaymath} (3.26)

Note that the expression on the left is much shorter than the one on the right - shorter means faster to write, easier (once you get the hang of it) to read!


next up previous contents
Next: Distributivity Up: Algebra Previous: Dividing both sides of   Contents
Robert G. Brown 2009-07-27