The FFT is not available as built in function in the TI Nspire, but it is trivial to write a program for doing this calculation. Instead of using the standard TI Basic program, the Lua scripting is attempted this time. Unlike the commonly used TI Basic program, variables are not shared directly. Things get complex when working with lists and matrices. However, there are some utility functions from the Lua scripting in Nspire that make it possible to exchange data with the Calculator page. The example below shown the FFT results from the Lua script in the Table page.
The HP Prime provided built in function for FFT.
As shown in a previous installment on running the Nelder-Mead optimization of the Rosenbrock function in TI-84, its hardware is not up to the challenge for problems of this kind. It is however an interesting case to learn from this program that took a considerable amount of time (in minutes), when most TI-84 programs complete in seconds, to grasp the technique in writing optimized code.
The problem used in the setting is the Rosenbrock function:
Two techniques were used to try to optimize the code. The first one is to in-line the function (in this case the Rosenbrock function). In the original version this function is stored in a string value to be evaluated whenever necessary by using the TI-84 expr() function. The idea from common in-lining is borrowed to see if it works in TI-84. As shown in line 44 below, the Rosenbrock function replaced the original expr() function call.
Another technique is to remove unnecessary comments. For most modern languages this is never considered a problem but for simple calculators it is speculated valuable processing time may be spent on processing comments that contribute nothing to the algorithm.
Both programs returned the same results. To compare the gain in speed, the same set of initial parameters and tolerance were used in both the original and code-optimized program. Surprisingly, the inline method does not yield any gain while removing all those “:” that were used for indentation does improve the speed. The average of the original program is 183 seconds while the program with cleaned code is only 174 seconds, which is around 95% of the run time of the original program.
Unlike the more sophisticated TI-89 and Nspire, the Durbin-Watson statistic is not included in the TI-84. Yet, calculating it is fairly straight-forward using list functions.
This statistics of regression is given as
where e is the residual list of values. To obtain this list (using a previous multiple regression example), simply subtract the actual values from the regression formula (Y7 below):
Finally, run the formula below for answer.
After determining the parameters of multiple linear regression in TI-84 (which do not have any direct built-in function support of this calculation), the coefficient of determination can also be easily calculated using the rich set of list functions supported by TI-84. Following the previous example, the dependent variable is in Sales list, the other two independent variables are Size and Dist lists.
The Yhat list is to be prepared first. This lists store the predicted values using the regression parameters determined in the previous installment.
Next, the mean of Y and Yhat are calculated and stored to a handy list S.
Furthermore, three lists SYY, SYhYh, SYYh are calculated respectively.
The result is obtained by the formula below.