Saturday, November 30, 2019

HP 41C and DM41L: Basic EKG Calculations

HP 41C and DM41L: Basic EKG Calculations



Introduction

The program calculates the following:

*  Lead II magnification, in mm
*  The mean axis deviation
*  The mean axis magnitude 

Given:

*  Lead I positive deflection, in mm
*  Lead III negative deflection, in mm

The mean axis deviation and magnitude are calculated by a rectangular conversion by the following coordinates:

X: Lead I positive deflection - Lead I negative deflection
Y:  Net Lead I deflection * 0.5774 + Net Lead III deflection * 1.1547
Mean axis deviation:  θ - 57°

The program also:

* Converts between the heart rate (rpm) and the R-R interval
* Use either parameter to calculate the Q-T interval, in seconds

heart rate = 60/R-R
Q-T interval = √(R-R)*0.39

The program is a translation of HP 67/HP 97 Basic EKG Determination, which itself is a translation of Steven A. Conrad's HP-65 program (HP-65 Users' Library Program).  See the source listed below.

Notes:

1.  Clear the assignments of keys A (Σ+) through E (LN) before running the program.  This must be done outside the programming environment.  Clear assignments to keys by ASN (blank) (designated key).  

Example:  Clear assignment from A: [ shift ] (ASN)  [ALPHA] [ALPHA] [ Σ+ ]

2.  Running EKG will turn the User Keyboard on.

3.  The program will set the calculator to degrees mode. 

4.  This program was entered on an HP 41C, and it should work on any simulator and Swiss Micros DM41.  

Instructions

1.  Run EKG.

