The Logbook

Little snippets of joy from a busy mind

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:

Geometric Mean 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

Learning Sed

posted at: Wed, 16 Apr 2008 22:54

Since I recommended learning awk, I suppose I should also suggest learning sed as they go well together.

A really good tutorial can be found here: Sed - An Introduction and Tutorial.

tags: , | permanent link to this entry

Beginning Awk

posted at: Wed, 16 Apr 2008 22:18

For parsing really large datasets you need to be able to use a good quick text manipulation tool. Because I don't find Perl appealing I decided to learn awk.

One of the easiest to read descriptions of the awk language is IBM's Developerworks series entitled 'Awk by Example'. It can be accessed from the following three links:

tags: , | permanent link to this entry

Infochimps Freely Redistributable Datasets

posted at: Wed, 09 Apr 2008 18:34

While browsing the internet looking for datasets which are both freely available and reasonably sized I came across Infochimps.

Initial impressions come across well. The site appears to still be in its infancy and certain browsing methods appear to not yet be implemented. However, the future looks promising. Well worth bookmarking for return visits in the future.

tags: , | permanent link to this entry

The Monty Hall Paradox

posted at: Mon, 07 Apr 2008 20:18

Want to cause an active discussion in the office and don't have a topic? Try the Monty Hall Problem.

In summary (from the linked wikipedia page):

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

tags: , | permanent link to this entry