Re: Calculation of powers (TI-86)


[Prev][Next][Index][Thread]

Re: Calculation of powers (TI-86)



Well, as I prepared this response, RWW Taylor sent one of well-reasoned,
insightful, informative posts on this topic, so I almost wonder if this is
worth posting.  Nonetheless, here's a bit more discussion.

I wrote:
>>I believe that the original post was asking for the formula:
>>        a^b = e ^ (b*ln(a)).
>>e.g., 2^7.2 = e ^ (7.2*ln(2) = e^(4.990...) = 147.03...
...
and Kevin DeGraaf responded:
>       The last reply helps, too.  (Thanks Darryl!)  I was aware of
>the formula (infamous "log law #3" plus some "tricky" mathematics),
>but it seems that we are back to square one.  How does the 86
>calculate e to non-integer/negative powers?  I'm thinking there is an
>easy way to do this with higher math than I know (Functions, Stats,
>and Trig).  Also, how are natural logs (and common ones too, for that
>matter) calculated?  Finally, what about negative bases (can't take the
>ln() of those, if I'm not mistaken)?

OK, I guess I skimped on my original response, so here's a little more detail.

DISCLAIMER: I am not presenting these as exact descriptions of the
algorithms used by TI calculators, only as the theoretical groundwork on
which those algorithms would be based.


The 4 issues covered are:
1. Calculating e^x
2. Calculating ln(x)
3. Other logarithms (and exponential functions)
4. Negative bases

1. Calculating e^x:  For =any= value of x, calculus can be used to show that

   e^x = 1 + x + x^2/2! + x^3/3! + x^4/4! + ...
       = sum(x^n/n!, n, 0, infinity),

where n! = n(n-1)(n-2)...(2)(1), with 0!=1.  In theory, this means
evaluating an infinite degree polynomial (a so-called "infinite series"),
but in practice, if x is small (say |x|<1), just using the first 11 terms
(i.e., using a 10th-degree polynomial) gives fairly accurate approximations
to e^x.  Thus, e^x can be approximated for (virtually) any value of x,
using only the operations of addition, multiplication (integer powers of
x), and division.

2.  Calculating ln(x): For -1<t<1, calculus gives

   -ln(1-t) = t + t^2/2 + t^3/3 + t^4/4 + ...
            = sum(t^n/n, n, 1, infinity).

For example, ln(0.9) = -0.105360515658..., which is approximated reasonably
well by the first four terms of this sum (with t=0.1):

   - (0.1 + 0.1^2/2 + 0.1^3/3 + 0.1^4/4) =  -0.1053583333....

This formula allows us (in theory) to approximate ln(x) for 0<x<2 (although
the approximation for x close to 0 and close to 2, the number of terms
required to get a good approximation is prohibitive).  However, with a
little adaptation, these problems can be resolved:  for example, numbers
are stored on the calculator in something like base-2 scientific notation
-- e.g., instead of 1024, it stores 1 x 2^10; instead of 34.56, it stores
1.08 x 2^5.  Thus, to find natural logarithms, we use formulas like

   ln(1024)  = ln(1) + 10 ln(2) = 10 ln(2), and
   ln(34.56) = ln(1.08) + 5 ln(2).

This expresses the logs in terms of values that can easily be approximated
[like ln(1.08)], or particular values that can be stored and used when
needed [like ln(2)].

3. Other logarithms (and exponential functions):  The infinite series
expressions for e^x and ln(x) given above are (part of) what makes these
functions special among all exponential and logarithmic functions.  Other
exponential and logarithmic functions have polynomial approximations, too,
but they are not so neat as these.

We have already mentioned that any exponential function can be written in
terms of e^( ) and ln( ) via the relation a^b = e^(b ln a).  Similarly, any
logarithmic function can be written in terms of ln( ) via log_a(b) =
ln(b)/ln(a); in particular, the base 10 (common) log of x is

   log(x) = ln(x) / ln(10).

4. Negative bases:  As mentioned by RWW Taylor, in terms of complex
numbers, we can take logarithms of negative bases, meaning we can make
sense of

   (-1)^(2.3) = e^( 2.3 ln(-1) ).

On the TI-81/82, which do not handle complex numbers, the calculator
apparently makes an effort to determine if the exponent is a "nice"
rational number (e.g., odd roots of negative numbers) -- sometimes
successfully, sometimes not.  For example, my TI-81 and -82 return -1 for
(-1)^(1/3), but give an error for (-1)^(2/3).

 /      Darryl K. Nester        |  nesterd@bluffton.edu  \
/  Assoc. Prof. of Mathematics  |  Office: 419-358-3483   \
\       Bluffton College        |  Fax:    419-358-3232   /
 \  Bluffton, OH  45817-1704    |  Home:   419-358-9650  /


Follow-Ups: References: