Chapter 15: Expressions and The Expression Stack
173
TI
-
89 / TI
-
92 Plus Developer Guide
Not for Distribution
Beta Version January 26, 2001
The internal representation of exponentiation depends primarily on the type of
exponent. If the exponent is a number, then the representation is an
EXPONENTIATION_TAG on top of the internal representation of the base on top
of the internal representation of the exponent. Thus, x ^ 2 is simplified to 2 1
NONNEGATIVE_INTEGER_TAG X_VAR_TAG EXPONENTIATION_TAG. The
one important exception occurs when the base is
e
. The symbol
e
raised to any
exponent, numeric or otherwise, is simplified to EXP_TAG on top of the
exponent. Thus,
e
^ 2 simplifies to 2 1 NONNEGATIVE_INTEGER_TAG
EXP_TAG, and
e
^ x simplifies to X_VAR_TAG EXP_TAG.
The internal representation of any other base raised to any non-numeric
exponent uses the exponential (EXP_TAG) and natural logarithm (LN_TAG)
functions. For example, x ^ y is represented as exp(y * ln(x)) which is
Y_VAR_TAG X_VAR_TAG LN_TAG MULTIPLY_TAG EXP_TAG. The only
exception is that 0 ^ u is represented internally as an EXPONENTIATION_TAG
on top of a zero on top of the internal representation of expression u.
Since multiplication can be reordered, the simplifier orders products with the
most main factor highest and the least main factor lowest. Thus, x * y is
externally tokenized as X_VAR_TAG Y_VAR_TAG MULTIPLY_TAG. Then, the
simplifier reorders this to Y_VAR_TAG X_VAR_TAG MULTIPLY_TAG, because
x is more main than y.
In internal form division is represented as a product with the denominator raised
to the minus one power. Thus, x / y is externally tokenized as X_VAR_TAG
Y_VAR_TAG DIVIDE_TAG. Then, the simplifier changes this to a product and
reorders it as 1 1 NEGATIVE_INTEGER_TAG Y_VAR_TAG
EXPONENTIATION_TAG X_VAR_TAG MULTIPLY_TAG.
Another important aspect of the internal representation of products is that the first
(most main) operand of a product is never a product. Thus, (a * b) * (c * d) is
externally tokenized as A_VAR_TAG B_VAR_TAG MULTIPLY_TAG
C_VAR_TAG D_VAR_TAG MULTIPLY_TAG MULTIPLY_TAG due to the
parentheses used in the text. In this external form each of the operands of the
topmost MULTIPLY_TAG is also a product. The simplifier reorders this
expression so that the topmost operand of each MULTIPLY_TAG is not a
product. The result is D_VAR_TAG C_VAR_TAG MULTIPLY_TAG B_VAR_TAG
MULTIPLY_TAG A_VAR_TAG MULTIPLY_TAG.
The simplifier performs a similar process with addition. Since addition can be
reordered, the simplifier reorders sums with the most main term highest and the
least main term lowest. Subtraction is changed to a sum with the second operand
negated. Finally, the simplifier makes sure that the topmost operand of each
ADD_TAG is not a sum. Thus, a + b becomes B_VAR_TAG A_VAR_TAG
ADD_TAG. The expression a
N
b becomes 1 1 NEGATIVE_INTEGER_TAG