Arithmetic Expressions
Outline for Arithmetric Expressions
An arithmetic expression is an expression built up using
numbers, arithmetic operators (such as +, ,
-,
/ and )
and parentheses, "(" and ")".
Arithmetic expressions may also make use of exponents,
for example, writing 23as
an abreviation for ((22)2).
An arithmetic expression in which the only operators are +,,
-
and exponentiation, is called a simple arithmetic expression.
Here are some examples:
-
5 -- a number
is an arithmetic expression
-
(3 + 4) -- the
sum of numbers is an arithmetic expression
-
(7 - 3) --
the difference of two numbers is an arithmetic expression
-
(2 5),
25 --
a
product of two numbers is an arithmetic expression. We indicate the
product with either a "times sign", ""
or a raised dot, "".
The raising of the dot is important as it makes it easy to distinguish
a product from a decimal. For example, it allows us to distinguish
314
from
3.14.
-
(6 (3
+ 4)), 6(3
+ 4) -- by
using parentheses we can indicate the order in which the operations are
to be done. In this example the parentheses indicate that the addition
is to be done before the multiplication.
-
6(3 + 4)--
This is another way of writing (6 (3
+ 4)). It is a common practice
to omit the product sign when one factor is surrounded by parentheses.
The multiplication is indicated by the juxtaposition of factors.
-
((3 + 4)(6
- 2)) -- This is another example of juxtaposition.
It is the same as writing ((3 + 4)(6
- 2)) . The same convention is used
when both factors are parenthesized.
-
23
-- this is an abbreviation for the arithymetic expression ((22)2)
-
(23
+ 5) -- this is an abbreviation for the arithmetic expression
(((22)2)
+ 5)
-
(23
+ 5)2 -- this is an abbreviation for the arithmetic
expression (23
+ 5)(23
+ 5)
-
7 - 6 + 2 --
while expressions involving several operators are sometimes written
without using parentheses this is only allowed when rules are given that
indicate how the parentheses should be inserted. Such rules are called
precedence
rules. We shall introduce some precedence rules at a later
point, for the time being we will always put in the parentheses.
Simple arithmetic expressions can always be evaluated to a number.
-
5 -- is
already evaluated, its value is 5.
-
(3 + 4) --
evaluates to 7
-
(7 - 3) -- evaluates
to 4
-
(2 5),
(25) --
evaluate
to 10.
-
6 (3
+ 4), 6(3
+ 4) -- evaluate
to 42 = 6 7
.
-
6(3 + 4)--
evaluates, again, to 42.
-
(3 + 4)(6 -
2) -- evaluates to 28=
74.
-
23
-- evaluates to ((22)2)
= 8 .
-
(23
+ 5) -- evaluates to (((22)2)
+ 5) = (8+5) = 13.
-
(23
+ 5)2 -- evaluates to ((23
+ 5)(23
+ 5)) = ((8+5)(8+5))
= (1313) = 169.
-
7 - 6 + 2 --
can be evaluated in two ways, depending on which operation we perform first.
Note that the two parenthesized versions of this expression, 7
-( 6 + 2) and (
7
- 6 ) + 2, evaluate to different values:
the first evaluates to -1 but
the second evaluates to 3.So,
unless we have a precedence rule which tells us where to put in the parentheses,
and thus tells us in which order to perform the operations, the evaluation
of the expression is ambiguous.
There are two ways to get avoid the ambiguity
problem presented in the last example. One is to have formal (strict)
rules for writing arithmetic expressions so that there are always enough
parentheses so that we always know in which order to perform the operations.
The other is to have "precedence rules" which tell us how to evaluate an
expression -- in effect they tell us how to insert parentheses.
Formal Rules for writing Simple Formal Arithmetic Expressions.
-
Every number is a simple formal arithmetic expression
-
if e and e'are
simple formal arithmetic expression then so is the expression
( e + e')
-
if e and e'
are
simple formal arithmetic expression then so is the expression
( e - e')
-
if e and e' are
simple formal arithmetic expression then so is the expression
( e e')
-
if e is a simple formal
arithmetic expression and n is a positive
integer then (e)n is a simple
formal arithmetic expression
-
An arithmetic expression is a simple
formal algebraic expression if, and only if, it is
obeys these rules.
Rules for evaluating Simple Formal Arithmetic
expressions
-
Evaluate the expression beginning with the expression
in the innermost parentheses and work outwards.
Examples:
-
((5 + 4) -3) = (9-3) = 6
-
((7)2)3 = ((7 7))3
= (49)3 = ((49
49) 49)
= (240149) =
117649
Rules for writing Simple Informal Arithmetic Expressions
Every number is a simple informal arithmetic expression
if e and e'are
simple informal arithmetic expression then so is the expression
( e + e')
if e and e'are
simple informal arithmetic expression then so is the expression
e + e'
if e and e'
are
simple informal arithmetic expression then so is the expression
( e - e')
if e and e'are
simple informal arithmetic expression then so is the expression
e - e'
if e and e' are
simple informal arithmetic expression then so is the expression
( e e')
if e and e'are
simple informal arithmetic expression then so is the expression
e e'
if e is a simple informal
arithmetic expression and n is a positive
integer then (e)n is a simple
informal arithmetic expression
if e is a simple informal
arithmetic expression and n is a positive
integer then en is a simple
informal arithmetic expression. Actually this rule is not really
satisfactory in the case that e is
of the form ap, for
some expression a, as the notation
ap
n is possibly confusing and it is better to
write (ap)n.
An arithmetic expression is a simple
informal algebraic expression if, and only if, it
is obeys these rules. However, in practice we will relax this rule and,
for example, use notations such as
34 or
3(5+2)
for,
respectively, 34
and 3(5+2).
Precedence Rules for evaluating simple informal
arithmetic expressions
-
Evaluate the expression beginning with the expression
in the innermost parentheses and working outwards.
-
When evaluating a parenthesis-free expression perform
the operations in the following order:
-
evaluate all factorials from left to right
-
do all multiplications from left to right
-
do additions and subtractions from left to right
Examples:
-
7 - 6 + 2 = 1 + 2 = 3
-
7 - (6 + 2) = 7-8 = -1
-
5 + 62
+ 1 = 5+ 12 + 1 = 17 + 1 = 18
-
(5 + 6) (2+1)
= 11(2+1) =
113 = 33
EXERCISES
Here is a form that will produce examples of informal
arithmetic expressions for use to both increase and test your ability to
evaluate arithmetic expressions. The underlying program produces
arithmetic expressions by making random choices -- it will frequently produce
examples that are either too difficult (too big) or too simple (e.g., a
single number) to be worthwhile working out. When that happens just produce
another expression by clicking on the "make Arithmetic Expression" button.