Showing posts with label 2 x 2 matrices. Show all posts
Showing posts with label 2 x 2 matrices. Show all posts

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.

Wednesday, December 5, 2012

Numeric CAS Part 10 - Eigenvalues of 2 x 2 Matrices

Eigenvalues of 2 x 2 Matrices

Many graphing calculators that do not have CAS (computer algebraic systems) do not have eigenvalues and eigenvector functions.

The program for the Casio Prizm gives eigenvalues. The TI-84+ program gives both eigenvalues and eigenvectors.

For the HP 39gii has the functions EIGENVAL and EIGENVV for eigenvalues and eigenvectors, respectively.

Example:
A = [[2, 7][-3, 9]]

Eigenvalues: ≈ 5.5 ± 2.9580i


Casio Prizm:

Eigenvalues of a 2 × 2 Matrix
EIGEN2 - 136 Bytes

a+bi
"2 × 2 MATRIX:"? → Mat A
Mat A[1,1] + Mat A[2,2] → T
Det Mat A→ D
(T+√(T^2-4D))÷2 → R ◢
(T-√(T^2-4D))÷2 → S ◢
"λS STORED IN R,S"


TI-84+:

EIGEN2
Eigenvalues of 2 × 2 matrices - Approximately 280 bytes
Bonus! A pair of eigenvectors are given
5/15/2011

a+bi
Input "2 X 2 MATRIX:", [J]
[J](1,1) + [J](2,2) → T
det([J]) → D
(T + √(T^2 - 4D))/2 → U
(T - √(T^2 - 4D))/2 → V
Disp "EIGENVAL. U"
Pause U
(U - [J](1,1)) / [J](1,2) → A
√(1 + A^2)⁻¹ * [[1][A]] → [H]
Disp "EIGENVEC. [H]"
Pause [H]
(V - [J](1,1)) / [J](1,2) → B
√(1 + B^2)⁻¹ * [[1][B]] → [I]
Disp "EIGENVAL. V"
Pause V
Disp "EIGENVECT. [I]"
Pause [I]




This blog is property of Edward Shore. 2012

Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...