## Wednesday, January 30, 2019

### HP 71B: Product of f(x), Nested Radicals, How Much Can I Afford?, Cardiac Analysis

HP 71B:  Product of f(x), Nested Radicals, How Much Can I Afford?, Cardiac Analysis

Product of a Function

∏ f(x)

Edit f(x) at line 10

PROGRAM PRODFX
At least 90 bytes, 1/23/2019

10 DEF FNF(X)=[ insert f(X) here ]
20 INPUT "Lower=";L
30 INPUT "Upper=";U
40 P=1
50 FOR X=L TO U @ P=P*FNF(X) @ NEXT X
60 DISP 'P=';P

Example:  f(X) = FNF(X) = 1/X
Lower:  1
Upper:  5
Result:  6.61375661376E-6

Trigonometric Simplification

Original blog entry (11/15/2018):  http://edspi31415.blogspot.com/2018/11/ti-84-and-casio-fx-cg-50-micropython.html

Source: Dugopolski, Mark  Trigonometry Addison Wesley: Boston 2003 pp 211-212  ISBN 0-201-70338-6

Simply the expression:

a sin x + b cos x = r * sin( θ + x )
where r = √(a^2 + b^2), θ = angle(a,b) = arg(a+bi)

PROGRAM SCTOSIN
114 bytes, 1/23/2019

10 DESTROY A,B,R,T
30 DISP "A*SIN(X)+B*COS(X)" @ PAUSE
40 INPUT "A=";A
50 INPUT "B=";B
60 R=SQR(A^2+B^2) @ T=ANGLE(A,B)
70 DISP R;"*SIN(";T;"+X)"

Line 70 can use PRINT
SQR is √

Example:
A = 2.25,  B = 1.76
Result:
R = 2.85658887486  (scroll left)
θ = .663806440909
Output:
2.85658887486  *SIN( .663806440909 +X)

How Much Car Can You Afford?

Original blog entry (3/13/2018):  https://edspi31415.blogspot.com/2018/03/hp-prime-car-payment-and-affordability.html

Calculate how much the buyer can afford, considering sales tax, discounts, and down payment.  All amounts are entered as positive.

PROGRAM AFFORD
221 bytes, 1/24/2019

10 DESTROY N,I,S,X,W,D,P
20 INPUT "# MONTHS:";N
30 INPUT "RATE %:";I @ I=I/1200
40 INPUT "PAYMENT \$";X
50 INPUT "SALES TAX %:";S
60 INPUT "DISCOUNT %:";D
70 INPUT "DOWN PMT \$";W
80 P=1/I*(1-(1+I)^(-N))
85 P=P*X
90 P=(P+W)/((1+.01*S)*(1-.01*D))
95 PRINT USING "'AMT: \$'7D.DD";P

Example:
Term: N = 60 months
Interest Rate:  I = 4.8%
Desired Payment: X = \$295
Sales Tax: S = 9.5%
Discount: D = 10%
Down Payment: W=\$1500

Result:
AMT: \$17657.09

HP 71B: Cardiac Programs

Source:  Hewlett Packard.  "HP-65 Medical Pac 1" 1974.

Valve Area

Variables:

Input:
P = pressure gradient data (mmHg), enter an average or data points
C = cardiac output (CO) (l/min)
R = R-R interval (seconds)
T = the time the valve is open (seconds)

The program offers a choice between calculating an  area of a regular valve or a mitral valve.

Program VALVE
433 bytes, 1/28/2019

10 DESTROY K,P,N,D,P1,C,R,T,F,V
20 P1=0 @ N=0 @ P=0
30 PRINT "PRESSURE (mmHg)" @ WAIT .5
35 INPUT "P: 1=AVG 2=DATA ";K
38 IF K=1 THEN 50 ELSE 40
40 INPUT "P DATA: ";D
42 P=P+D @ N=N+1 @ P1=P/N
44 INPUT "DONE? 1=YES 2=NO ";K
46 IF K=2 THEN 40 ELSE 60
50 INPUT "P AVG. :";P1
60 INPUT "CO (l/min): ";C
62 INPUT "R-R (sec): ";R
64 INPUT "OPEN TIME (sec/min):";T
66 F=C*R/(60*T) @ V=F/(.0445*SQR(P1))
68 INPUT "MITRAL 1=YES 2=NO ";K
70 IF K=1 THEN LET V=V/.7
72 PRINT "MEAN FLOW (l/sec) :";F @ PAUSE
74 PRINT "AREA (cm^2) :";V

