## Sunday, April 21, 2024

### Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

The HP 16C’s #B Function

The #B function is the HP 16C’s number of bits function and sums the bits that are “turned on”. To find #B, if needed, convert the number to its binary form (base 2). #B are the number of ones. Here, I am assuming the binary integers are unsigned.

For example: Calculate #B(49). Assuming 49 is in decimal base.

49_10 = 110001_2

Then #B(49) = 3

Casio fx-CG 50 Program: BITS

I thought the fx-CG 50 had functions to convert integers and logical functions, but I did not have find them. If anyone knows whether the fx-CG 50 has base conversions, please let me know. I know that earlier Casio graphing calculators had base conversions.

The binary integer form is stored in B, as long as the decimal integer is less than 2048. (2^11).

Size: 168 bytes

“DEC→BIN”

“D”? → N

N → M

0 → C

0 → B

Int (log N ÷ log 2) → L

For L → J To 0 Step -1

If M ≥ 2^J

Then

C + 1 → C

M – 2^J → M

B × 10 + 1 → B

Else

B × 10 → B

IfEnd

Next

ClrText

If N < 2049

Then

“BIN=”

B ◢

IfEnd

“#B=”

C

The hashtag character (#) is called from the CHAR menu.

Swiss Micros DM32 Program: BITS

Two labels are used:

LBL B: 68 bytes

LBL T: 92 bytes

The main program is LBL B. This should fit on the classic HP 32S/32SII calculators.

B01 LBL B

B02 CF 0

B03 SF 10

B04 “DEC NUMB”

B05 PSE

B06 INPUT N

B07 STO M

B08 Clx

B09 STO C

B10 RCL N

B11 LOG

B12 2

B13 LOG

B14 ÷

B15 IP

B16 1

B17 +

B18 STO L

T01 LBL T

T02 RCL M

T03 2

T04 RCL L

T05 1

T06 -

T07 y^x

T08 -

T09 x≥0?

T10 SF 0

T11 FS? 0

T12 LASTx

T13 FS? 0

T14 STO- M

T15 FS? 0

T16 1

T17 FS? 0

T18 STO+ C

T19 CF 0

T20 DSE L

T21 GTO T

T22 RCL N

T23 BIN

T24 STOP

T25 “BITS=”

T26 PSE

T27 CF 10

T28 DEC

T29 VIEW C

T30 GTO B

Examples

Decimal: 35, Binary: 100011, #B(35) = 3

Decimal: 36, Binary: 100100, #B(36) = 2

Decimal: 37, Binary: 100101, #B(37) = 3

Decimal: 50, Binary: 110010, #B(50) = 3

Decimal: 51, Binary: 110011, #B(51) = 4

Decimal: 52, Binary: 110100, #B(52) = 3

Sources

Hewlett-Packard. HP-16C Computer Scientists Owner’s Handbook. Hewlett-Packard Company. 1982. pg. 52

Eddie

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

### Sharp EL-9300 Programs

Sharp EL-9300 Programs

Today’s blog entry takes us to the 1992 Sharp’s EL-9300 graphing calculator. On January 10, 2022, I gave a review of this calculator:

https://edspi31415.blogspot.com/2022/01/retro-review-sharp-el-9300c.html

The programs should also work on the EL-9200. Spaces are added for readability.

Sharp EL-9300 Program: polygon2

The program polygon2 calculates four properties of regular polygons:

* The internal angle of the polygon

* The length of the polygon’s apothem

* The length of the polygon’s radius

* The area of the polygon

A regular polygon is a polygon whose sides all have equal length and all the internal angles are equal.

REAL Mode

Print “Set Degrees 1st”

Wait 1

Print “number of sides”

Input n

Print “side length”

Input x

angle = (n – 2) / n * 180

apothem = x / 2 * tan (angle / 2)

radius = x / (2 * cos (angle / 2) )

area = n * x * apothem / 2

ClrT

Print angle

Print apothem

Print area

Note that the calculator must be set in Degrees mode prior to running this program. To set the degrees mode, press [ SET UP ], [ B ], [ 1 ]. Note that this won’t set the angle mode indicator in the program as the angle mode change takes place outside of the program script.

Examples

Inputs: n = 6, x = 8

Outputs:

angle = 120 (internal angle)

apothem = 6.92820323

area = 166.2768775

Inputs: n = 12, x = 1.5

Outputs:

area = 150

apothem = 2.799038106

area = 25.19134295

Sharp EL-9300 Program: agm

The program agm calculates the arithmetic-geometric mean between two numbers x and y.

(x + y) / 2

√(x * y)

The program also asks for the tolerance. If the tolerance is small, it means we are asking for better accuracy at the expense of additional calculations.

REAL Mode

ClrT

Print “arithmetic/”

Print “geometric mean”

Input x

Input y

Print “tol (10^-nn)”

Input tol

Label loop

a = (x + y) / 2

g = √(x * y)

x = a

y = g

If abs(a – g) >= tol Goto loop

ClrT

Print “results”

Print a

Print g

End

Examples

Inputs: x = 15, y = 70, tol = 10^-6

Outputs:

a = 37.28076573

g = 37.28076573

Inputs: x = 1649, y = 1248, tol = 1E-7

Outputs:

a = 1441.519759

g = 1441.519759

The EL-9300 is pretty quick.

a * x^2 + b * x + c = 0

where a, b, and c can be real or complex numbers.

COMPLEX Mode

ClrT

Print “ax^2+bx+c=0”

Print “complex numbers”

Input a

Input b

Input c

x = (-b + √(b^2 – 4 * a * c)) / (2 * a)

z = x - √(b^2 – 4 * a * c) / a

ClrT

Print “solutions=”

Print x

Print z

End

Examples

Inputs:

a = 4 + 3i, b = 2 – 5i, c = 3i

Solutions:

x = 0.346818295 – 0.288439118i

z = -0.066818295 + 1.328439118i

Inputs:

a = 2, b = -6i, c = -4 + 8i

Solutions:

x = 1.370730624 + 0.040924113i

z = -1.370730624 + 2.959075887i

Sharp EL-9300 Program: twobytwo

The program twobytwo solves the simultaneous set of equations:

a * x + b * y = e

c * x + d * y = f

where a, b, c, d, e, and f can be complex numbers.

COMPLEX Mode

Print “2x2 system”

Print “complex numbers”

Print “A=((a,b)(c,d))”

Input a

Input b

Input c

Input d

Print “B=((e)(f))”

Input e

Input f

g = a * d – b * c

h = e * d – f * b

i = a * f – c * e

x = h / g

y = i / g

ClrT

Print “solutions=”

Print x

Print y

End

Examples

Input:

a = 3 + 2i, b = -i

c = 3 – 2i, d = 1 – i

e = 0, f = 5i

Outputs:

x = -0.660377358 + 0.188679245i

y = -0.754716981 + 2.358490566i

Input:

a = 3, b = -6

c = 3i, d = 6i

e = 1, f = -i

Outputs:

x = 0

y = -0.166666667

Eddie

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

### Spotlight: Sharp EL-5200

Spotlight: Sharp EL-5200

As we come on the 13th (April 16) anniversary of this blog, I want to thank you. Blogging about mathematics and calculators is a joy in my life and I’m grateful for your support.

Today’s spotlight is about an early graphing calculator, which is a rare collector’s item today: the Sharp EL-5200, also known as the Sharp EL-9000.

Quick Facts

Model: EL-5200/EL-9000

Company: Sharp

Timeline: 1986 – late 1980s

Type: Graphing, Programmable

Memory: 5,120 bytes

Power: 2 x CR2032 batteries

Keyboard

There are excellent reviews and articles on the Sharp EL-5200/EL-9000, please check out the Sources section below.

The EL-5200 is a folding calculator which is housed in a wallet. On the left side, we have the scientific keys, the arrow keys, memory keys, and the numeric keypad. The keys are the normal calculator keys.

On the right side, there are the alphabetic keys and the utility keys. I think the key style on the right side is a membrane keyboard, but I am not sure.

The Four Main Modes

The four main modes of the Sharp EL-5200 are, which are listed in switch order:

STAT mode

COMP mode

AER II mode

AER I mode

AER II and AER I modes are programming mode, which is called the Algebraic Expression Reserve mode. The AER I mode is the classic AER mode while AER II is the newer version of programming mode.

STAT Mode

This is the calculator's statistics mode. Upon switching to this mode, we have the option of storing data points. Data points are stored in array S while basic statistics are stored in array Z. The basic statistics stored in array Z are:

Z[1] = n

Z[2] = Î£x

Z[3] = Î£x^2

Z[4] = Î£xy

Z[5] = Î£y

Z[6] = Î£y^2

Be aware when you decide to store data, it takes up programming memory.

Three keys are remapped as follows:

[ RM ]: CD. Clear data. Erases a data point.

[ ⇒M ] (x, y): Adds a comma between the x point and y point.

[ M+ ] DATA: Adds a data point.

The statistic variables are access through the second function ([2ndF]) of the numeric keypad and arithmetic keys.

Linear regression is offered in the form of y = a + bx. The variable a is the y-intercept while the variable b is the slope.

Adding × n before pressing [ M+ ] {DATA} adds the frequency to the data point.

Graphs of statistical data are available, including histograms, linear regression lines, and scatter plots.

Fairly simple.

COMP MODE

This is our calculation mode. In addition to our regular scientific calculator, which operates in algebraic mode, there are other sub-modes included in COMP Mode.

Graphing

We can graph up to two functions at one time. The [ RANGE ] key allows to set the range parameters, while the [ AUTO ] key sets the zoom level automatically. The [DRAW] key draws the graph.

For example, to draw y(x) = x^2 + 5 using automatic zoom, key in [ GRAPH ] [ X ] [ x^2 ] [ + ] 5 [ AUTO ] [ DRAW ].

The screen takes up the entire left hand of the screen. The screen shows one coordinate at a time, X or Y. Switch between the two with the key sequence [ 2ndF ] [ ↑ ] {X<>Y}.

Matrices

The EL-5200 can store up to 26 matrices A-Z. Operations include determinant, inverse, transpose, and matrix arithmetic. We can get to the arrays at any time by pressing [ 2ndF] [↓].

In fact, the [ 2ndF ] [ ↓ ] toggles between the text (calculator), graphics, and data/array screen.

The [ 2ndF ] [ A ] {DIM} sequence can set the dimensions of a matrix.

In the data screen, we see two elements at one time.

Base Conversions

Integers can be converted between four bases: hexadecimal, binary, decimal, and octal. (bases 16, 2, 10, and 8, respectively) Not much more than arithmetic is offered.

Running Programs

Finally, COMP mode is where we run AER programs. Scroll through the programs with the [ PRO ] button. Start programs and enter data at the prompts by using the [ COMP ] key.

AER I MODE

AER I mode is the classic programming mode for Sharp programming calculators. This mode is meant for simple calculations. The [ f()=/? ] key puts the input form     f( )=. Enter the variables in between the parenthesis, and the variables will automatically be prompted. For example f(AB)= prompts for the variable A, then B. Only global variables (A – Z) are used. Implied multiplication is allowed. This mode is similar to the AER mode of EL-5100 from 1979.

Title:

CIR.1

Code:

M: f( R ) = Ï€ × R^2 ⇒ A, 2 × Ï€ × R ⇒ C

AER II MODE

AER II is the full programming mode. In this mode, we can use both global and local variables, with local variables being the default. Local variables include lower case letters and subscript numbers. Subscript numbers are entered by the sequence [ 2ndF ] [ number key ]. In this mode, the [ f()=/? ] key adds a question mark to the variable and creates a prompt. Unlike AER I, implied multiplication is not allowed.

Example: Graphing a Sine Wave

Title:

Code:

M: A = ? B = ? C = ? GRAPH A × SIN (B × X + C) AUTO DRAW

There is no Radians mode command, so the user has to set Radians mode during program execution.

Common to Both Program Modes

M: This is the main loop.

, (comma): Displays the result of a calculation and pauses the execution. Press [ COMP ] to continue.

␣ (open space) : Finishes a calculation without stopping.

◣ (right triangle): Ends the current program or subroutine.

↳ ↰ : Loop markers

(comparison) -Y→[(do if true)] -N→[(do if false)]: If Then Else Structure.

[ 2ndF ] {SUB}: Creates a new subroutine. Switch between subroutines and the main loop by pressing [ 2ndF ] [ ↑ ] or [ 2ndF ] [ ↓ ].

To create a new program, go to either AER I or AER II mode, press [ COMP ], enter the title. The title is not limited to eight characters. Since we do not have string or string functions, include descriptive information and reminders in the title (see the example in AEI II Mode above).

I find the symbols taking a bit getting used to because we have symbols instead of the regular If-Then-Else-End structure, For-Next loop, Lbl-Goto structure, etc. AER can store complex formulas and best are for simple number crunching.

Overall Thoughts

I like the separate alphabetic keys, but the membrane keyboard calls for extra care when using those keys. The number of features of the EL-5200 are very invented and advanced for 1986. I wish the AER programs had line returns instead everything smashed together in wrap around lines, but it is more for readability. The calculator has a nice, compact form and is fun to work with.

In the future I will be posting AER programs for the EL-5200. It’s rarity makes the EL-5200/EL-9000 collectible.

Sources

Calculator Culture. “Sharp EL-9000 Graphing Calculator from 1986” November 27, 2023.

Gelhaus, Matthew & Taia Gelahus. “Sharp EL-5200” gelahus.net. Last Updated December 21, 2023. http://www.gelhaus.net/cgi-bin/page.py?loc:8bit/+content:EL-5200.html Retrieved March 1, 2024.

Magyarra, VÃ¡ltÃ¡s “History and Programming of AER Calculators”. Milestone in the History of Calculators. Virtual Museum of Calculators. 2016. Retrieved March 25, 2024. http://www.arithmomuseum.com/szamologep.php?id=25&lang=en

Sharp Corporation. Sharp Scientific Calculator Super Scientific Model EL-9000 Operation Manual

(website hosted by hopto.org) (this the same manual for the EL-5200)

Eddie

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

### HP Prime: Hagen-Poiseuille Law

HP Prime: Hagen-Poiseuille Law

The Hagen-Poiseuille Law relates flow of water with the change in pressure in the pipe:

Q = K × D^4 × Î”P / (Î¼ × L) where:

K = constant = Ï€ / 128 (dependent on the pipe’s diameter)

D = diameter of the pipe (in m)

L = length of the pipe (in m)

Î”P = change in pressure (in Pa)

Q = flow rate (in m^3/s)

Î¼ = viscosity of water (Pa a)

Short Table of Viscosity of Water

 Temperature Viscosity of Water (mPa s) 5 °C (41 °F) 1.5182 10 °C (50 °F) 1.3059 15 °C (59 °F) 1.1375 20 °C (68 °F) 1.0016 25 °C (77 °F) 0.89 30 °C (86 °F) 0.7972

Note that 1 Pa s = 1,000 mPa s

The program references the above table for certain temperatures. The program asks for temperature in degrees Celsius (°C). If any other temperature is entered, the empirical formula known as the Vogel-Fulcher-Tammann Equation is used:

Î¼ = 0.02939 × e^( 507.88 K ÷ (T K – 149.3 K))

= 0.02939 × e^( 507.88 K ÷ ((T °C + 273.15) K – 149.3 K))

= 0.02939 × e^( 507.88 ÷ (T + 123.85))

Equations

Calculating flow:

Q = (Ï€ × D^4 × Î”P)/(128 × Î¼ × L)

Calculating Pressure Change:

Î”P = Q × Î¼ × L × 128/(D^4 × Ï€)

HP Prime Code: Hagen-Poiseuille Law

EXPORT HAGEN()

BEGIN

// 2024-02-22 EWS

// local variables

LOCAL ch1;

LOCAL u,t,d,l,p,q;

LOCAL t1,t2,t3;

// list of temps

t1:={"5°C","10°C","15°C",

"20°C","25°C","30°C","Other"};

t2:={1.5182,1.3059,1.1375,

1.0016,0.89,0.7972};

t3:={5,10,15,20,25,30};

// inputs

INPUT({{t,t1},d,l,{ch1,{"Î”Pressure",

"Flow Rate"}}},

"Hagen-Poisuelle Law",

{"t:","d:","l:","Solve for:"},

{"Temp of water (ÂºC)","Pipe Diameter (m)",

"Pipe Length (m)"});

// temp to viscosity

// from table

IF t≤6 THEN

u:=t2(t)/1000;

t:=t3(t);

ELSE

// empirical formula

INPUT(t,"Enter temp in °C","t:");

u:=0.02939*e^(507.88/(t+123.85))/1000;

END;

PRINT();

PRINT("RESULTS:");

PRINT("Temperature: "+STRING(t)+" °C");

PRINT("Viscosity = "+STRING(1000*u)+" mPa s");

// solve for pressure

IF ch1==1 THEN

INPUT(q,"Enter flow rate","q:","m^3/s");

p:=q*u*l*128/(d^4*Ï€);

PRINT("Î”Pressure = "+STRING(p)+" Pa");

RETURN {t,u,p};

END;

// solve for flow rate

IF ch1==2 THEN

INPUT(p,"Î”Pressure:","Î”p:","Pa");

q:=(Ï€*d^4*p)/(128*u*l);

PRINT("Flow Rate = "+STRING(q)+" m^3/s");

RETURN {t,u,q};

END;

END;

Examples

Example 1:

Temp = t = 20°C

Flow = q = 0.5 m^3/s

Solve for Î”p

Results:

Viscosity = Î¼ = 1.0016 mPa s

Pressure Change = Î”p = 199.261988751 Pa

Example 2:

Temp = t = 10°C

Pressure Change = Î”p = 150 Pa

Result:

Viscosity = Î¼ = 1.3059 mPa s

Flow = q = 0.28868299137 m^3/s

Example 3:

Temp = t = 33°C

Flow = q = 0.36 m^3/s

Solve for Î”p

Results:

Viscosity = Î¼ = 0.748935277403 mPa s

Pressure Change = Î”p = 107.277076309 Pa

Sources

Lauga, Eric. Fluid Mechanics: A Very Short Introduction. Oxford University Press: Oxford, UK 2022. pp. 36-37

“Fluid of Viscosity” Wikipedia. https://en.wikipedia.org/wiki/Viscosity Retrieved February 5, 2024.

“Viscosity of Liquids and Gases” and “Viscosity of Water” HyperPhysics. http://hyperphysics.phy-astr.gsu.edu/hbase/Tables/viscosity.html Retrieved February 8, 2024.

Until next time,

Eddie

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

### Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...