Sunday, March 5, 2023

Radio Shack EC-4000 (equiv. of TI-57): Program Library

Radio Shack EC-4000 (equiv. of TI-57):   Program Library





Radio Shack EC-4000/TI-57:  Horner's Method


Let's start with a demonstration of Horner's Method, which allows a quick evaluation of polynomials.   For a quadratic polynomial:


p(x) = a * x^2 + b * x + c = x * (a * x + b) + c



The program demonstrates an example polynomial:


p(x) = 3 * x^2 - 4 * x + 9 = x * (3 * x -  4) + 9



Step:  Key Code [ Key ]

00: 32, 1 [ STO 1 ]

01:  55 [ × ]

02:  03  [ 3 ]

03:  65  [ - ]

04:  04 [ 4 ]

05:  85  [ = ]

06:  55 [ × ]

07:  33, 1 [ RCL 1 ]

08:  75  [ + ]

09:  09  [ 9 ]

10:  85 [ = ]

11:  81  [ R/S ]

12:  71  [ RST ]


Examples:

p(0) = 9

p(5) = 64

p(9) = 216


Horner's Method can apply to higher order polynomials.  




Radio Shack EC-4000/TI-57:  Permutation and Factorial



This is to add two of the common probability functions that are missing with on the calculator.  


nPr = n! / (n - r)!


If n = r, then nPn = n!


Store n in R0 (register 0), r in R1 (register 1), then run the program (RST, R/S).


Other registers used:  R2:  nPr,  R7:  n-r+1 


Note that R7 is also the t-register.  


Step:  Key Code [ Key ]

00:  01  [ 1 ]

01:  32, 2  [ STO 2 ]

02:  33, 0  [ RCL 0 ]

03:  65   [ - ]

04:  33, 1  [ RCL 1 ]

05:  75  [ + ]

06:  01  [ 1 ]

07:  85  [ = ]

08:  32, 7 [ STO 7 ]

09:  86, 5 [ LBL 5 ]

10:  33, 0 [ RCL 0 ]

11:  39, 2  [ Prd 2 ]

12:  01  [ 1 ]

13:  -34, 0 [ INV SUM 0 ]

14:  33, 0 [ RCL 0 ]

15:  76  [ x≥t ]

16:  51, 5 [ GTO 5 ]

17:  33, 2 [ RCL 2 ]

18:  81  [ R/S ]

19:  71  [ RST ]



Examples:

n = 6, r = 6:  6P6 = 6! = 720

n = 5, r = 3:  5P3 = 60

n = 11, r = 6:  11P6 = 332,640

n = 52, r = 5:  52P5 = 3.118752 * 10^8



Radio Shack EC-4000/TI-57:  Snell's Law


There are two subroutines in this program listing.  Subroutines accessed by the [ SBR ] key.  


Snell's Law describes, among other things, the relationship between index of refraction of a medium (n) and refraction angle of the direction of light (Θ) is stated by:


n1 * sin(Θ1) = n2 * sin(Θ2)



Subroutine 1:  Solve for n2.  n2 = (n1 * sin(Θ1)) / sin(Θ2)


Subroutine 2:  Solve for Θ2.  Θ2 = arcsin( n1 * sin(Θ1) / n2 )


The registers used are:  R1 = n1, R2 = n2,  R3 = Θ1, R4 = Θ2


Step:  Key Code [ Key ]


// Solve for n2

00:  86, 1  [ LBL 1 ]

01:  50  [ DEG ]

02:  33, 1 [ RCL 1 ]

03:  55  [ × ]

04:  33, 3  [ RCL 3 ]

05:  28  [ SIN ]

06:  45  [ ÷ ]

07:  33, 4 [ RCL 4 ]

08:  28  [ SIN ]

09:  85  [ = ]

10:  32, 2 [ STO 2 ]

11:  81  [ R/S ]


// Solve for Θ2

12:  86, 2  [ LBL 2 ]

13:  50  [ DEG ]

14:  33, 1 [ RCL 1 ]

15:  55  [ × ]

16:  33, 3 [ RCL 3 ]

17:  28  [ SIN ]

18:  45  [ ÷ ]

19:  33, 2 [ RCL 2 ]

20:  85 [ = ]

21:  -28  [ INV SIN ]

22:  32, 4 [ STO 4 ]

23:  81 [ R/S ]


Examples:


Solve for n2:  n1 = 1.000293 (air), Θ1 = 30°, Θ2 = 19°

1.000293 STO 1

30 STO 3

19 STO 4

GSB 1

Result:  n2:  1.5362267


Solve for Θ2:  n1 = 1.000293 (air), Θ1 = 30°, n2 = 1.333 (water)

1.000293 STO 1

30 STO 3

1.333 STO 2

GSB 2

Result:  Θ2:  22.036902



Radio Shack EC-4000/TI-57:  Pseudorandom Number Generation


This program attempts to generate random numbers using the generator:


x_n+1 = frac(997 * x_n + π)


The random numbers are between 0 and 1.  An initial seed will be required 


The calculator does not have fraction and integer parts, so they have to be simulated:


int(x) ≈ x + 1E10 - 1E10

frac(x) = x - int(x), will require a register 


See steps 10 to 23.  


Due to the internal 10 digits and the simulations, expect possible roundoff errors as random numbers are continuously generated.  


Step:  Key Code [ Key ]

00:  55 [ × ]

01:  09  [ 9 ]

02:  09  [ 9 ]

03:  07 [ 7 ]

04:  75  [ + ]

05:  30  [ π ]

06:  85  [ = ]

07:  32, 6 [ STO 6 ]

08:  75  [ + ]

09:  01  [ 1 ]

10:  42  [ EE ]

11:  01  [ 1 ] 

12:  00 [ 0 ]

13:  65  [ - ]

14:  01  [ 1 ]

15:  42  [ EE ]

16:  01  [ 1 ] 

17:  00 [ 0 ]

18:  85 [ = ]

19:  -42  [  INV EE ]

20:  -34,6  [ INV SUM 6 ]

21:  33, 6 [ RCL 6 ]

22:  81  [ R/S ]

23:  71  [ RST ]



Example:


Seed:  0.98

Generation:

0.2015927

0.1294647

0.2178986

0.3864470

0.4292517



Until next time,


Eddie 


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Spotlight: Akron Brass FireCalc Pocket Computer

Spotlight: Akron Brass FireCalc Pocket Computer Welcome to a special Monday Edition of Eddie’s Math and Calculator blog. Thi...