Adding Additional Functions to the TI83
posted at: Tue, 13 May 2008 09:57
While browsing the manual for my (now superceeded) Texas Instruments TI-83 calculator I came across the following description of 'Ans'.
When an expression is evaluated successfully from the home screen or from a program, the TI-83 stores the answer to a storage areas called Ans (last answer). Ans may be a real or complex number, a list, a matrix, or a string. When you turn off the TI-83, the value in Ans is retained in memory.
You can use the variable Ans to represent the last answer in most places.
This led me to think that parameters could be passed to TI-Basic programs on the calculator through this variable. Some investigation revealed this to be correct. Through careful coding, functions can be created which only modify the 'Ans' variable (i.e. do not destroy any other variables).
Worked Example - Geometric Mean
The geometric mean is the product of a list of numbers raised to the power of the reciprical of the number of numbers, as explained by the following equation:

The TI-Basic code for this function (prgmGEOMEAN) is as follows:
PROGRAM:GEOMEAN
:prod(Ans)^(1/dim(Ans))
The above code uses the built in functions 'prod' and 'dim' to calculate the product of a list and retrieve the length of a list respectively.
Now that the program has been created we only need to find out how to pass parameters to it through 'Ans'. As was outlined above, 'Ans' will contain the answer to the last statement. Statements are separated with the colon (':') operator. Thus the following example should return the value nine:
3:Ans^2
First the statement '3' is evaluated which returns the value three. This is then stored in 'Ans' and the next statement evaluated. The way I remember the colon notation is to associate it with the pipe ('|') command in Unix based systems. This command also passes the output of one statement to the input of another. Now we have enough information to calculate the geometric mean of a list
{1,2,3,5,9}:prgmGEOMEAN
This should return the answer 3.063887063. Note that it will work with both explicit lists, such as used above, or named lists.
In conclusion, by utilising 'Ans' in this way and by careful programming, parameters of any type may be passed to a TI-Basic program, manipulated and returned.
tags: | permanent link to this entry