Anatomic Shunts

The program SHUNTS calculates the bi-directional shunts as a percentage.  The shunts are R-L (right-left) shunt and the L-R (left-right) shunts.

Variables:

Input:
R1:  right pulmonary artery
R2:  right atrium
L1:  left pulmonary artery
L2:  left ventricle

Program SHUNT
230 bytes, 1/27/2019

10 DESTROY L1,L2,R1,R2,L3,R3
20 INPUT "R-PULMONARY%:";R1
30 INPUT "R.ATRIUM%:";R2
40 INPUT "L-PULMONARY%:";L1
50 INPUT "L.ATRIUM%";L2
60 R3=(L1-L2)/(L1-R2)*100
65 L3=(R1-R2)/(L1-R2)*100
70 PRINT USING ' "R-L SHUNT:"4D.DD"%" ';R3 @ PAUSE
75 PRINT USING ' "L-R SHUNT:"4D.DD"%" ';L3
90 END

Stroke Work

The program STRKWORK calculates stroke work and stroke work index based on pressure, cardiac output (CO), R-R interval (seconds), and body surface area (BSA).  The BSA is optional but is needed to calculate stroke work index.

Program STRKWORK
404 bytes, 1/28/2019

10 DESTROY S,S1,P,P1,R,C,N,K,D,B
14 DISP "P=PRESSURE mmHg" @ WAIT .5
20 N=0 @ P=0
25 INPUT "P 1:AVG 2:DATA ";K
30 IF K=1 THEN 50
40 INPUT "P. DATA PT: ";D
42 P=P+D @ N=N+1 @ P1=P/N
44 INPUT "DONE? 1=YES 2=NO ";K
46 IF K=2 THEN 40 ELSE 60
50 INPUT "AVG P: ";P1
60 INPUT "R-R INTERVAL (sec):";R
62 INPUT "CO (L/MIN): ";C
70 S=13.6*P1*C*R/60
72 PRINT "SW =";S;"(gm m)" @ PAUSE
80 INPUT "BSA? (m^2) (0=NONE): ";B
82 IF B=0 THEN 90
84 S1=S/B
86 PRINT "SWI: ";S1;"gm m/m^2"
90 END

Eddie

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

## Monday, January 28, 2019

### HP 71B: Linear Regression, Open Channel, Sunrise/Sunset, Musical Mini-Piano

HP 71B:  Linear Regression, Open Channel, Sunrise/Sunset, Musical Mini-Piano

 Feel free to use this pic whenever it's Friday.  Even if it's Monday.  :)

Linear Regression with a User Keyboard

This program creates a user keyboard with the following keys defined:

[ I ]  Clears the statistics array and variables
[ A ]  Add a data point X,Y: the sample size is shown
[ D ]  Delete a data point X,Y:  the sample size is shown
[ M ] Sample Mean for X and Y data.  Press CONT for mean of Y values.
[ S ] Sums for X and Y data.  Press CONT for sum of Y values.
[ E ]  Standard Deviation for X and Y data.  Press CONT for standard dev. of Y values.
[ R ]  Execute Linear Regression.  A = intercept, B = slope, correlation is calculated, fit to the line Y = A + B*X
[ H ]  Help:  cycles what all the keys do
[ X ] Clears all the user keys, prepares you to go to the next program

PROGRAM STATLIN
689 bytes, 1/26/2019

10 DEF KEY "I", 'RUN 110'
20 DEF KEY "A", 'RUN 200'
30 DEF KEY "D", 'RUN 300'
40 DEF KEY "M", 'RUN 400'
45 DEF KEY "S", 'RUN 440'
50 DEF KEY "E", 'RUN 500'
60 DEF KEY "R", 'RUN 600'
70 DEF KEY "X", 'RUN 700'
75 DEF KEY "H", 'RUN 750'
80 USER ON
90 END

