Thursday, September 8, 2016

TI-74 Programming: Factorial, List of Random Integers, 2 x 2 Matrix Determinant and Inverse, Simple Pendulum, Secret Codes

TI-74 Programming: Factorial, List of Random Integers, 2 x 2 Matrix Determinant and Inverse, Simple Pendulum, Secret Codes


Note:  The TI-74 has one programming space (lines 0 to 32768), which the entire space can be saved if the TI-74 connected to an appropriate peripheral (cassette or computer).  Cassettes?  The TI-74 is a 1980s basic computer after all. 

TI-74 Program Factorial

The TI-74 does not have a factorial function its command set.  Here is one way to tackle it:

1300 ! Factorial
1310 INPUT “N=”; N
1320 IF N=0 THEN PRINT 0: PAUSE: STOP
1325 F=1
1330 IF I=1 TO N-1
1340 F=F*I
1350 NEXT I
1360 PRINT “N!=”; F: PAUSE
1370 END

TI-74 List of Random Integers

Integers will appear for 2 seconds followed by a “Next…” indicator. 

1000 ! List of random integers
1005 RANDOMIZE
1010 INPUT “Length?”; K
1020 INPUT “High Number:”; N
1025 FOR I=1 TO K
1035 PRINT INT(N*RND+1): PAUSE 2
1040 PRINT “Next…”: PAUSE 0.5
1045 NEXT I
1050 PRINT “Done”: PAUSE: END

TI-74 2 x 2 Matrices: Determinant and Inverse

Matrix:  [[A, B],[C, D]]
Inverse:  [[F, G],[H, I]]
Determinant: E = A*D – B*C.  If E=0, the matrix is singular.

1100 ! 2 x 2 Matrices; det/inv
1105 INPUT “A=”; A, “B=”; B
1110 INPUT “C=”; C, “D=”; D
1115 E=A*D-B*C
1120 PRINT “det=”; E: PAUSE 2
1125 IF E=0 THEN STOP
1130 PRINT “inv=”: PAUSE 2
1135 F = D/E: G = -B/E: H=-C/E: I=A/E
1140 PRINT “F=”; F: PAUSE 2
1145 PRINT “G=”; G: PAUSE 2
1150 PRINT “H=”; H: PAUSE 2
1155 PRINT “I=”; I: PAUSE 2
1160 END

Example:
Matrix:  [[1, 5],[-2, 7]]
A=1,  B=5, C=-2, D=7

RUN 1100:
det = 17
inv =
F = .4117647059
G = -.2941176471
H = .1176470588
I = .0588235294

TI-74 Simple Pendulum:  Angular Velocity and Period

This routine calculates the angular velocity and period for a simple pendulum.  SI units are used, meaning that g = 9.80665 m/s^2.  Note the SQR command is square root.

1200 ! Simple Pendulum, SI unites
1205 G=9.80665
1210 INPUT “Length (m):”; L
1215 W=SQR(G/L): T=2*PI*SQR(L/G)
1220 PRINT “Angular Vel.:”; W; “m/s”:  PAUSE
1225 PRINT “Period:”; T; “s”: PAUSE
1230 END

Example:  L = 1.14 m
Results:  W = 2.932971967 m/s, T = 2.1422588902 s

TI-74 Secret 3 Digit Codes

I learn the PRINT USING and IMAGE commands for the first time here.  On the TI-74, # is a number field, the period (.) is the decimal point, ^ is the exponential character, and I can use spaces and text.  Yes, IMAGE is different on each of the basic calculators.

500  IMAGE ###   ###   (3 spaces in between the sets of hashtags)
505  PRINT “Here are the”: PAUSE 1
510  PRINT “secret codes!”: PAUSE 1
515  FOR I=1 TO 4
520 A=100*RND: B=100*RND
525 PRINT USING 500; A,B : PAUSE 1
530 NEXT I
540 END

Notes

1.     I am not able to use a variable while using a DIM command to size an array.  This is not allowed:

100 Z = 10
110 DIM A(Z)

2.     The commands and one-letter variables auto-capitalize when [ENTER] is pressed.  For example:

I type 100 print a, press [ENTER] and when look at the line again, the TI-74 displays:
100 PRINT A

3.     It is a good idea to put an END command after each routine.  END will tell the TI-74 stop, allowing multiple, separate routines in the TI-74 programming space.

4.    The amount of free memory is found by the formula:  FRE(0)-FRE(1).  The keyboard shortcut to FRE is [FN] [ ↓ ].

5.    If you want to clear the entire program space, type NEW ALL.

There will be more TI-74 programs in the near future.  Until next time,

Eddie


This blog is property of Edward Shore, 2016.

TI-30Xa and HP 12C: Linear Interpolation

TI-30Xa and HP 12C: Linear Interpolation Introduction Given two points (x0, y0) and (x1, y1), and a point, x, we can easily estim...