Saturday, September 19, 2026

Sharp EL-5200/EL-9000 AER II Program Collection – September 2026

Sharp EL-5200/EL-9000 AER II Program Collection – September 2026



For my review on the Sharp EL-5200 (also known as the Sharp EL-9000), check out this blog entry from 2024: https://edspi31415.blogspot.com/2024/04/spotlight-sharp-el-5200.html


The AER programming on Sharp is very unusual.


* Angle mode has to be set manually through the [ 2ndF ] [ FSE ] (DRG) key sequence.

* Similarly, the decimal settings have be set manually through the [ 2ndF ] [ FSE ] key sequence and setting number of decimal places through tab.

* In AER II, there are really only two ways to display messages. First, through the program title when cycling through the programs with the [ PRO ] key. Second by setting a result variable such as area=2×π×r². The display will show “area= (next line) result”.


Graphing Commands


Setting the graphing range:

RANGE xmin, xmax, xstep, ymin, ymax, ystep


Clearing the graph:

G.CL ([2ndF] [ ← ])


Plotting a point:

PLOT x, y

This may include expressions, the point must be in the graph area or an Error 2 occurs.


Drawing a line:

LINE x1, y1, x2, y2

The entire line must fine the graph area or an Error 2 occurs.


Plotting a function:

GRAPH f(X)


Auto Sizing the window (Y-range only):

AUTO

Placed before the DRAW command.


Draw and show the graph screen:

DRAW


Finally, how are loops done?

* Loops are only available on the main portion of the program, and not in the subroutines. I found this out the hard way.

* Use the Y (Yes) and N (No) results to enable the loop.

* There are only four comparisons: =, >, >=, and ≠


A sample syntax:


↳ (loop commands) (comparison) – Y ⇒ [ do if true ↰ ]

↳ (loop commands) (comparison) – N ⇒ [ do if false ↰ ]



All programs today are in AER II mode. Spaces are provided for readability.


Sharp EL-5200: Random Integers


Title: random integers

M: low=? high=? num=?

↳ num>0 -Y→[ INT (RND ×(high-low))+low,

num=num-1 ↰]


Keep on pressing [COMP] until a zero comes up, which signals the end of the list. (This assumes that low and high are both positive numbers.)


Example:


low=15, high=95, num=5

ans=41, 64, 78, 69, 17, 0





Sharp EL-5200: Work Sample Size, 95% Confidence