110 DESTROY S,A,B,X,Y,H\$,I
120 STAT S(2) @ PRINT "ALL CLEAR"
130 END

200 INPUT "+ X,Y:";X,Y
210 ADD X,Y & DISP "N=";TOTAL(0)
220 END

300 INPUT "- X,Y:";X,Y
310 DROP X,Y & DISP "N=";TOTAL(0)
320 END

400 PRINT "X-BAR=";MEAN(1) @ PAUSE
420 PRINT "Y-BAR=";MEAN(2)
430 END

440 PRINT CHR\$(28);"X=";TOTAL(1) @PAUSE
450 PRINT CHR\$(28);"Y=";TOTAL(2)
460 END

500 PRINT "sX:";SDEV(1) @ PAUSE
510 PRINT "sY:";SDEV(2)
520 END

600 LR 2,1,A,B
610 PRINT "INT=";A @ PAUSE
620 PRINT "SLP=";B @ PAUSE
630 PRINT "r=";CORR(2,1) @ PAUSE
640 PRINT "Y=";A;"+";B;"X"
650 END

700 PURGE KEYS @ USER OFF
710 PRINT "EXIT COMPLETE"

750 FOR I=1 TO 8
760 READ H\$ @ PRINT H\$ @ WAIT 1
770 DATA "I: CLEAR","A: ADD","D: DEL","M: MEAN","S: SUMS","E: SDEV","R: A+BX","X: EXIT"
780 NEXT I
790 PRINT "READY." @ END

Example to try:

Data:  X,Y
-5.56, 0.79
-4.30, 0.84
1.86, 1.93
2.24, 2.01
3.95, 2.26

To add data:  (in USER mode) [ A ] -5.56, 0.79 [END LINE] (repeat for all data points)

Results:  n = 5

Mean:
[ M ]  "X-BAR=" -0.362  [ f ] [ + ] (CONT) "Y-BAR=" 1.566

Sums:
[ S ]  "∑X=" -1.81 [ f ] [ + ] (CONT) "∑Y=" 7.83

Standard Deviations:
[ E ] "sX=" 4.26696847891 [ f ] [ + ] (CONT) "sY=" 0.696512742166

Linear Regression:
[ R ] "INT=" 1.62489805306  [ f ] [ + ] (CONT)
"SLP=" 0.162701804029 [ f ] [ + ] (CONT)
"r=" 0.996741950615 [ f ] [ + ] (CONT)
"Y=1.6248905306 + 0.162701804029 X"

Open Channel Parameters

Source:

Michael R. Lindberg, PE  Civil Engineering Reference Manual for the PE Exam 11th Edition  Professional Publications Inc., Belmont, CA  2008  ISBN-13:  978-1-59126-129-2

The program OPENFLOW calculates the following:

Area
Wetted Perimeter
Hydraulic Depth
Uniform Section Factor

of conductors of four shapes: rectangle, trapezoid, triangle, and circle.

PROGRAM OPENFLOW
781 bytes, 1/25/2019

10 DESTROY K,D,B,P,R,T,H,W
20 DEGREES
30 DISP "1. RECTANGLE" @ WAIT 1
40 DISP "2. TRAPEZOID" @ WAIT 1
50 DISP "3. TRIANGLE" @ WAIT 1
60 DISP "4. CIRCLE" @ WAIT 1
70 DISP "ELSE. REPEAT" @ WAIT .5
80 INPUT "CHOICE (1-4,E):"; K
90 IF K=1 THEN 1010
100 IF K=2 THEN 2010
110 IF K=3 THEN 3010
120 IF K=4 THEN 4010
130 GOTO 30

1010 INPUT "WIDTH,DEPTH:";W,D
1020 A=D*W @ P=2*D+W @ R=A/P
1030 H=A/W @ S=A*R^(2/3)
1040 GOTO 5010

