SHARP EL-5500 II/III Basic Commands
And
Statistical Features Summary
By Namir Shammas
This is a table that summarizes most of the commands for the SHARP EL-5500 II/III.
Command |
Purpose |
Syntax |
Example |
END |
Ends execution. Must appear before subprograms |
END |
END |
FOR |
For loop |
FOR variable = first TO last [STEP step] |
FOR I = 1 to 5 STEP 2 |
GOSUB |
Invokes a subroutine |
COSUB line |
100 GOSUB 600 200 PRINT X 599 END 600 REM sub 610 X = 1 699 RETURN |
GOTO |
Jumps to a line |
GOTO line |
100 GOTO 333 |
IF THEN ELSE |
Decision making. The entire IF statement resides in one line. You must use the LET reserved word in an assignment with the THEN and/or ELSE clauses. |
IF condition THEN stmt1 ELSE stmt2 |
IF X = 0 THEN LET Y = 1 ELSE LET Y = 0 |
NEXT |
End a FOR loop |
NEXT variable |
FOR I = 1 to 3 PRINT I NEXT I |
ON GOSUB |
|
|
|
ON GOTO |
|
|
|
RETURN |
Return from a subroutine |
RETURN |
|
STOP |
Stops execution |
STOP |
STOP |
CLEAR |
Clears variables |
CLEAR |
CLEAR |
DIM |
Sets the dimensions of arrays. First index is 0. The DIM statement specifies the number of dimensions and high index for each dimension. |
DIM variable(highIndex) |
DIM X(20)
DIM
B(12,12) DIM C$(3) |
LET |
Assignment statement |
LET variable = expression |
LET X = 2 |
DATA |
A comma-delimited data list |
DATA list |
DATA 1,2,3,4 DATA “me”, “you” |
INPUT |
Input from the keyboard |
INPUT [prompt,] varList |
INPUT “X?”; X |
INPUT# |
Input from files |
INPUT #fileNum [, REC recNum], varList |
INPUT #3, Z, B, C |
LPRINT |
Write to printer |
LPRINT [USING frmt] outputList |
LPRINT X, Y |
PAUSE |
Briefly displays information and then resumes program execution |
PAUSE expression |
PAUSE A PAUSE X, Y |
|
Display results |
PRINT [USING frmt] outputList |
PRINT X, Y |
PRINT# |
Write to a file |
PRINT # fileNum, outputList |
PRINT #1, X,Y |
USING |
Directs PRINT statement to use output format. The characters used in the format string are: # is a right justified digit. . is a decimal ^ for a digit that appears as scientific notation $ is a left justified digit |
USING frmt |
PRINT USING “##.##”; X |
READ |
Read from a DATA list |
READ varList |
READ X, Y, Z DATA 1, 2, 3 |
RESTORE |
Restore the pointer to a DATA statement. An optional line specifies a target DATA statement. |
RESTORE [line] |
10 DATA 1,2,3 20 DATA 4,5,6 90 RESTORE 20 |
RANDOM |
Reseeds the internal random number generator |
RANDOM |
RANDOM X = RND |
REM |
Remark |
REM text |
REM this is a test |
WAIT |
Pauses execution. |
WAIT WAIT number of 1/64 of a seconds |
PRINT 3 : WAIT 64 |
INKEY$ |
Reads input from the keyboard |
INKEY$ |
A$ = INKEY$ IF A$ = “Y” THEN |
MEM |
Display amount of memory available |
MEM |
PRINT MEM |
PI |
Returns the value of PI |
PI |
E = PI – 355/113 |
ASC |
The ASCII code of the first character in a string |
ASC(string) |
X = ASC(“A”) Y = ASC(“AB”) |
CHR$ |
The character that corresponds to a specified ASCII code |
CHR$(integer) |
A$ = CHR$(65) |
LEFT$ |
Extract leading string characters |
LEFT$(string, count) |
A$=LEFT$(“1234567”, 3) |
LEN |
The length of a string |
LEN(string) |
X = LEN(“123”) |
MID$ |
Extracts a substring |
MID$(string, position, length) |
A$ = MID$(“123456789”, 2, 4) |
RIGHT$ |
Extract trailing string characters |
RIGHT$(string, count) |
A$=RIGHT$(“1234567”, 3) |
STR$ |
Converts a number into a string. |
STR$(value) |
A$ = STR$(23.3) |
VAL |
Converts string to a value |
VAL(string) |
X = VAL(“12.3”) |
ABS |
Absolute value |
ABS(value) |
X = ABS(-1) |
ACS |
Arccosine value |
ACS(value) |
X = ACS(.5) |
AHC |
Inverse hyperbolic cosine value |
AHC(value) |
X = AHC(1.5) |
AHS |
Inverse hyperbolic sine value |
AHS(value) |
X = AHS(1.5) |
AHT |
Inverse hyperbolic tangent |
AHT(value) |
X = AHT(0.5) |
ATN |
Inverse tangent |
ATN(value) |
X = 4 * ATN(1) |
|
Cosine value |
COS(value) |
X = COS(2) |
CUR |
Cubic root |
CUR(value) |
X = CUR(125) |
DEG |
Converts angle (in degrees, minutes, seconds) into fraction |
DEG(value) |
10 REM Angle is 12°11’22.30’’ 15 X = DEG(12.112233) |
DMS |
Converts angle (fraction format) into in degrees, minutes, and seconds. |
DMS(value) |
X = DEM(12.2) |
EXP |
Exponential value |
EXP(value) |
X = EXP(1.1) |
FACT |
Factorial value |
FACT(integer) |
X = FACT(5) |
HCS |
Hyperbolic cosine value |
HCS(value) |
X = HCS(2) |
HSN |
Hyperbolic sine value |
HSN(value) |
X = HSN(0.5) |
HTN |
Hyperbolic tangent value |
HTN(value) |
X = HTN(0.5) |
INT |
Returns the largest integer |
INT(value) |
X = INT(1.9) |
LN |
Natural logarithm |
LN(positiveValue) |
X = LN(9) |
LOG |
Common logarithm |
LOG(positiveValue) |
X = LOG(9) |
POL |
Converts rectangular coordinates to polar values |
POL(x,y) |
POL(1,1) |
RCP |
Returns the reciprocal value |
RCP(value) |
X = RCP(4) |
REC |
Converts polar coordinates to rectangular values |
REC(length, angle) |
REC(10, 35) |
RND |
Generates a random number is >= 0 and < 1 |
RND |
RANDOMIZE X = RND |
ROT |
Returns the power root value |
Value ROT powerRoot |
144 ROT 2 yields 12 |
SGN |
Sign value |
SGN(value) |
IF SGN(X) > 0 THEN |
SIN |
Sine value |
SIN(value) |
X = SIN(45) |
SQR |
Square root |
SQR(value) |
X = SQR(25) |
SQU |
Square of a value |
SQU(value) |
X = SQU(12) |
TAN |
Tangent value |
TAN(value) |
X = TAN(45) |
TEN |
Power of ten |
TEN(value) |
X = TEN(3) |
Here is a set of sample programs:
This program uses
100 REM
110 INPUT “Enter guess? “;X
120 I = 0
200 H = 0.01
210 IF ABS(X) > 1 THEN LET H = H * X
220 XX = X + H
: GOSUB 400 : F1 = FX
230 XX = X - H
: GOSUB 400 : F2 = FX
240 XX = X :
GOSUB 400 : F3 = FX
250 D = 2 * H *
F3 / (F1 – F2)
260 X = X - D
270 I = I + 1
280 IF I > 55 THEN GOTO 300
290 IF ABS(D) > 1.0E-8 THEN GOTO 200
300 PRINT “Root = “; X; “ Iters = “;I : WAIT
399 END
400 REM Subroutine F(X)
405 REM adapt next line to your function
410 FX = EXP(XX) – 3 * XX ^ 2
420 RETURN
This program performs simple linear regression. The program allows you specify the number of observations, enter the X and Y data, and obtain the linear regression statistics. Lines 153 and 155 are place holders for transforming the X and/or Y data. As the program stands, the X and Y data are not transformed.
100 INPUT “Enter number of data pairs? “; N
102 IF N = 0 THEN GOTO 450
105 IF N < 2 THEN GOTO 100
110 SX = 0 : SXX = 0
120 SY = 0 : SYY = 0 : SXY = 0
130 FOR I = 1 TO N
140 PRINT “X(”;I;”)? “;
: INPUT X
150 PRINT “Y(”;I;”)? “;
: INPUT Y
151 REM Optional
transformations
152 REM X = function
of X
153 X = X
154 REM Y = function
of Y
155 Y = Y
160 SX = SX + X
170 SXX = SXX + X * X
180 SY = SY + Y
190 SYY = SYY + Y * Y
200 SXY = SXY + X * Y
210 NEXT I
300 MX = SX / N
310 MY = SY / N
320 SDX =
SQR(SXX – MX * SX)/(N - 1))
330 SDY = SQR(SYY – MY * SY)/(N - 1))
340 B = (N *
SXY – SX * SY) / (N * SXX – SX^2)
350 A = MY – B * MX
360 R2 = (B * SDX / SDY)^ 2
400 PRINT “A = “; A : WAIT
410 PRINT “B = “; B : WAIT
420 PRINT “R^2 = “; R2 : WAIT
450 END
This program performs linear regression with a one-line main menu. You can customize the statements in lines 610 and 710 to perform data transformations for X and Y, respectively. These statements are in two separate subroutines called by the data addition and deletion parts of the program.
10 REM Linear regression with a menu
20 REM init stat sums
100 GOSUB 500
110 INPUT “1) Add 2)
Delete 3) Calc 4) New 5)Quit Choice=>”;C
120 ON C GOSUB 200, 300, 400, 500
160 IF C = 5 THEN GOTO 180 ELSE GOTO 110
180 PRINT “BYE!” : WAIT 200
190 END
200 REM Add observations
205 INPUT “Number of observations to add? “;M
207 IF M < 1 THEN GOTO 290
210 FOR I = 1 TO M
215 INPUT “X?”;X
220 INPUT “Y?”;Y
221 REM Optional transformations
222 GOSUB 600
223 GOSUB 700
230 N = N + 1
240 SX = SX + X
250 SXX = SXX + X * X
260 SY = SY + Y
270 SYY = SYY + Y * Y
280 SXY = SXY + X * Y
285 NEXT I
290 RETURN
300 REM Remove an observation
305 IF N < 1 THEN PRINT “No data to delete” : WAIT: GOTO
390
310 INPUT “X?”;X
320 INPUT “Y?”;Y
321 REM
Transformation
322 GOSUB 600
325 GOSUB 700
330 N = N - 1
340 SX = SX - X
350 SXX = SXX -
X * X
360 SY = SY - Y
370 SYY = SYY - Y * Y
380 SXY = SXY - X * Y
390 RETURN
400 REM Calc stats
401 IF N < 2 THEN PRINT “Not enough data” : WAIT: GOTO
490
405 MX = SX / N
410 MY = SY / N
420 SDX =
SQR(SXX – MX * SX)/(N - 1))
430 SDY = SQR(SYY – MY * SY)/(N - 1))
440 B = (N *
SXY – SX * SY) / (N * SXX – SX^2)
450 A = MY – B * MX
460 R2 = (B * SDX / SDY)^ 2
470 PRINT “A = ”; A : WAIT
480 PRINT “B = ”; B : WAIT
485 PRINT “R^2 = ”; R2 : WAIT
490 RETURN
500 REM New data
510 SX = 0 : SXX = 0 : N = 0
520 SY = 0 : SYY = 0 : SXY = 0
530 PRINT “Stat sums reset” : WAIT 200
540 RETURN
600 REM X=f(X)
610 X = X
620 RETURN
700 REM Y=f(Y)
710 Y = Y
720 RETURN
This program performs linear regression with a one-line main menu. You can customize the statements in lines 610 and 710 to perform data transformations for X, Y, and Z, respectively. These statements are in two separate subroutines called by the data addition and deletion parts of the program. The program fits data to the following model:
Z = A + B X + C Y
10 REM Multiple Linear regression with a menu
20 REM init stat sums
100 GOSUB 500
110 INPUT “1) Add 2)
Delete 3) Calc 4) New 5)Quit Choice=>”;C
120 ON C GOSUB 200, 300, 400, 500
160 IF C = 5 THEN GOTO 180 ELSE GOTO 110
180 PRINT “BYE!” : WAIT 200
190 END
200 REM Add observations
205 INPUT “Number of observations to add? “;M
207 IF M < 1 THEN GOTO 290
210 FOR I = 1 TO M
212 INPUT “X?”;X
215 INPUT “Y?”;Y
220 INPUT “Z?”;Z
221 REM Optional transformations
222 GOSUB 600
223 GOSUB 700
225 GOSUB 800
230 N = N + 1
240 SX = SX + X
235 SXX = SXX + X * X
240 SY = SY + Y
245 SYY = SYY + Y * Y
250 SXY = SXY + X * Y
255 SZ = SZ + Z
260 SZZ = SZZ + Z * Z
265 SZX = SZX + X * Z
270 SZY = SZY + Y * Z
280 NEXT I
290 RETURN
300 REM Remove an observation
305 IF N < 1 THEN PRINT “No data to delete” : WAIT: GOTO
390
310 INPUT “X?”;X
315 INPUT “Y?”;Y
320 INPUT
“Z?”;Z
321 REM
Transformation
322 GOSUB 600
325 GOSUB 700
327 GOSUB 800
330 N = N - 1
335 SX = SX - X
340 SXX = SXX -
X * X
345 SY = SY - Y
350 SYY = SYY - Y * Y
355 SXY = SXY - X * Y
360 SZ = SZ - Z
365 SZZ = SZZ - Z * Z
370 SZX = SZX - X * Z
375 SZY = SZY - Y * Z
390 RETURN
400 REM Calc stats
401 IF N < 2 THEN PRINT “Not enough data” : WAIT : GOTO
490
405 PXX = N *
SXX – SX^2
410 PYY = N *
SYY – SY^2
415 PXY = N *
SXY – SX * SY
420 PZX = N *
SZX – SZ * SX
430 PZY = N *
SZY – SZ* SY
440 C = (PXX *
PZY – PXY * PZX) / (PXX * PYY – PXY^2)
445 B = (PZX –
C * PXY) / PXX
450 A = (SZ – C
* SY – B * SX) / N
455 R2 = (A *
SZ + B * SZX + C * SZY – SZ^2 / N) / (SZZ – SZ^2 / N)
470 PRINT “A = “; A : WAIT
475 PRINT “B = “; B : WAIT
480 PRINT “C = “; C : WAIT
485 PRINT “R^2 = “; R2 : WAIT
490 RETURN
500 REM New data
510 SX = 0 : SXX = 0 : N = 0
515 SY = 0 : SYY = 0 : SXY = 0
520 SZ = 0: SZZ = 0 : SZX = 0 : SZY = 0
530 PRINT “Stat sums reset” : WAIT 200
540 RETURN
600 REM X=f(X)
610 X = X
620 RETURN
700 REM Y=f(Y)
710 Y = Y
720 RETURN
800 REM Z=f(Z)
810 Z = Z
820 RETURN
This program allows you to enter strings then sort them and search for matching text.
100 MAX = 20
110 DIM A$(MAX)
120 GOSUB 400
200 INPUT “1)Add 2)Clear 3)Sort 4)Search 5)Quit Choice=>”;C
210 ON C GOSUB 300, 400, 500, 800
250 IF C = 5 THEN GOTO 290 ELSE GOTO 200
290 PRINT “BYE!” : WAIT 200
299 END
300 REM Add
305 IF N = M THEN GOTO 350
310 N = N + 1
320 INPUT “Enter string? “; A$(N)
330 IF A$(N) <> “” THEN GOTO 310
340 N = N – 1
350 RETURN
400 REM Clear
410 FOR I = 1 TO M : A$(I) = ”” : NEXT I
420 N = 0
430 RETURN
500 REM Sort
510 FOR I = 1 TO N – 1
520 FOR J = I TO N
530 IF A$(I) <=
A$(J) THEN GOTO 550
540 S = A$(I) : A$(I)
= A$(J) : A$(J) = S
550 NEXT J
560 NEXT I
570 FOR I = 1 TO N
580 PRINT A$(I) : WAIT
200
590 NEXT I
600 RETURN
800 REM Search
810 INPUT “Search for ?”; S
820 IF S = “” THEN GOTO 890
830 FOR I = 1 TO N
840 IF S = A$(I) THEN
GOTO 870
850 NEXT I
860 PRINT S; “ was not found!” : WAIT
865 GOTO 810
870 PRINT “Found “;S; “ at index “;I : WAIT
880 GOTO 810
890 RETURN
This is a number guessing game. The program selects a secret number between 1 and 1000 and prompts you to guess that number. With each guess, the program gives you a hint if your guess is high or low. You have 10 guesses. You can change the number of guesses by assigning a different value to variable M. You can also change the range of numbers used to select the secret number by editing the statement in line 110. If you enter a guess of 0, the program stops the guessing part and displays the secret number.
100 RANDOMIZE
110 S = INT(1000 * RND) + 1
120 M = 10 : N = 0
125 INPUT “Play?”; C$
130 A$ = MID$(C$, 1, 1)
140 IF A$ = “Y” OR A$ = “y” THEN GOTO 200
150 PRINT “BYE!” : WAIT 200
160 END
200 IF N > M THEN GOTO 400
210 INPUT “Enter guess? “; G
215 IF G <= 0 THEN GOTO 400
217 N = N + 1
220 IF G = S THEN GOTO 300
230 IF G > S THEN PRINT “Too high” : WAIT 200
240 IF G < S THEN PRINT “Too low” : WAIT 200
250 GOTO 200
300 PRINT “You guess it!” : PAUSE
310 GOTO 100
400 PRINT “Out of guesses! Number was”; S : WAIT
410 IF G > 0 THEN GOTO 100 ELSE GOTO 150
The SHARP EL-5500 II/III supports statistics for single and double variables, with and without frequency data. These features make the SHARP EL-5500 II/III a very good tool to perform statistics that involve the mean, standard deviation, and linear regression.
Task |
Keystroke Sequence |
Example/Comment |
Clear statistical registers |
Shift to STAT mode |
|
Add single-variable data |
x [DATA] |
1.1[DATA] |
Add single-variable data with frequency |
x [Ï] freq [DATA] |
2.1 [Ï] 5 [DATA] |
Add paired data |
x [(x,y)] y [DATA] |
3 [(x,y)] 5 [DATA] |
Add paired data with frequency |
x [(x,y)] y [Ï] freq [S+] |
3 [(x,y)] 5 [Ï] 10 [DATA] |
Delete single-variable data |
x [SHIFT][CD] |
1.1 [SHIFT] [CD] |
Delete single-variable data with frequency |
x [Ï] freq [SHIFT] [CD] |
2.1 [Ï] 5 [SHIFT] [CD] |
Delete paired data |
x [(x,y)] y [SHIFT] [CD] |
3 [(x,y)] 5 [SHIFT] [CD] |
Delete paired data with frequency |
x [(x,y)] y [Ï] freq [SHIFT] [CD] |
3 [(x,y)] 5 [Ï] 10 [SHIFT] [CD] |
Get the mean of x |
[STAT][4] |
|
Get the mean of y |
[SHIFT][7] |
|
Get the standard deviation of x |
[SHIFT][8] |
|
Get the standard deviation of y |
[SHIFT][5] |
|
Get the linear regression intercept |
[SHIFT][2] |
|
Get the linear regression slope |
[SHIFT][3] |
|
Get the linear regression correlation coefficient |
[SHIFT][1] |
|
Project X onto Y |
x[SHIFT][0] |
2[STAT][0] |
Project Y onto X |
Y[SHIFT][+/-] |
4[STAT][+/-] |
SHARP EL-5500 II/III is a trademark of the Sharp Corporation.
Copyright © 2002 by Namir C Shammas