size = z² ÷ (%acc ÷ 100)² × (1 - #occ ÷ #obs) ÷ #obs × #occ

z: normal distribution value that indicates confidence level; for a 95% interval, z ≈ 1.9599

%acc: desired percent accuracy

#occ: number of occurrences (i.e. idle employees, targets not met, hours missed, etc.) in the preliminary sample

#obs: number of observances in the preliminary sample


Title: work sample size, with 95 percent confidence

M: size = 1.9599² ÷ (occ ÷ 100)² × (1 – occ ÷ obs) ÷ occ × obs ␣

size = INT size + 1,

rat = occ ÷ obs



The size is rounded up to the nearest integer.

rat: ratio of occurrences to observances



Examples:



Example 1:

acc: 10%, occ: 3, obs: 20.

Result: size: 2177, ratio: 0.15



Example 2:

acc: 5%, occ: 2, obs: 108

Result: size: 81,434, ratio: 0.018518519



Source:

Hewlett Packard. “Business Finance and Accounting: Step-by-Step Solutions for Your HP-17B, HP-19B, or HP-27S Calculator”. HP Part No. 00017-90020. Printed in Canada. Edition 3. Corvallis, OR. September 1991. pp. 97-98



Sharp EL-5200: Eigenvalue of a 2 x 2 Matrix



This calculates the eigenvalues of a 2 x 2 matrix, [ [ a, b ] [ c, d ] ] by the following sequence:



m = (a + d) ÷ 2

p = a * d – b * c

Eigenvalues

λ = m ± √(m² – p)



Title: eigen of [[a,b][c,d]] (real)

M: a=? b=? c=? d=?

m=(a+d)÷2 ␣

p=a×d-b×c ␣

m+√(m²-p),

m-√(m²-p)



Example:

[ [10, 8], [3, 6] ]

a=10, b=8, c=3, d=6

Result: 13.29150262, 2.708497378



Source:

3Blue1Brown. “A quick trick for computing eigenvalues | Chapter 15, Essence of linear algebra” YouTube video, posted May 7, 2021. https://www.youtube.com/watch?v=e50Bj7jn9IQ



The next three programs deal with graphics.



Sharp EL-5200: Graphing a Sine Wave



Graph of y = A × sin(B × x + C) given A, B, C. Angles are set to be in radians.



Title: graph A×sin(Bx+C). Set radians mode.

M: A=? B=? C=?

GRAPH A×SIN (B×X+C) AUTO DRAW



Sharp EL-5200: Graphing a Line



Draw a line between (a,b) and (c,d). The program determines the window by determining the maximum and minimum for two numbers:



max(x,y) = (x + y + abs(x – y)) ÷ 2

min(x,y) = (x + y – abs(x – y)) ÷ 2



The distance is displayed.



Title: draw a line between (a,b) and (c,d)

M: a=? b=? c=? d-?

dist=√((c-a)² + (d-b)²),

max=(a+c+ABS(a-c))÷2 ␣

mix=(a+c-ABS(a-c))÷2 ␣

may=(b+d+ABS(b-d))÷2 ␣

miy=(b+d-ABS(b-d))÷2 ␣

RANGE mix-1, max+1, 1, miy-1, may+1, 1 ␣

LINE a, b, c, d DRAW



Sharp EL-5200: Graphing a Rose



This program graphs the rose:

r = cos(5 * Θ) for 0 ≤ Θ ≤ π







Title: graph a rose, set rad mode

M: G.CL ␣ a=0 ␣

RANGE -1.2, 1.2, 0.2, -1.2, 1.2, 0.2 ␣

↳PLOT COS(5×a)×COS a, COS(5×a)×SIN a

DRAW a=a+π÷128 ␣

a>π – N → [ ↰ ]



Eddie


All original content copyright, © 2011-2026. 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.


Sunday, September 13, 2026

HP 71B Basic and Casio fx-CG 100: Weighted Random Sample

HP 71B Basic and Casio fx-CG 100: Weighted Random Sample




Introduction



In calculators, it is fairly easy to generate a random sample when every number or object has an equal chance to be picked. But what happens when this is not the case?


Let’s compare two bags:


Bag A has one red marble, one blue marble, one green marble, and one gold marble.


Bag B has one red marble, three blue marbles, two green marbles, and one gold marble.


Bag A has an equal amount of colored marbles, while Bag B doesn’t.


We could easily use a list to represent Bag B as such:

[red, blue, blue, blue, green, green, gold]


That is well and good when the population is small. Let’s consider a larger population:


Box C has 100 red marbles, 75 blue marbles, 100 green marbles, and 125 gold marbles. If we took the approach like we did with Bag B, we would have a list of 400 elements. Some calculators don’t even allow a list with 400 elements! And if they do, that list might take a lot of memory. This calls for a different approach.



An Approach to Consider



Consider creating a table of cumulative probabilities. Then we can use a standard random number (psuedo)generator function, which generates random number between 0 (inclusive) and 1 (not inclusive).


We will take Box C as an example. Recall that Box C has 100 red marbles, 75 blue marbles, 100 green marbles, and 125 gold marbles.


Calculate the probability of picking only one marble out of the bag.


Color

# of Marbles

Probability

Red

100

0.25

Blue

75

0.1875

Green

100

0.25

Gold

125

0.3125

Total

400



Note that sorting is not required. The next step is to calculate the cumulative probability.


Color

# of Marbles

Probability

Cumulative Probability

Red

100

0.25

0.25

Blue

75

0.1875

0.4375

Green

100

0.25

0.6875

Gold

125

0.3125

1

Total

400




The probability intervals can be set up as:


Red: 0 ≤ x < 0.25

Blue: 0.25 ≤ x < 0.4375

Green: 0.4375 ≤ x < 0.6875

Gold: 0.6875 ≤ x < 1


General a random number, for example: 0.344. Since 0.344 lies in between 0.25 and 0.4375, this corresponds to a blue marble.


Let’s say the random number is 0.678. Since 0.678 lies in between 0.4375 and 0.6875, this corresponds to a green marble.



The HP 71B Basic Problem WSAMPLE


The program is uses a container of four colored marbles: red, blue, green, and gold. Provide the number of marbles for each color and the sample size. Each pick is shown to be separately noted on paper or computer.


Note that this a sample with replacement (whatever is picked is returned to the population, which could allow repeats).


Code (365 bytes):


100 DESTROY ALL

105 OPTION BASE 1

110 DIM S$(4)[5]

115 DIM W(4)

120 S$(1)="RED"

125 S$(2)="BLUE"

130 S$(3)="GREEN"

135 S$(4)="GOLD"

140 DISP "# OF MARBLES?" @ WAIT .5

145 T=0

150 FOR I=1 TO 4

155 DISP S$(I) @ WAIT .5

160 INPUT W(I)

165 T=T+W(I)

170 NEXT I


200 U=0

205 DISP P(4),C(4)

210 FOR I=1 TO 4

215 P(I)=W(I)/T

220 U=U+P(I)

225 C(I)=U

230 NEXT I


300 INPUT "SIZE? ";N

305 FOR I=1 TO N

310 R=RND

315 J=1

320 X=C(J)

325 IF R>=X THEN 400

330 DISP STR$(I)&": "&S(J) @ PAUSE

335 NEXT I

340 END


400 J=J+1

405 GOTO 320



Examples (results will vary):


Example 1: (n = 5)

1: GREEN

2: RED

3: GOLD

4: RED

5: GREEN


Example 2: (n = 5)

1: BLUE

2: GREEN

3: GREEN

4: RED

5: GREEN


Example 3: (n = 10)

1: RED

2: GOLD

3: BLUE

4: BLUE

5: GREEN

6: GREEN

7: GOLD

8: RED

9: RED

10: GREEN



Casio fx-CG 100 Python: Weighted Random Sample



This program script, wsample.py, asks for a list of labels and the population for each label. This allows flexibility for additional applications.


Note that this a sample with replacement (whatever is picked is returned to the population, which could allow repeats).


Code:



# EWS 2026-09-05

from math import *

from random import *


print("Weighted Random Sample")

s=eval(input("Label List? "))

w=eval(input("Weights List? "))

n=int(input("Sample Size? "))


# determine probabilities

p=[i/sum(w) for i in w]


# cumulative sums

c=[sum(p[:i+1]) for i in range(len(p))]


# build sample

x=[]

for i in range(n):

  r=random()

  i=0

  while r>=c[i]:

    i+=1

    # end while

  x.append(s[i])

  # end for  


print(x)



Example (results will vary):


Example 1:

labels: [“red”, “blue”, “green”, “yellow”]

weights list: [ 5, 15, 10, 5 ]

sample size: 10

result: [“yellow”, “green”, “green”, “blue”, “yellow”, “green”, “yellow”, “green”, “red”, “green”]


Example 2:

labels: [“purple”, “orange”, “teal”, “gray”, “mint”]

weights list: [10,20,10,10,20]

sample size: 10

result: [“mint”, “gray”, “teal”, “purple”, “orange”, “purple”, “gray”, “mint”, “orange”, “orange”]



Hopefully this approach is useful.


Eddie


All original content copyright, © 2011-2026. 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.




Saturday, September 12, 2026

Trigonometry Reduction Formula and Solving Simple Arcsine and Arccosine Equations

Trigonometry Reduction Formula and Solving Simple Arcsine and Arccosine Equations




Some Background and Periodic Reduction Formulas


This blog will focus on angle measurement in degrees. For radians and grads, please use the appropriate measurement.


90° = π/2 rad = 100 grad

180° = π rad = 200 grad


sin 90° = 1, sin 180° = 0, sin 360° = 0, sin(-x) = -sin(x)

cos 90° = 0, cos 180° = -1, cos 360° = 1, cos(-x) = cos(x)


General Sums


sin(α + ß) = sin α * cos ß + sin ß * cos α


sin(α + 90°) = sin α * cos 90° + sin 90° * cos α = cos α

sin(α + 180°) = sin α * cos 180° + sin 180° * cos α = -sin α

sin(α + 360°) = sin α * cos 360° + sin 360° * cos α = sin α

sin(90° - α) = sin 90° * cos(-α) + cos 90° * sin(-α) = cos(-α) = cos α

sin(180° - α) = sin 180° * cos(-α) + cos 180° * sin(-α) = -1 * -sin α = sin α


cos(α + ß) = cos α * cos ß – sin α * sin ß


cos(α + 90°) = cos α * cos 90° – sin α * sin 90° = -sin α

cos(α + 180°) = cos α * cos 180° – sin α * sin 180° = -cos α

cos(α + 360°) = cos α * cos 360° – sin α * sin 360° = cos α

cos(90° - α) = cos 90° * cos(-α) – sin 90° * sin(-α) = -sin(-α) = sin α

cos(180° - α) = cos 180° * cos(-α) – sin 180° * sin(-α) = -1 * cos(-α) = -cos α



The Trigonometric Reduction Formula


a * sin(x) + b * cos(x) = √(a² + b²) * sin(x + Θ)


Let x = 90°:

a * sin(90°) + b * cos(90°) = √(a² + b²) * sin(90° + Θ)

a * 1 + b * 0 = √(a² + b²) * cos(Θ)

⇒ cos(Θ) = a ÷ √(a² + b²)


Let x = 180°:

a * sin(180°) + b * cos(180°) = √(a² + b²) * sin(180° + Θ)

a * 0 + b * -1 = √(a² + b²) * -sin(Θ)

-b = -sin(Θ) * √(a² + b²)

⇒ sin(Θ) = b ÷ √(a² + b²)


Then:

sin(Θ) = b ÷ √(a² + b²)

cos(Θ) = a ÷ √(a² + b²)

[sin(Θ) ÷ cos(Θ)] = [ b ÷ √(a² + b²) ] ÷ [ a ÷ √(a² + b²) ]

tan(Θ) = b ÷ a

Θ = arctan(b ÷ a)





Wikibooks uses the Algebraic Argument (see source):



a * sin(x) + b * cos(x)

= [ √(a² + b²) ÷ √(a² + b²) ] * [ a * sin(x) + b * cos(x) ]

= √(a² + b²) * ( a ÷ √(a² + b²) * sin(x) + b ÷ √(a² + b²) * cos(x) )

= √(a² + b²) * ( cos(Θ) * sin(x) + sin(Θ) * cos(x) )

= √(a² + b²) * sin(x + Θ)



Solving Simple Arcsine Equations


The calculator arcsine function gives: Domain: -1 ≤ x ≤ 1, Range: -90° ≤ Θ ≤ 90°


Note that for any angle x: sin(180° - x) = sin(x), sin(x) = sin(x ± 360°*z) (z is an integer)


Given n, solve for Θ:

n = sin(Θ) = sin(180° - Θ)


Base Solution 1:

n = sin(Θ)

⇒ Θ = arcsin(n)


Base Solution 2:

n = sin(180° - Θ)

arcsin(n) = 180° - Θ

⇒ Θ = 180° - arcsin(n)


Example:

0.67 = sin(Θ)

Base Solution 1: Θ = arcsin(0.67) ≈ 42.0670648025°

Base Solution 2: Θ = 180° - arcsin(0.67) ≈ 137.932935198°


Given n and α, solve for Θ:

n = sin(α + Θ)


Base Solution 1:

n = sin(α + Θ)

arcsin(n) = α + Θ

⇒ Θ = arcsin(n) – α


Base Solution 2:

n = sin(180° - (α + Θ))

n = sin(180° - α – Θ)

arcsin(n) = 180° - α – Θ

⇒ Θ = 180° - α – arcsin(n)


Example:

0.7757 = sin(Θ + 76°)

Base Solution 1: Θ = arcsin(0.7757) – 76° ≈ -25.1314549842°

Base Solution 2: Θ = 180° - 76° - arcsin(0.7757) = 104° - arcsin(0.7757) ≈ 53.131459842°


To get all the possible angles, add and subtract multiples of 360°.


Solving Simple Arccosine Equations


The calculator arccosine function gives: Domain: -1 ≤ x ≤ 1, Range: -90° ≤ Θ ≤ 90°


Note that for any angle x: cos(180° - x) = -cos(x), cos(x) = cos(x ± 360°*z) (z is an integer)


Given n, solve for Θ:

n = cos(Θ), n = cos(-Θ)


Base Solution 1:

n = cos(Θ)

⇒ Θ = arccos(n)


Base Solution 2:

n = cos(-Θ)

⇒ Θ = -arccos(n)


Example:

0.58 = cos(Θ)

Base Solution 1: Θ = arccos(0.58) ≈ 54.54945736°

Base Solution 2: Θ = -arccos(0.58) ≈ -54.54945736°


Given n and α, solve for Θ:

n = cos(α + Θ)


Base Solution 1:

n = cos(α + Θ)

arccos(n) = α + Θ

⇒ Θ = arccos(n) – α


Base Solution 2:

n = cos(-(α + Θ))

n = cos(-α – Θ)

arccos(n) = -α – Θ

-arccos(n) = α + Θ

⇒ Θ = -arccos(n) – α


Example:

0.6 = cos(35° + Θ)

Base Solution 1: Θ = arccos(0.6) – 35° ≈ 18.13012035°

Base Solution 2: Θ = -arccos(0.6) – 35° ≈ -88.13010235°



To get all the possible angles, add and subtract multiples of 360°.



Sources

Sterling, Mary Jane. Trigonometry for Dummies. 2nd Edition. John Wiley & Sons, Inc. Hoboken, NJ. 2014. pp. 351-352. ISBN 978-1-118-82741-3


“Trigonometry/Simplifying a sin(x) + b cos(x)”. Wikibooks. January 2, 2024. Retrieved January 4, 2026. https://en.wikibooks.org/wiki/Trigonometry/Simplifying_a_sin(x)_%2B_b_cos(x)


Eddie


All original content copyright, © 2011-2026. 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.


Saturday, September 5, 2026

Python – Earth’s Radius and Gravity in US Units

Python – Earth’s Radius and Gravity in US Units



Introduction



The following script, gravus2.py, estimates the Earth’s gravity in ft/sec^2 given:



1. The observer’s latitude on Earth (North or South; you don’t have to enter negative numbers for South)

2. The elevation where the observer is in feet.



The Python script is made with a TI-84 Evo, but it should work with all platforms with Python.



Equation Used: With Everything Converted to U.S. Units:



Calculating g_0 at sea level with latitude φ:

g_0 = 32.17192 – 0.08530 * cos(2 * φ°) = 32.17192 – 0.08530 * cos(2 * φ * π ÷ 180)



Calculating g_h with height h:

g_h = g_0 * (erad ÷ (erad + h ÷ 5280))^2



Where (Earth’s radius at latitude φ):

erad = √((a^4 + b^4 * tan(φ)^2) ÷ (a^2+ b^2 * tan(φ)^2)) 



a = 3963.1905919

b = 3949.90276423189



Code: gravus2.py


'''

Earth's Gravity in US Units

EWS 05/26/2026

'''


from math import *


# title screen

print("Earth's Gravity")

print("Given Latitude and Elevation")

print("U.S./Imperial Units")

print("-----------------")


# angles must be converted to radians


print("Latitude in DMS:")

l1=eval(input("Whole Degrees? "))

l2=eval(input("Whole Minutes? "))

l3=eval(input("Seconds? "))

langle=l1+l2/60+l3/3600

# convert to radians

langle*=pi/180

# elevation

elev=eval(input("Elevation in feet? "))

# calculate radius 

a=3963.1905919

b=3949.90276423189

erad=(a**4+b**4*(tan(langle))**2)

erad/=(a**2+b**2*(tan(langle))**2)

erad=sqrt(erad)

# calculation

g=32.17192-0.08530*cos(2*langle)

g*=(erad/(erad+elev/5280))**2

print("Earth's radius: {0:.5f} mi".format(erad))

print("Estimated Gravity: {0:.5f} ft/s**2".format(g))



Examples (Results are rounded to five decimal places)



Latitude (φ)

Height (h ft)

Earth’s Radius (mi)

g_h (ft/s^2)

34°03’00”

500

3959.04875

32.13857

64°11’27”

1650

3952.43868

32.21979

10°57’00”

395

3962.71501

32.09156





Source



Grainger Engineering Office of Marketing and Communications. (answer written by Rebecca H.) (2016, November 21). “How gravitational force varies at different locations on Earth.” Illinois. https://van.physics.illinois.edu/ask/listing/64061. Retrieved March 10, 2026.

Planetcalc. “Earth Radius by Latitude (WGS 84)” Timur. 2021. https://planetcalc.com/7721/ Retrieved March 22, 2026.



Eddie


All original content copyright, © 2011-2026. 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.


Sharp EL-5200/EL-9000 AER II Program Collection – September 2026

Sharp EL-5200/EL-9000 AER II Program Collection – September 2026 For my review on the Sharp EL-5200 (also known as the Sharp EL-9000)...