2010 INPUT "DEPTH:";D
2012 INPUT "WIDTH-LONG:";W
2014 INPUT "WIDTH-SHORT:";B
2016 INPUT "ANGLE:";T
2020 A=D*(B+D/TAN(T)) @ P=B+2*(D/SIN(T)) @ R=A/P
2030 H=A/W @ S=A*R^(2/3)
2040 GOTO 5010

3010 INPUT "WIDTH:";W
3012 INPUT "DEPTH:";D
3014 INPUT "ANGLE:";T
3020 A=D^2/TAN(T) @ P=2*D/SIN(T) @ R=A/P
3030 H=A/W @ S=A*R^(2/3)
3040 GOTO 5010

4012 INPUT "ANGLE:";T @ T=PI*T/180
4020 A=1/8*(T-SIN(T))*D^2 @ P=T*D/2 @ R=A/P
4030 H=A/D @ S=A*SQR(D)
4040 GOTO 5010

5010 PRINT "AREA=";A @ PAUSE
5020 PRINT "WET PERIM.=";P @ PAUSE
5030 PRINT "HYD. RADIUS=";R @ PAUSE
5040 PRINT "HYD. DEPTH=";H @ PAUSE
5050 PRINT "SECTION FACTOR=";S
5060 END

Approximate Time of Sunrise and Sunset

Source:

Hewlett Packard "HP-65 Aviation Pac" 1974

The program SUNTIME approximates the time of sunset and sunrise based on a date in a general 365-day calendar, the person's location (longitude (east is negative, west is positive) and latitude (north is positive, south is negative)), and the time zone.

Time Zone Table (United States/Mexico/Canada)
Hours from GMT:
Hawaii:   Standard and Daylight: -10
Alaska:  Standard: -9, Daylight: -8
Pacific:  Standard: -8, Daylight: -7
Mountain: Standard: -7, Daylight: -6
Central: Standard: -6, Daylight: -5
Eastern: Standard: -5, Daylight: -4

Program SUNTIME
494 bytes, 1/24/2019

10 DESTROY T,E,D,A,Z,G,C
11 DESTROY S,S1,S2,S3
12 DESTROY O1,O2,O3,O,U1,U2,U3,U
14 DEGREES
16 INPUT "MONTH: ";M
20 INPUT "DAY: ";D
26 INPUT "LONG (E/W):D,M,S:";O1,O2,O3
27 O=O1+O2/60+O3/3600
30 INPUT "LAT (S/N):D,M,S:";U1,U2,U3
32 U=U1+U2/60+U3/3600
35 INPUT "TIME ZONE:";Z
40 T=.988*(D-1+30.3*(M-1))
45 E=.123*COS(T+87)-1/6*SIN(2*T+20)
50 C=-23.439*COS(T+10)
55 S=(O-ACOS(-TAN(C)*TAN(U)))/15-E+12+Z
57 S1=IP(S)
59 S2=IP(FP(S)*60)
61 S3=FP(FP(S)*60)*60
65 DISP "Sunrise: ";S1;":";S2;":";S3 @ PAUSE
75 N=(O+ACOS(-TAN(C)*TAN(U)))/15-E+12+Z
77 N1=IP(N)
79 N2=IP(FP(N)*60)
81 N3=FP(FP(N)*60)*60
85 DISP "Sunset: ";N1;":";N2;":";N3

Example:
Time:  January 26  (Month = 1, Day = 26)
Place:  Farifield, CA:   38°15′28″N 122°3′15″W
Time Zone: -8 (Standard)

Inputs:
MONTH: 1
DAY: 26
LONG: 122,3,15
LAT: 38,15,28
TIME ZONE: -8

Results:
Sunrise: 7 : 24 : 19.09497708
Sunset: 17 : 16 : 17.62419468

Musical Mini-Piano

Key map:

[ A ]:  A
[ W ]:  A#
[ S ]: B
[ D ]: C
[ R ]: C#
[ F ]: D
[ T ]: D#
[ G ]: E
[ H ] : F
[ U ]: F#
[ J ]: G
[ I ]: G#
[ K ]: A (higher octave)

[ O ]: One octave higher
[ L ]:  One octave lower