2.  Determine Lead I net deviation and store it to register 01:
(in User's Mode) positive deviation Lead I [ENTER] negative deviation Lead I ( A )  

3.  Determine Lead II net deviation, storing net Lead III net deviation to register 03 and Lead II net deviation to register 02:
(in User's Mode)  positive deviation Lead III [ENTER] negative deviation Lead III ( B )
Result:  Lead II net deviation

4.  Compute Mean Axis:
(in User's Mode)   ( C )  deviation is displayed [ R/S ] magnitude is displayed

5a.  Convert heart rate to R-R:   
(in User's Mode) heart rate (bpm) ( D )
-or-
5b.  Convert R-R to heart rate:
(in User's Mode)  R-R ( D )

6.  Compute Q-T.  
(in User's Mode)  ( E )

HP 41C/DM41 Program:  EKG

01 LBL T^EKG
02 SF 27
03 GTO 00
04 LBL A
05 - 
06 STO 01
07 ^T III:_ 
08 ARCL X
09 AVIEW
10 RTN
11 LBL B
12 -
13 STO 03
14 RCL 01
15 +
16 STO 02
17 ^T II:_ 
18 ARCL X
19 AVIEW
20 RTN
21 LBL C
22 RCL 01
23 ENTER↑
24 0.5774
25 *
26 RCL 03
27 ENTER↑
28 1.1547
29 *
30 +
31 ENTER↑
32 RCL 01
33 R-P
34 X<>Y
35 57
36 -
37 ^T DEV=
38 ARCL X
39 AVIEW 
40 STOP
41 X<>Y
42 ABS
43 ^T MAG=
44 ARCL X
45 AVIEW
46 RTN
47 LBL D
48 ENTER↑
49 ENTER↑
50 60
51 X<>Y
52 /
53 X<=Y?
54 GTO 05
55 ^T RATE=
56 ARCL X
57 AVIEW
58 RTN
59 LBL 05
60 ^T R-R=
61 ARCL X
62 AVIEW
63 RTN
64 LBL E
65 X>Y?
66 X<>Y
67 SQRT
68 0.39
69 *
70 ^T Q-T=
71 ARCL X
72 AVIEW 
73 RTN
74 LBL 00
75 RTN
76 END

Example

I+ = 2.8 mm,  I- = 1.1 mm
III+ = 2.5 mm, III- = 1.4 mm
Heart Rate = 86 bpm

Keystrokes:

XEQ "EKG"
(User Mode is On)
2.8 [ENTER] 1.1 ( A ) 
Display:  III: 1.7000

2.5 [ENTER] 1.4 ( B )
Display:  II:  2.8000

( C )
Display:  DEV=-4.0516
[ R/S ]
Display:  MAG=2.8214

86 (D)
Display:  R-R=0.6977

(E)
Display:  Q-T=0.3258

Source:

"Basic EKG Determinations"  HP-67/97 User's Library Solutions:  Cardiac.  Hewlett Packard.  Corvallis, OR.  (no date given, but I estimate this to be circa 1974)

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. 

Friday, November 29, 2019

Working with Hyperbolic Sine and Cosine

Working with Hyperbolic Sine and Cosine

Definition of sinh and cosh

Hyperbolic Sine

sinh x = (e^x - e^-x) / 2

Hyperbolic Cosine

cosh x = (e^x + e^-x) / 2

Properties

Adding sinh to cosh

cosh x + sinh x
= (e^x + e^-x) / 2 + (e^x - e^-x) / 2
= (2*e^x + e^-x - e^-x) / 2
= (2*e^x) / 2
= e^x

Subtracting sinh from cosh

cosh x - sinh x
= (e^x + e^-x) / 2 - (e^x - e^-x) / 2
= (e^x + e^-x - e^x + e^-x) / 2
= (2*e^-x) / 2
= e^-x

Multiplication of sinh and cosh

(I)
cosh x * cosh y
= (e^x + e^-x) / 2 * (e^y + e^-y) / 2
= (e^x * e^y + e^x * e^-y + e^-x * e^y + e^-x * e^-y) / 4

sinh x * sinh y
= (e^x - e^-x) / 2 * (e^y - e^-y) / 2
= (e^x * e^y - e^x * e^-y - e^-x * e^y + e^-x * e^-y) / 4

cosh x * cosh y + sinh x * sinh y
= (e^x * e^y + e^x * e^-y + e^-x * e^y + e^-x * e^-y) / 4
+ (e^x * e^y - e^x * e^-y - e^-x * e^y + e^-x * e^-y) / 4
= (2 * e^x * e^y + 2 * e^-x * e^-y) / 4
= (e^x * e^y + e^-x * e^-y) / 2
= (e^(x+y) + e^-(x+y)) / 2
= cosh(x + y)

(II)
sinh x * cosh y
= (e^x - e^-x) / 2 * (e^y + e^-y) / 2
= (e^x * e^y + e^x * e^-y - e^-x * e^y - e^-x * e^-y) / 4

sinh y * cosh x
= (e^y - e^-y) / 2 * (e^x + e^-x) / 2
= (e^x * e^y - e^x * e^-y - e^-x * e^-y + e^-x * e^y) / 4

sinh x * cosh y + sinh y * cosh x
= (e^x * e^y + e^x * e^-y - e^-x * e^y - e^-x * e^-y) / 4
+ (e^x * e^y - e^x * e^-y - e^-x * e^-y + e^-x * e^y) / 4
= (2 * e^x * e^y - 2 * e^-x * e^-y) / 4
= (e^(x+y) - e^-(x+y)) / 2
= sinh(x + y)

(III)
cosh^2 x
= ((e^x + e^-x) / 2)^2
= (e^(2*x) + 2 * e^x * e^-x + e^-(2*x)) / 4
= (e^(2*x) + 2 + e^-(2*x)) / 4

sinh^2 x
= ((e^x - e^-x) / 2)^2
= (e^(2*x) - 2 * e^x * e^-x + e^-(2*x)) / 4
= (e^(2*x) - 2 + e^-(2*x)) / 4

cosh^2 x + sinh^2 x
= (e^(2*x) + 2 + e^-(2*x)) / 4 + (e^(2*x) - 2 + e^-(2*x)) / 4
= (2*e^(2*x) + 2*e^-(2*x)) / 4
= (e^(2*x) + e^-(2*x)) / 2
= cosh(2*x)

Summary

cosh x + sinh x = e^x
cosh x - sinh x = e^-x
cosh x * cosh y + sinh x * sinh y = cosh(x + y)
sinh x * cosh y + sinh y * cosh x = sinh(x + y)
cosh^2 x + sinh^2 x = cosh(2*x)

Source:
Oldham, Keith, Myland, Jan, and Spainer, Jerome.  An Atlas of Functions  2nd Edition.  Springer:  New York.  ISBN 978-0-387-48806-6  2009

Stay safe and sane this Black Friday,

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.

Thursday, November 28, 2019

TI 84 Plus CE and HP Prime: Simplified Modulo Expressions

TI 84 Plus CE and HP Prime: Simplified Modulo Expressions

I hope you are having a great, at least sane Thanksgiving. It's Turkey Day (or the vegan equivalent of turkey day) in the United States.  Disclosure: I'm not vegan. 



Introduction

Let A, B, and M be positive integers where:

A ≡ B mod M

Let A = a * c   (A = a when c = 1)
B = b * c  (B = b when c = 1)
M = m

A "cancellation" theorem states that if:

a * c ≡ b * c mod m and gcd(c,m) = 1, then

a ≡ b mod c

Also, if a * c ≡ b * c mod m with gcd(c,m) = d, then

a ≡ b mod (m/d)

The program SIMPMOD uses the second theorem to find equivalent congruence for A ≡ B mod M.   The user inputs B and M, A and equivalent congruence will be calculated.

TI-84 Plus CE Program: SIMPMOD

Firmware version 5.3 or greater is required because of the toString command.  For earlier versions, you will have edit the last few lines. 

"2019-10-27 EWS"
"84+ CE 5.3"
ClrHome
Disp "A =  B MOD M"
Disp "A>0, B>0, M>0"
Input "B? ",B
Input "M? ",M
remainder(B,M)→A
Disp "A= ",A
iPart(√(B))→S
{1,B}→L_1
For(K,2,S)
B/K→T
If fPart(T)=0
augment(L_1,{K,T})→L_1
End
dim(L_1)→D
For(K,1,D)
L_1(K)→C
If fPart(A/C)=0
Then
A/C→R
B/C→S
M/gcm(M,C)→T
toString(R)+" = "+toString(S)+" MOD "+toString(T)→Str1
Disp Str1
End
End 
Disp "DONE"

L_1 is the L1 list variable, [2nd] [ 1 ]

HP Prime Program: SIMPMOD

CHAR(8801) or CHAR(#2261h) is the congruence symbol, ≡

EXPORT SIMPMOD()
BEGIN
// 2019-10-27 EWS
// A ≡ B MOD M
LOCAL B,M;
LOCAL A,R,S,T,K,l1,l2,D;
INPUT({B,M},
"A "+CHAR(8801)+" B MOD M",
{"B?","M?"});
A:=B MOD M;
PRINT();
l1:=CAS.idivis(B);
l2:=SIZE(l1);
D:=l2(1);

FOR K FROM 1 TO D DO
C:=l1(K);
IF FP(A/C)==0 THEN
R:=A/C;
S:=B/C;
T:=M/CAS.gcd(M,C);
PRINT(R+" "+CHAR(8801)+" "+
S+" MOD "+T);
END;
END;
PRINT("DONE");
END;

Examples

Example 1

20 ≡ 500 MOD 30

Inputs:  B = 500, M = 30

20 ≡ 500 MOD 30
10 ≡ 250 MOD 15
5 ≡ 125 MOD 15
4 ≡ 100 MOD 6
2 ≡ 50 MOD 3
1 ≡ 25 MOD 3

Example 2

4 ≡ 364 MOD 60

Input: B = 364, M = 60

4 ≡ 364 MOD 60
2 ≡ 182 MOD 30
1 ≡ 91 MOD 15

Example 3

28 ≡ 3528 MOD 100

Input:  B = 3528, M = 100

28 ≡ 3528 MOD 100
14 ≡ 1764 MOD 50
7 ≡ 882 MOD 25
4 ≡ 504 MOD 100
2 ≡ 252 MOD 50
1 ≡ 126 MOD 25

Source:

Dudley, Underwood.  Elementary Number Theory  2nd Edition.  Dover Publications, Inc:  Mineola, NY 1978  ISBN 978-0-486-46931-7  (2008 reprint)

Happy Thanksgiving!

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.

Wednesday, November 27, 2019

HP Prime: Hyperoblic CAS Transformations

HP Prime:  Hyperbolic CAS Transformations

Introduction

These CAS transforms some expressions involving hyperbolic functions, mainly sinh (hyperbolic sine) and cosh (hyperbolic cosine). 

Let ϕ and Ω be any algebraic expression, real number, or complex number.  These commands are meant to work in CAS mode. 

Exponential Definitions

sinhexp

sinhexp(ϕ) = (e^(ϕ) - e^(-ϕ)) / 2 = ((e^ϕ)^2 - 1) / (2 * e^ϕ)

#cas
sinhexp(f):=
BEGIN
RETURN (e^(f)-e^(−f))/2
END;
#end

coshexp

coshexp(ϕ) =  (e^(ϕ) + e^(-ϕ)) / 2 = ((e^ϕ)^2 + 1) / (2 * e^ϕ)

#cas
coshexp(f):=
BEGIN
RETURN (e^(f)+e^(−f))/2
END;
#end

tanhexp

tanhexp(ϕ) = (e^(ϕ) - e^(-ϕ)) / (e^(ϕ) + e^(-ϕ))

#cas
tanhexp(f):=
BEGIN
RETURN (e^(f)-e^(−f))/
(e^(f)+e^(−f))
END;
#end

Adding Properties

addsinh

addsinh(ϕ + Ω) = sinh ϕ * cosh Ω + sinh Ω * cosh ϕ

#cas
addcosh(f,g):=
BEGIN
RETURN COSH(f)*COSH(g)+
SINH(f)*SINH(g);
END;
#end

addcosh

addcosh(ϕ + Ω) = csoh ϕ * cosh Ω + sinh Ω * sinh ϕ

#cas
addsinh(f,g):=
BEGIN
RETURN SINH(f)*COSH(g)+
COSH(f)*SINH(g);
END;
#end

addtanh

addtanh(ϕ + Ω) = (tanh ϕ + tanh Ω) / (1 + tanh ϕ * tanh Ω)

#cas
addtanh(f,g):=
BEGIN
RETURN (TANH(f)+TANH(g))/
(1+TANH(f)*TANH(g));
END;
#end

Squaring Properties

sqsinh

sqsinh(ϕ) = sinh^2 ϕ = 1/2 * cosh(2 * ϕ) - 1/2

#cas
sqsinh(f):=
BEGIN
RETURN COSH(2*f)/2-1/2;
END;
#end

sqcosh

sqcosh(ϕ) = cosh^2 ϕ = 1/2 * cosh(2 * ϕ) + 1/2

#cas
sqcosh(f):=
BEGIN
RETURN COSH(2*f)/2+1/2;
END;
#end

Product Properties

sinhsinh

sinhsinh(ϕ, Ω) = 1/2 * (cosh(ϕ + Ω) - cosh(ϕ - Ω))

#cas
sinhsinh(f,g):=
BEGIN
RETURN 1/2*(COSH(f+g)-
COSH(f-g));
END;
#end

coshcosh

coshcosh(ϕ, Ω) = 1/2 * (cosh(ϕ + Ω) + cosh(ϕ - Ω))

#cas
coshcosh(f,g):=
BEGIN
RETURN 1/2*(COSH(f+g)+
COSH(f-g));
END;
#end

sinhcosh

sinhcosh(ϕ, Ω) = 1/2 * (sinh(ϕ + Ω) + sinh(ϕ - Ω))

#cas
sinhcosh(f,g):=
BEGIN
RETURN 1/2*(SINH(f+g)+
SINH(f-g));
END;
#end

Source:

Spiegel, Murray R. and Seymour Lipschutz, John Liu.  Schuam's Outlines:  Mathematical Handbook of Formulas and Tables  5th Edition   McGraw Hill: New York  2018  ISBN 978-1-260-01053-4


A little early start to our Thanksgiving feast,

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.

Sunday, November 24, 2019

TI 84 Plus CE, HP 42S/DM42: Pairs of Multiples

TI 84 Plus CE, HP 42S/DM42:  Pairs of Multiples

Introduction

The program MULPAIRS displays all the multiplication pairs of a positive integer.  For example, for n = 15:

15 = 1 * 15
15 = 3 * 5

The TI-84 Plus CE version gives a list of pairs ( first element * second element,  third element * fourth element, etc).   ( {1, 15, 3, 5})

The HP 42S version will display pairs on the display, one pair at a time. 

TI-84 Plus CE Program: MULPAIRS

"2019-10-26 EWS"
Input "INTEGER N? ",N
iPart (√(N))→S
{1,N}→L_1
For(K,2,S)
N/K→T
If fPart(T)=0
augment(L_1,{K,T})→L_1
End
Pause L_1

L_1 is the list variable L1, accessed by pressing [ 2nd ] [ 1 ].

HP 42S/DM42 Program:  MULPAIRS

00 {51-Byte Prgm}
01 LBL "MPAIRS"
02 STO 00
03 SQRT
04 IP
05 STO 01
06 1
07 RCL 00
08 STOP
09 2
10 RCL 01
11 1E-3
12 *
13 +
14 STO 02
15 LBL 01
16 RCL 00
17 RCL 02
18 IP
19 ÷
20 FP
21 X≠0
22 GTO 02
23 LAST X
24 ENTER
25 ENTER
26 RCL 00
27 X<>Y
28 ÷
29 STOP
30 LBL 02
31 ISG 02
32 GTO 01
33 RTN

Example

N = 64
TI-84 Plus CE:  {1, 64, 2, 32, 4, 16, 8, 8}
HP 42S/DM42:  1, 64, R/S;  2, 32, R/S;  4, 16, R/S;  8, 8

64 = 1 * 64 = 2 * 32 = 4 * 16 = 8^2

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, November 23, 2019

HP 42S DM42 Smith Chart Conversions

HP 42S DM42 Smith Chart Conversions



Smith Conversions

Introduction

The program SMITH brings generates a custom menu that allows the user to convert between four factors: 

RL:  return loss
p:  reflection coefficient
s:  voltage standing ratio
SWR:  standing wave ratio

p = 10^-(RL/20)
s = (1 + p)(1 - p)
SWR = 20 * log s

Programs here:

HP 42S/DM42 Program:  SMITH

00 { 111-Byte Prgm }
01▸LBL "SMITH"
02 "RL>p"
03 KEY 1 GTO 01
04 "p>s"
05 KEY 2 GTO 02
06 "s>SWR"
07 KEY 3 GTO 03
08 "SWR>s"
09 KEY 4 GTO 04
10 "s>p"
11 KEY 5 GTO 05
12 "p>RL"
13 KEY 6 GTO 06
14 MENU
15▸LBL 07
16 STOP
17 GTO 07
18▸LBL 01
19 +/-
20▸LBL 04
21 20
22 ÷
23 10↑X
24 RTN
25▸LBL 02
26 STO 00
27 1
28 +
29 1
30 RCL- 00
31 ÷
32 RTN
33▸LBL 05
34 STO 00
35 1
36 -
37 1
38 RCL+ 00
39 ÷
40 RTN
41▸LBL 06
42 1/X
43▸LBL 03
44 LOG
45 20
46 ×
47 RTN
48 .END.

Example 1

Convert SWR of 12 to RL:

[XEQ]  (SMITH)
12  (SWR>s)  (s>p) (p>RL)

Result:  4.45901

Conversions Between Complex Reflection Coefficient and Impedance

It is recommended that you set the calculator to Degree and Polar modes.  To enter complex numbers in polar mode,

Z→R:  Convert from impedance to complex reflection coefficient
Stack:  Z, Z0 (characteristic impedance)

Γ = (Z/Z0 - 1) / (Z/Z0 + 1)

R→Z:  Convert from complex reflection coefficient to impedance
Stack:  Z0, Γ

Z = Z0 * (1 + Γ) / (1 - Γ)

HP 42S/DM42 Programs:  Z→R and R→Z

00 { 19-Byte Prgm }
01▸LBL "Z→R"
02 ÷
03 ENTER
04 ENTER
05 1
06 -
07 X<>Y
08 1
09 +
10 ÷
11 RTN
12 .END.

00 { 20-Byte Prgm }
01▸LBL "R→Z"
02 ENTER
03 ENTER
04 1
05 +
06 X<>Y
07 1
08 -
09 +/-
10 ÷
11 ×
12 RTN
13 .END.

Example 2

In a system with the resistance of 66 Ω has the impedance of 10 ∠ 15°.  What is the reflection coefficient?

(Degree and Polar Mode)
10 [ENTER] 15 [(shift)] (COMPLEX) 66 
[XEQ]  ( Z→R )

Result:  0.40469 ∠ -163.92848

Example 3

What is the impedance of a system with a reflection coefficient of 0.86∠50° with a resistor of 125 Ω?

(Degree and Polar Mode)
125 [ENTER] 0.86 [ENTER] 50 [(shift)] (COMPLEX)
[XEQ] (  R→Z )

Result:  246.80096 ∠ 78.82055°

Source: 

Step-by-Step Solutions For Your HP Calculator: Engineering Applications (HP-32S).  Hewlett Packard.  Edition 1. Corvallis, OR  June 1988

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.

Sunday, November 17, 2019

TI-84 Plus CE: Simple Elliptic Curves Determined by Two Points

TI-84 Plus CE:  Simple Elliptic Curves Determined by Two Points

Introduction

The program ECURVE determines the coefficients of a simple elliptic curve:

y^2 = x^3 + G * x + H

from two points P:(A,B) and Q:(C,D).  It also computes the point R:(E,F) by the following equations:

E = θ^2 - A - C
F = θ * (A + C) - B

Determining G and H.

Using the two points P:(A,B) and Q:(C,D):

A^3 + A * G + H = B^2
C^3 + C * G + H = D^2

A * G + H = B^2 - A^3
C * G + H = D^2 - C^3

Subtracting the bottom equation from the top gets:

( A - C ) * G = (B^2 - A^3) - (D^2 - C^3)
G = ( (B^2 - A^3) - (D^2 - C^3) ) / (A - C)

H can be determined one of two ways:

H = B^2 - A^3 - A * G
H = D^2 - C^3 - C * G

TI-84 Plus CE Program:  ECURVE

Func
FnOff
"EWS 2019-10-20"
Disp "P:(A,B), Q:(C,D)"
Prompt A,B,C,D
(D-B)/(C-A)→θ
θ^2-A-C→E
θ*(A+E)-B→F
Disp "R:(E,F)",E,F
Pause
((B^2-A^3)-(D^2-C^3))/(A-C)→G
B^2-A^3-A*G→H
Disp "Y^2=X^3+G*X+H",G,H
Pause
"√(X^3+G*X+H)"→Y_1
"-Y_1"→Y_2
ZoomFit

Y_1 and Y_2 are the Y1 and Y2 from the Vars, Y-Vars, Function menu.

Example 1

P:(-2, 3)  (A = -2, B = 3)
Q:(-1, 0)  (C = -1, D = 0)

Results:
R:(12, -33)  (E = 12, F = -33)
G = -16
H = -15

Equation:  y^2 = x^3 - 16 x - 15



Example 2

P:(-1, 1)  (A = -1, B = 1)
Q:(2, 4)  (C = 2, D = 4)

Results:
R:(0, -2)  (E = 0, F = -2)
G = 2
H = 4

Equation:  y^2 = x^3 + 2 x + 4



Source:

Rosing, Michael. Implementing Elliptic Curve Cryptography Manning Publishing Co: Greenwich, CT  1999   ISBN 10:  1884777694



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, November 16, 2019

TI-84 Plus CE: Bucket Curve Analysis

TI-84 Plus CE:  Bucket Curve Analysis

Introduction

The program, originally presented by David Burch in the April & May 1985 edition of Datafile (see source below), calculates radio-only noise (dB) and system noise (dB) give the following variables:

*  Tangential Idel noise
*  Second-order Intermodulation
*  High-order Intermodulation

The program, which Burch originally did for the HP 41C, eliminates the need for radio-only and echo noise nomographs. 

The program, ported for the TI-84 Plus here first solves for radio-only noise (P_S) by solving the equation for P_I by repeated iteration:

I = I - 10 log (1 + 10^((I-M)/10)

After each iteration, H is stored to M and H zeroes out.  Radio-only noise is solved when M = 0.   At that point, P_S = M. 

where:
I:  intial idle noise (dB)
M:  second-order intermodulation
H:  high-order intermodulation

The next step is calculate system echo noise (P_D):

N = N - 10 log (1 - 10^((N-S)/10)

The initial value of S is P_S.

Iteration happens again until N = 0,which at that point, P_D = N.

TI-84 PLUS Program: BUCKET

ClrHome
Disp "BUCKET CURVE ANALYSIS"
"DAVID BURCH 1985"
Input "IDLE LINE? ",I
Input "I.MOD LINE? ",M
Input "HIGH I.MOD? ",H
1→F
Lbl 1
I-10*log(1+F*10^((I-M)/10))→I
H→M
0→H
If M≠0
Goto 1
If F=­1
Goto 2
Disp "RADIO ONLY NOISE: ",I
I→R
I→M
Input "MEASURED NOISE? ",I
­1→F
Goto 1
Lbl 2
Disp "SYSTEM ECHO:",I
I→S

Example

Idle Line?  44.5
I.Mod Line?  52
High I.Mod?  56
Result:  R Noise ≈ 43.536

Measured Noise? 40
Result:  System Echo ≈ 42.542

Source

Burch, David "Bucket Curve Analysis"  Datafile April & May 1985.  Vol. 4.  No. 3

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.

Sunday, November 10, 2019

HP 12C: Economic Ordering Quantity

HP 12C: Economic Ordering Quantity

Introduction

In inventory control, a business may try to determine the optimum level of inventory, which is known as the economic ordering quantity.  There are several ways to calculate the economic ordering quantity, each with various approaches of what variables and factors to use.  This blog entry will explore two approaches, as described by the HP Step by Step Solutions For Your HP Calculator book for marketing and sales.  (see source)

Economic Ordering Quantity Knowing Costs and Sales

A simple approach to determining economic ordering quantity is by use of the following formula:

EOQ = √(2 * CPO * SALES / ( UNIT_COST * HOLD%) )

where:
EOQ = economic ordering quantity
CPO = the cost of place an order
SALES = the company's annual sales
UNIT_COST = cost per unit of inventory
HOLD% = holding cost as a rate of inventory costs

HP 12C Program:

Step;  Key Code;  Key
01;   2 ;  2
02;  45, 1; RCL 1
03;  20;  *
04;  45, 2;  RCL 2
05;  20;  *
06;  45, 3;  RCL 3
07;  45, 4;  RCL 4
08;  25;  %
09;  34;  x<>y
10;  35;  R↓
11;  10; ÷
12;  43, 21;  √
13;  44, 0;  STO 0
14;  43,33,00;  GTO 00

Instructions:

Store the following values:
R1 = CPO 
R2 = SALES
R3 = HOLD%
R4 = UNIT_COST

Press R/S to calculate EOQ, which is stored in R0.

Example:

R1 = CPO = $35.00
R2 = SALES = 10,000 units
R3 = HOLD% = 20% of inventory value
R4 = UNIT_COST = $4.73 cost per inventory unit

Result:
CPO = 860.21

Economic Ordering Quantity Factoring Discounts and Taxes

This next calculation adds discounts rates, units used, and income taxes. 

EOQ = √(( 2 * (1 - TAX%) * CPO * UNITS_USED)
/ ( (1 - TAX%) * HOLD% * UNIT_COST + DISCOUNT% * UNIT_COST))

where:
EOQ = economic ordering quantity
TAX% = income tax rate
CPO = the cost of place an order
UNITS_USED = inventory units used in a year
UNIT_COST = cost per unit of inventory
HOLD% = holding cost as a rate of inventory costs
DISCOUNT% = discount rate

HP 12C Program:

Step;  Key Code;  Key
01;  1 ; 1
02;  45, 1; RCL 1
03;  25 ;  %
04;  30 ;  -
05; 44,1;  STO 1
06;  2  ;  2
07;  20 ;  *
08;  45, 2 ;  RCL 2
09;  20 ;  *
10;  45, 3 ;  RCL 3
11;  20 ;  *
12;  44, 0 ; STO 0
13;  45, 5 ; RCL 5
14;  45, 4 ; RCL 4
15;  25 ;  %
16;  45, 1 ; RCL 1
17;  20 ;  *
18;  45, 5 ; RCL 5
19;  45, 6 ; RCL 6
20;  25 ;  %
21;  34 ;  X<>Y
22;  33;  R↓
23;  40;  +
24; 45, 0 ; RCL 0
25; 34 ;  X<>Y
26;  10 ;  ÷
27;  43, 21 ;  √
28;  44, 0 ; STO 0
29;  43, 33, 00 ;  GTO 00

Instructions:

Store the following values:
R1 = TAX% = income tax* 
R2 = CPO
R3 = UNITS_USED
R4 = HOLD%
R5 = UNIT_COST
R6 = DISCOUNT%

R1 gets recalculated as  (1 - TAX%)

Press R/S to calculate EOQ, which is stored in R0.

Example:

R1 = TAX% = 22%
R2 = $150.00
R3 = 24,000 units
R4 = 5.1% holding cost
R5 = $8.00 per unit
R6 = 2% discount

Results:
CPO = 3,426.81

Source:
"HP Step By Step Solutions For Your HP Calculator:  Marketing and Sales:  HP-17B, HP-19B, HP-27S"  Hewlett Packard.  January 1988.  Edition 1

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, November 9, 2019

HP 35S: Determinant and Cramers Rule - 3 x 3 Matrices

HP 35S: Determinant and Cramers Rule - 3 x 3 Matrices

Determinant of a 3 x 3 Matrix

The following program calculates a determinant of a matrix:

[ [ K, N, Q ]
[ L, O, R ]
[ M, P, S ] ]

The determinant is  K*O*S + N*R*M + Q*L*P - M*O*Q - P*R*K - S*L*N.

Enter the elements in columns. 

Program HP 35S:  Determinant

D001 LBL D
D002 SF 10
D003 "DET 3x3"
D004 CF 10
D005 INPUT K
D006 INPUT L
D007 INPUT M
D008 INPUT N
D009 INPUT O
D010 INPUT P
D011 INPUT Q
D012 INPUT R
D013 INPUT S
D014 RCL K
D015 RCL* O
D016 RCL* S
D017 RCL N
D018 RCL* R
D019 RCL* M
D020 +
D021 RCL Q
D022 RCL* L
D023 RCL* P
D024 +
D025 RCL M
D026 RCL* O
D027 RCL* Q
D028 -
D029 RCL P
D030 RCL* R
D031 RCL* K
D032 -
D033 RCL S
D034 RCL* L
D035 RCL* N
D036 -
D037 RTN

Examples:

[ [ -3, 3, 2 ]
[ 5, 4, -1 ]
[ 2, 1, 4 ] ]
Determinant:  -123

[ [ 5, 0, 7 ]
[ -2, 4, -1 ]
[ -3, 11, 6 ] ]
Determinant:  105

Cramer's Rule

Cramer's Rule solves the linear system:

[[ A, D, G ]   [[ x ]  = [[ X ]
[ B, E, H ]     [ y ]  = [ Y ]
[ C, F, I ]]      [ z ]] = [ Z ]]

x = U, y = V, z = W,  T = determinant of the coefficients

Program HP 35S: Cramer's Rule

C001 LBL C
C002 GTO C027
C003 RCL K     // determinant calculation
C004 RCL* O
C005 RCL* S
C006 RCL N
C007 RCL* R
C008 RCL* M
C009 +
C010 RCL Q
C011 RCL* L
C012 RCL* P
C013 +
C014 RCL M
C015 RCL* O
C016 RCL* Q
C017 -
C018 RCL P
C019 RCL* R
C020 RCL* K
C021 - 
C022 RCL S
C023 RCL* L
C024 RCL* N
C025 - 
C026 RTN
C027 SF10  // input numbers into the system
C028 "COL 1"
C029 INPUT A
C030 STO K
C031 INPUT B
C032 STO L
C033 INPUT C
C034 STO M
C035 "COL 2"
C036 INPUT D
C037 STO N
C038 INPUT E
C039 STO O
C040 INPUT F
C041 STO P
C042 "COL 3"
C043 INPUT G
C044 STO Q
C045 INPUT H
C046 STO R
C047 INPUT I
C048 STO S
C049 "VECTOR" 
C050 INPUT X
C051 INPUT Y
C052 INPUT Z
C053 XEQ C003
C054 STO T
C055 "DET="
C056 VIEW T
C057 RCL X
C058 STO K
C059 RCL Y
C060 STO L
C061 RCL Z
C062 STO M
C063 XEQ C003
C064 RCL÷ T
C065 STO U
C066 "X="
C067 STOP
C068 RCL A
C069 STO K
C070 RCL B
C071 STO L
C072 RCL C
C073 STO M
C074 RCL X
C075 STO N
C076 RCL Y
C077 STO O
C078 RCL Z
C079 STO P
C080 XEQ C003
C081 RCL÷ T
C082 STO V
C083 "Y="
C084 STOP
C085 RCL D
C086 STO N
C087 RCL E
C088 STO O
C089 RCL F
C090 STO P
C091 RCL X
C092 STO Q
C093 RCL Y
C094 STO R
C095 RCL Z
C096 STO S
C097 XEQ C003
C098 RCL÷ T
C099 STO W
C100 "Z="
C101 CF 10
C102 TOP
C103 RTN

Examples:

[[ -3, 2, -4 ]   [[ x ]  = [[ 0 ]
[ 6, 1, 2 ]       [ y ]  = [ 2 ]
[ 3, 3, 7 ]]      [ z ]] = [ 6 ]]
T:  -135
x ≈ 0.0296
y ≈ 0.9333
z ≈ 0.4444

[[ 0, 10, 6 ]  [[ x ] = [[ 3 ]
[ 5, 3, 8 ]     [ y ]  = [ 6.5 ]
[ -5, 8, 2 ]]    [ z ]] = [ 7 ]]
T:  -830
x ≈ -0.0843
y ≈ 0.6687
z ≈ 0.6145

Source:

Pike, Scott.  "Using Cramer's Rule to Solve Three Equations with Three Unknowns"  Mesa Community College.  http://www.mesacc.edu/~scotz47781/mat150/notes/cramers_rule/Cramers_Rule_3_by_3_Notes.pdf  Retrieved September 24, 2019

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.

Sunday, November 3, 2019

HP 41C and HP 42S: Paired T Statistic

HP 41C and HP 42S: Paired T Statistic

Introduction

The program PAIRT compares two means of two populations.  With this statistic, the paired t statistic test the null hypothesis:

μ_1  = μ_2,  with degrees of freedom n - 1.

Formulas used:

D = 1/n * Σ(x_i - y_i)

S = √(( n * Σ(D^2) - (ΣD)^2) / (n * (n - 1))) / √n

t = D / S

Note:  The default statistics registers are R11 - R16. 

HP 41C/DM 41 Program: PAIRT

01 LBL T^PAIRT
02 T^PAIRED T
03 AVIEW
04 PSE
05 CLΣ
06 LBL 00
07 T^ENTRY Y/X:
08 PROMPT
09 X<>Y
10 -
11 Σ+
12 T^MORE? N=0
13 PROMPT
14 X≠0?
15 GTO 00
16 SDEV
17 RCL 16
18 SQRT
19 /
20 STO 00
21 MEAN
22 RCL 00
23 /
24 ^T=
25 AVIEW
26 PSE
27 END 

HP 42S/DM 42 Program: PAIRT

00 {67-Byte Prgm}
01 LBL "PAIRT"
02 "PAIRED T"
03 AVIEW
04 PSE
05 CLΣ
06 LBL 00
07 "ENTRY Y/X:"
08 PROMPT
09 X<>Y
10 - 
11 Σ+
12 "MORE N=0?"
13 PROMPT
14 X≠0
15 GTO 00
16 SDEV
17 RCL 16
18 SQRT
19 ÷
20 STO 00
21 MEAN
22 RCL÷ 00
23 "T="
24 AVIEW
25 PSE
26 RTN
27 END

Instructions

1.  Run PAIRT, by XEQ PAIRT
2.  For each data point, enter y, press ENTER, then x, then press R/S.  If you have more data points to enter, enter a nonzero value (any nonzero value) at the "MORE? NO=0" prompt.  When you are done, enter 0 at the "MORE? NO=0" prompt. 
3.  At the "T=" prompt, press R/S to see the t statistic.

Example

Data: (x,y)
(4.3, 8.1)
(4.2, 8.6)
(4.5, 9.6)
(13.0, 10.4)

Result:  T = -1.5043

Source:

HP-33E Statistics Applications  Hewlett Packard Company:  Corvallis, OR.  February 1978

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, November 2, 2019

HP 12C: Error Function Approximation

HP 12C: Error Function Approximation

Introduction

The program for the HP 12C calculator approximates the error function defined as

erf(x) = 2 / √π * ∫ e^-(t^2) dt from t = 0 to t = x

by using the series

erf(x) = (2*x) / √π * Σ( (-x^2)^n / (n!*(2*n+1)), n = 0 to ∞)

In the approximation, up to 69 terms are calculated for the sum (the loop stops when n = 69). 

Since there is no π constant on the HP 12C, the approximation 355/113 for π is used.

HP 12C Program Error Function

Step;   Key Code;  Key
01;  44,1;  STO 1
02;  35;   CLx
03;  44, 2;  STO 2
04;  44, 3;  STO 3
05;  45, 1;  RCL 1   
06;  2;   2
07;  21;  y^x
08;  16;  CHS
09;  45, 2;  RCL 2
10;  21;  y^x
11;  45, 2;  RCL 2
12;  43, 3;  n!
13;  45, 2;  RCL 2
14;  2;   2
15;  20;  *
16;  1;  1
17;  40;  +
18;  20;  *
19;  10;  ÷
20;  44,40,3;  STO+ 3
21;  43, 35;  x=0
22;  43,33,31;  GTO 31
23;  1;  1
24;  44,40,2;  STO+ 2
25;  45, 2;  RCL 2
26;  6;   6
27;  9;   9
28;  43,34;  x≤y
29;  43,33,31; GTO 31
30;  43,33,05; GTO 05
31;  45,3;  RCL 3
32;  45,1;  RCL 1
33;  20;  *
34;  2;  2
35;  20;  *
36;  3;  3
37;  5;  5
38;  5;  5
39;  36;  ENTER
40;  1;  1 
41;  1;  1
42;  3;  3
43;  10;  ÷
44;  43,21;  √
45;  10;  ÷
46;  43,33,00;  STO 00

Examples

(FIX 5)

erf(0.5) ≈ 0.52050

erf(1.6) ≈ 0.97635

erf(2.3) ≈ 0.99886

Source

Ball, John A.  Algorithms for PRN Calculators  John Wiley & Sons: New York  1978  ISBN (10) 0-471-0370-8

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.

HP 42S/DM42: Height of a Fire, Time to Clear a Corridor

 HP 42S/DM42:  Height of a Fire, Time to Clear a Corridor HP 42S/DM42/Free42 Program:  FIREHGT The program FHGT approximates the height of a...