**Fun with the Sharp EL-5500 III**

Even though the
EL-5500 III has one programming space, we can fit many programs in it. One of the great features is that how
programs take relatively little space.
Obviously you can change the line numbers, the sequence of lines are
most important.

**Euclid Algorithm – RUN 10**

10 PAUSE “GCD:
A>B”

18 INPUT “A: “; A, “B:
“; B

20 C = A – INT(A/B)*B

30 IF C = 0 THEN 40

32 A = B

34 B = C

36 GOTO 20

40 PRINT “GCD = “; B

46 END

My first program
on the EL-5500 III. We can probably make
the coding more efficient. PRINT with a
proceeding WAIT pauses execution until [ ENTER ] is pressed.

The command END
ends the program execution and allows the space to have more than one routines.

Examples:

A: 100, B:
20. Result: GCD = 20

A: 63, B:
60. Result: GCD = 3

**Binomial Expansion – RUN 50**

50 PAUSE “(Ax + B)^n”

55 INPUT “A: “;A, “B:
“;B, “N: “,N

60 FOR I=0 TO N

65 C = FACT(N) /
(FACT(I) * FACT(N-I))

70 T = C * A^(N-I) *
B^I

75 PRINT T; “*x^”;
N-I

80 NEXT I

85 END

The command
PAUSE shows the text for about 0.85 seconds.

This program
displays each coefficient one at time.

Example: A = 3, B = -2, N = 3. Expand (3 – 2x)^3.

Result: 27, -54, 36, -8 (27x^3 – 54x^2 + 36x – 8)

**Days Between Dates – RUN 100**

100 PAUSE “Days
between Dates”

112 INPUT “M1:”; M1,
“D1:”; D1, “Y1:”; Y1

113 INPUT “M2:”; M2,
“D2:”; D2, “Y2:”; Y2

115 M = M1: D = D1:
Y = Y1

117 GOSUB 140

119 F1 = F

121 M = M2: D = D2:
Y = Y2

123 GOSUB 140

125 F2 = F

127 N = F2 – F1

129 PRINT “# DAYS: “;
N

131 END

140 IF M > 2 THEN
150

142 X = 0: Z = Y – 1

144 GOTO 160

150 X = INT(.4 * M +
2.3): Z = Y

160 F = 365 * Y +
31* (M – 1) + D + INT(Z/4) – X

165 RETURN

If I had it my
way, every calculator that isn’t a basic 4-function calculator will have a Days
Between Dates function.

Example: November 4, 1986 to January 12, 2017

M1: 11, D1: 4, Y1: 1986

M2: 1, D2: 12,
Y2: 2017

Result: 11,027

**Power of a Complex Number – RUN 200**

This calculates
(a + bi)^n

200 PAUSE “(A +
Bi)^n”

203 INPUT “A: “;A, “B:
“;B, “n: “;N

205 IF A<>0
THEN 210

207 A = A^N: GOTO
220

210 R = √(A^2 +
B^2)^N

212 T = ATN(B/A)*N

214 A = R * COS T

216 B = R * SIN T

220 PRINT A; “+”; B;
“i”

225 END

The command
<> means not equals (≠) and ATN is the arctangent function.

Examples:

(2 +
3i)^3: A = 2, Bi = 3. Result: -46 + 9i

(-5 + i)^2: A = -5, Bi = 1. Result: 24 – 10i

**Error Function Approximation – RUN 250**

250 PAUSE “APPROX
ERF(X)”

252 CLEAR

254 DIM A(3)

256 E = 0

260 INPUT “X > 0
: “; X

262 T = RCP(1 +
.47047 * X)

270 FOR I = 1 TO 3

272 READ A(I)

274 E = E + A(I) *
T^I

276 NEXT I

280 DATA .3480242,
-.0958798, .7478556

290 E = 1 – E *
EXP(-(X^2))

292 PRINT “ERF : “,
F

294 CLEAR

296 END

Use the command
CLEAR to clear all the variables. At
this point, I will use this command both at the beginning and end of
calculations. The command RCP is the
reciprocal. Finally, EXP is from e^x
function, *not the
[EXP] key*.

Example:

x = 0.53, erf ≈
0.546455764

x = 0.88, erf ≈
7.86708E-01 = 0.786708

Keep in mind
this approximation is accurate 2.5 parts in 10^-5.

Source: Smith, Jon M.
__Scientific Analysis on the Pocket Calculator__ John Wiley & Sons: New York. 1975. ISBN 0-471-79997-1

**Simpson’s Rule – RUN 300**

Calculates the
numeric integral ∫ f(x) dx from x = L to x = U.

You can edit
the function at line 342. In BASIC-PRO
mode, call up line 342 by LIST 342. Edit
as desired.

300 PAUSE “Simpsons
Rule”

302 CLEAR

304 INPUT “LOWER: “;
L, “UPPER: “; U, “PARTS (even): “; N

306 RADIAN

308 X = L: GOSUB
340: T = F

310 X = U: GOSUB
340: T = T + F

314 H = (U – L)/N

320 FOR I = 1 TO N-1

322 X = L + I * H:
GOSUB 340

324 R = I/2 –
INT(I/2)

326 IF R = 0 THEN
LET T = T + 2*F

328 IF R <> 0
THEN LET T = T + 4*F

330 NEXT I

332 T = T * H/3

334 PRINT “Integral:
“, T

336 CLEAR

338 END

340 REM f(x)

342 F = *[insert f(X) here]*

344 RETURN

Note: I finally learn why LET is included in BASIC. In an IF-THEN statement, if you want to
assign a value or calculation to a variable, you will need a LET command.

I use a REM
(remark) command on line 340. REM is for
comments and nothing said after REM is executed.

Examples:

342 F = X^2 – 1

L = -2, U = 2,
N = 14. Result: 1.333333334 (Actual: 4/3 ≈ 1.333333333)

342 F = √(X –
1)

L = 2, U = 3, N
= 14. Result: 1.218951372 (Actual: ≈ 1.2158951416)

**Dancing Star Demo – RUN 400**

400 PAUSE “Dancing
Star Demo”

405 CLEAR

410 S$ = “ “
(9 spaces)

415 FOR I = 1 TO 48

420 N = RND 7 + 1

425 T$ = MID$(S$, 1,
N-1) + “*” + MID$(S$, N+1, 9-(N+1))

430 WAIT 15: PRINT
T$

440 NEXT I

445 BEEP 3: CLEAR:
END

This is just
show a dancing asterisk (*) on the screen.

WAIT 15: PRINT
T$: This causes the string T$ after a
quarter of a second. WAIT operates in
1/60 seconds.

RND n: This is the random command. If n = 1, the result is between 0 and 1.

BEEP n: This makes the EL-5500 III beep n times.

Eddie

This blog is
property of Edward Shore, 2017.