[ P ]: Double the length of the note
[ = ]: Halve the length of the note

[ X ]:  Exit, clears all the user keys

Default octave:  A4 (220 HZ) to A5 (440 Hz)
Default note length:  1/4 second

Program PIANO
743 bytes, 1/27/2019

100 DESTROY A,N,P
110 A=2^(1/12) @ N=0 @ P=0
112 DEF KEY "A", 'BEEP 220.0*2^N,.25*2^P': ! A
114 DEF KEY "W", 'BEEP 233.1*2^N,.25*2^P': ! A#
116 DEF KEY "S'", 'BEEP 246.9*2^N,.25*2^P': ! B
118 DEF KEY "D", 'BEEP 261.6*2^N,.25*2^P': ! C
120 DEF KEY "R", 'BEEP 277.2*2^N,.25*2^P': ! C#
122 DEF KEY "F", 'BEEP 293.7*2^N,.25*2^P': ! D
124 DEF KEY "T", 'BEEP 311.0*2^N,.25*2^P': ! D#
126 DEF KEY "G", 'BEEP 329.6*2^N,.25*2^P': ! E
128 DEF KEY "H", 'BEEP 349.2*2^N,.25*2^P': ! F
129 DEF KEY "J", 'BEEP 392.0*2^N,.25*2^P': ! G
130 DEF KEY "U", 'BEEP 370.0*2^N,.25*2^P': ! G#
132 DEF KEY "I", 'BEEP 415.3*2^N,.25*2^P': ! F
134 DEF KEY "K", 'BEEP 440.0*2^N,.25*2^P': ! A
136 DEF KEY "O", 'N=N+1@ PRINT "OCTAVE UP" ':
138 DEF KEY "L", 'N=N-1 @ PRINT "OCTAVE DOWN" ':
140 DEF KEY "P", 'P=P+1 @ PRINT "NOTE x2" ':
142 DEF KEY "=", 'P=P-1 @ PRINT "NOTE /2" ':
144 DEF KEY "X", 'RUN 400':
146 USER ON
148 END
400 DESTROY A,N,P
410 PURGE KEYS
420 USER OFF
430 PRINT "EXIT COMPLETE"
440 END

Eddie

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

## Monday, January 21, 2019

### HP Prime: Renaming Headers in Statistic Editors

HP Prime:  Renaming Headers in Statistic Editors

I recently received an email asking for help of how to rename columns of the Statistics Editor screen.  I was not able to figure it out myself, I then asked if anyone at the Museum of HP Calculators knew.

Tim Wesseman replied that you can change the header name in the statistic editor by using:

D1(-1) = " [ header name in a string ] "

This applies to D2 - D9, D0, C1 - C9, and C0.  The HP Prime uses D# in anaylzing 1 Variable Statistics and C# in analyzing 2 Variable Statistics.

In the illustration listed above, I renamed the headers for both C1 and C2 as "X DATA" and "Y DATA".

C1(-1):="X DATA"
C2(-1):="Y DATA"

Note this only changes the header in the Numeric View of the Statistics apps (Statistics 1Var, Statistics 2Var).

Caution:  This only works for Statistics columns, not for list columns for the list editor, or the matrix columns and rows for the matrix editor.

Tyann states to clear the header, simply store an empty string.  In this example,

C1(-1):=""
C2(-1):=""

Thanks to Tim Wessman, Tyann, and Roger Céspedes Esteban to sending me the email (the best for your Descriptive Statistics app, Roger).

Eddie

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

### Retro Review: Casio fx-85WA

Retro Review: Casio fx-85WA

I want to give a special thank you to John Cadick. Cadick requested that I review this calculator and has loaned me his calculator to review. Much appreciated, and John, I hope you like this review.

General Information

Company: Casio
Type: Scientific – Algebraic (Perfect Algebraic Method)
Display: 10 digits with 2 digit exponents
Power: Solar with battery backup (LR44)
Memory Registers: 8: A, B, C, D, E, F, X, Y ,M
Years: Circa 1998-1999
Original Cost: \$10 to \$20, depending on the store (at the time)
Documentation: Manual, Quick Reference card
Two Line Display and Fractions

