TI-Basic Bouncing Ball Animation Anyone who has programmed in TI-Basic is likely to have written one of these programs. The concept for this program is simple. 

The "ball" represented by a single point that originates from the upper left hand corner of the screen and bounces around the screen leaving a trail as it travels. The initial movement vector for the ball is (1,1), meaning one down, one right. During each pass through a loop, the "ball" is translated by the amount specified in the movement vector. When the ball would go of bounds, its movement vector is adjusted so that this does not happen. In short, it behaves like this: 



except I increased the frame of the GIF.

I've reduced my code to a very short and clean snippet:

FnOff 
PlotsOff 
AxesOff
ClrDraw

{1,1→L₁
Repeat getKey
Ans→L₂
Pxl-Change(L₁(1),L₁(2
Ans+L₁→L₁
L₂*(1-2not(Ans and Ans≠{62,94
End

FnOn 
PlotsOn 
AxesOn
ClrDraw


What I would like to hear in responses can be enumerated in four points:


How can I reduce the size of this program?
How can I increase the speed of this program?
How can I reduce the numbers of variables used in this program?
How can I increase the clarity of this program without sacrificing any of the goals stated above?




People responding to this post should also keep in mind that this code was written for and tested on a TI-83 Plus calculator.
This uses no variables other than Ans, but because real( and imag( are two-byte tokens, the code is larger. It is also faster than your code according to Timtech.

i+dim(identity(1                    //{1+i,1+i}
Repeat getKey
Pxl-Change(real(Ans(1)),real(Ans(2
Ans+imag(Ans)(1-2inot(real(Ans) and real(Ans)≠{62,94
End


In your original solution, you can thusly save a total of six bytes at the cost of a small amount of speed, and the use of named lists. Two bytes less than that is a program that starts at (2,2) instead of (1,1) because command order is switched:

dim(identity(1→A                    //{1,1
Repeat getKey
Ans→B
Ans+∟A→A
Pxl-Change(Ans(1),Ans(2
∟Bcos(πʳnot(Ans and Ans≠{62,94
End


Finally, if your calculator is in radian mode, you can save one more byte by removing the ʳ.