The Casio fx-85WA has a two line display: the top line for the mathematical expression to be evaluated, and the bottom line displays the answers. The font on the bottom line is bigger than the font on the top line. Later models will have the fonts of both lines of about equal size.

 Screen for fx-85WAS (left) and FX-300MS (right)

You can enter equations as they are written, no need to worry about post-fix notation. The order of operations is effect for all calculations.

You can enter and do calculations with fractions with the [ a b/c ] key. After a calculation is completed, the [ a b/c ] can convert results between a fraction and decimal approximation. All fractions are simplified. The maximum denominator is 9999. Conversions between mixed fractions and improper fractions are also available.

The functions available are:

* Trigonometry: sine, cosine, tangent, with inverse and hyperbolic
* Logarithmic: natural and common, with inverses
* Square, square root, cube, and cube root (all primary key functions on the fx-85WA)
* Reciprocal, factorial (calculating 69! on the fx-85WS is surprising slightly faster than later models)
* Combination, permutation
* Engineering notation with the [ENG] and its inverse
* Degree-Minute-Seconds calculations [ ° ‘ “ ] and conversions
* Fractions, random numbers, round result to the FIX settings
* Polar and Rectangular Conversions

For the polar and rectangular conversions, results are stored in the following variables:

E: x, r
F: y, θ

Replay

The last expression can be edited. To re-edit the last expression, simply press either the arrow keys [ ← ] or [ → ] and edit. Characters can be inserted and deleted.

Statistics

There are two primary statistics modes on the fx-85WA:

* SD (Single Deviation, 1-variable statistics)
* REG (Regression, 2-variable statistics)

The type of regressions are:

Lin: Linear (y = a + b*x)
Log: Logarithmic (y = a + b*ln x)
Exp: Exponential (y = a + b*e^x)
Pwr: Power (y = a*x^b)
Inv: Inverse (y = a + b/x)
Quad: Quadratic (y = a + b*x + c*x^2)

Data points are entered with the [ M+ ] key with frequencies added with the semicolon ( ; ). When data is entered, the x value is returned. There is no data count indicator when [ M+ ] is pressed, I wish it did. Keep this in mind.

All the statistics registers are kept as shifted functions and alpha registers, and they are:

 SHIFT 1: mean x SHIFT 6: sy* RCL A: ∑x^2 RCL F: ∑xy SHIFT 2: σx SHIFT 7: A (intercept) RCL B: ∑x RCL M: ∑x^3 SHIFT 3: sx* SHIFT 8: B (slope, x coef.) RCL C: n RCL X: ∑x^2y SHIFT 4: mean y SHIFT 9: C (x^2 coef.) RCL D: ∑y^2 RCL Y: ∑x^4 SHIFT 5: σy SHIFT (: r (correlation) RCL E: ∑y

* labeled xσn-1 and yσn-1, respectively. (sample deviation)

Keyboard

The fx-85WA is a light calculator and pretty compact. The keys are pretty solid, but also allow for fast typing. I like the labeling of the keys, they are easy to read.
One thing I am big fan of both STO (store) and RCL (recall) are primary key functions. This is something we don’t see on scientific calculators anymore, as often either STO or RCL is a shifted function.

The color of the font on the keys and labels are readable with good contrast. The fx-85WA is a pleasure to use.

Verdict

The fx-85WA serves a scientific calculator providing with lots of functions. My only wish I had for this model is that top line’s font is bigger, but that is addressed in later models.

This model (and equivalent fx-300W) is a challenge to find. I searched ten pawn shops and several thrift shops for this model without success.

Before I go: I want to thank John Cadick for lending me his calculator to review.

I also want to give a table comparison of three Casio calculators:

 (left to right) Casio fx-85WA, Casio fx-300MS, Casio fx-300ES Plus

Eddie

All original content copyright, © 2011-2019. 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. Please contact the author if you have questions.

## Wednesday, January 16, 2019

### Comparison – Three Generations of Casio fx-115

Casio fx-115D

Casio fx-115MS

Casio fx-115ES Plus