Monday, May 30, 2022

Plus42: The FOR Function

Plus42:  The FOR Function



About the Plus42 App


Author:  Thomas Okken


App: 

Android:  $9.99

iOS:  $9.99

PC/MacOS/Linux:  Free

Donations Accepted


Link:  https://thomasokken.com/plus42/


Please give Okken some love!   Free42 and Plus42 are both awesome apps and emulators, both emulate the HP 42S engine.  The Plus42 adds the solver of the HP 17B/19B/27S and unit conversions of the HP 48/49/50 family.   The Plus42 can also graph functions.   You can find a lot more information on the link above!


(Disclaimer:  I am not being paid.)


I am now including apps like the Plus42 in my rotation for blogs, please be on the look out for those.  


Today's blog entry will cover one of the additional solver functions for the Plus42:  FOR.


Plus42 FOR Syntax


FOR(INIT:COND:NEXT:EXPR)


INIT:  Initial commands


COND:  condition

If the condition is true:  execute EXPR (there can be more than one EXPR statements), then NEXT

If the condition is false:  the loop ends


NEXT:  next command,  this is where the counter variable is incremented or decremented


EXPR:  the main loop


Examples 


Example 1:  Add from 1 to 4.


HP 39G/Prime Code:

A:=0;

FOR K FROM 1 TO 4 DO  (STEP 1)

A:=A+K;

END;


Plus42 Equation Code:

S=FOR((L(A:0)+L(I:1))×0:G(I)≤4:L(I:G(I)+1):L(A:G(A)+G(I)))


Variables:

S = sum_final answer

A = sum

I = counter variable


Result:  S = 10


S=:   set the result to the variable S, S = A

INIT:  (L(A:0)+L(I:1))×0;  set A = 0 and I = 1

COND:  G(I)≤4;  test if I≤4; if true continue, if false exit the loop

NEXT:  L(I:G(I)+1); this happens at the end of the loop, this is like the general STEP incr/decr command

EXPR: L(A:G(A)+G(I))


The use of the Get function allows the variable to used automatically and not be displayed in the CALC menu.  


Something that threw me off is that the order of NEXT and EXPR, which the EXPR (which I think there could be more than one EXPR statements), I am used to NEXT either at the end of the FOR loop or implied (end of indentation in Python, for example).


Example 2:  Product


Calculate Π(n/4, n=1 to m) = 1/4 * 2/4 * 3/4 * ... * m/4


Plus42 Equation Code:

P=FOR((L(A:1)+L(N:1)+M)×0:G(N)≤IP(M):L(N:G(N)+1):L(A:G(A)×(G(N)÷4)))


Variables:

P = product_final answer

N = counter

M = higher limit


P=:   set the result to the variable P, P = A

INIT:  (L(A:1)+L(N:1)+M)×0; set A = 1, N = 1, ask for M

COND: G(N)≤IP(M); if N ≤ IP(M); if true continue, if false exit the loop

NEXT:  L(N:G(N)+1)

EXPR: L(A:G(A)×(G(N)÷4))


Results:

3 → M; P → 0.0938

6 → M; P → 0.1758

12 → M; P → 28.5507


Example 3:  Recursive


Given an initial condition u_0, calculate the recursion:


u_n = 2 * u_n-1 - 3


for n terms.


Plus42 Equation Code:

S=FOR((U+N+L(I:1))×0:G(I)≤N:L(I:G(I)+1):L(U:2×G(U)-3))


Variables:

S = final answer

U = recursive variable

N = number of terms


S=:  final answer

INIT:  (U+N+L(I:1))×0

COND: G(I)≤N

NEXT:  L(I:G(I)+1)

EXPR:  L(U:2×G(U)-3)


Results, enter U, N first before calculating for S:

2 → U, 3 → N; S → -5

5 → U, 2 → N; S → 11


Enjoy and hope this helps,


Eddie 


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

HP 42S/DM42: Base Programs

 HP 42S/DM42:   Base Programs


Unsigned NOT


The program UNOT applies a NOT to a binary integer (flips zeros to ones and ones to zeros) using unsigned binary integers.  The number of bits (size) is prompted.


HP 42S/DM42 Program UNOT


00  {40-Byte Prgm}

01  LBL "UNOT"

02  BINM

03  "BIN?"

04  PROMPT

05  STO 01

06  EXITALL

07  "SIZE?"

08  PROMPT

09  STO 02

10  2

11  X<>Y

12  Y↑X

13  RCL- 01

14  STO 02

15  1

16  -  

17  BINM

18  END


Examples:


Unsigned NOT of 10100, size 5:  1011  (01011)


Unsigned NOT of 10100, size 8:  11101011


Shift Left


Makes a binary integer shift left: a zero is added to the right side of the integer and "drops" off the left most digit.  The number of bits (size) is prompted.  The binary number is assumed to be non-negative. 


HP 42S/DM42 Program SL16


00  {35-Byte Prgm}

01  LBL "SL16"

02  BINM

03  "BIN?"

04  PROMPT

05  EXITALL

06  2

07  ×

08  "SIZE?"

09  PROMPT

10  2

11  X<>Y

12  Y↑X

13  MOD

14  BINM

15  END


Examples:


Shift Left:  10100, size 5:  1000   (01000)


Shift Left:  10100, size 8:  101000  (00101000)


Shift Right (Logical)


Makes a binary integer shift right: a zero is added to the left side of the integer and "drops" off the left most digit.  The binary number is assumed to be non-negative. A logical shift right divides an integer by 2 and taking the integer result.


HP 42S/DM42 Program SR16


00  {24-Byte Prgm}

01  LBL "SR16"

02  BINM

03  "BIN?"

04  PROMPT

05  EXITALL

06  2

07  ÷

08  IP

09  BINM

10  END


Examples:


Shift Right:  10100:  1010


Shift Right:  1010:  101


The next two programs deals with RGB and HEX codes for computer colors.


HP 42S/DM42 Program CLR→:   RBG to Hexadecimal Code


00  {51-Byte Prgm}

01  LBL "CLR→"

02  DECM

03  "RED?"

04  PROMPT

05  65536

06  BASE×

07  "GREEN?"

08  PROMPT

09  256

10  BASE×

11  BASE+

12  "BLUE?"

13  PROMPT

14  BASE+

15  HEXM

16  END


Example:

Red: 221, Green: 80, Blue 109

Result:  HEX Code:  DD506D


HP 42S/DM42 Program  →CLR:   Hexadecimal to RGB Code


00  {63-Byte Prgm}

01  LBL "→CLR"

02  HEXM

03  "HEX CODE?"

04  PROMPT

05  STO 00

06  DECM

07  65536

08  BASE÷

09  STOP   // Red

10  65536

11  BASE×

12  RCL 00

13  X<>Y

14  BASE-

15  STO 00

16  256

17  BASE÷

18  STOP   // Green

19  256

20  BASE×

21  RCL 00

22  X<>Y

23  BASE-

24  END


Example:  

HEX Code:  103E22

Result:  Red:  16, Green:  62,  Blue:  34


Eddie



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

Casio fx-4000P: Orthonormal 2D Vector Test

Casio fx-4000P:  Orthonormal 2D Vector Test


Introduction


A set of vectors form an orthonormal basis if the vectors are mutually perpendicular and are of unit length.  


Mutual perpendicular means the dot product of two different vectors in the space is 0:


v_i ∙ v_j = 0,  i ≠ j


Unit length means that the norm of each vector is 1:


|v_i| = 1



 For two 2D vectors [ A, B ] and [ C, D ], the two vectors form an orthonormal basis if:


A^2 + B^2 = 1

C^2 + D^2 = 1

A * D + B * C = 0


Casio fx-4000P Program:  Orthonormal 2D Vector Test

Bytes:  84 steps

(line returns are included for readability)


"A":

?→A:

"B":

?→B:

"C":

?→C:

"D":

?→D:

A²+B²≠1⇒Goto 0:

C²+D²≠1⇒Goto 0:

AD+BC≠0⇒Goto 0:

"YES" ⊿

Goto 1:

Lbl 0:

"NO" ⊿

Lbl 1


Examples


Example 1:

[1, 0], [0, 1]

A = 1, B = 0, C = 0, D = 1


"NO"   (1*1 - 0*0 = 1)


Example 2:

[1/√2, 1/√2], [1/√2, -1/√2]

A = 1/√2, B = 1/√2, C = 1/√2, D = -1/√2


"YES"


Source:


Rowland, Todd. "Orthonormal Basis." From MathWorld--A Wolfram Web Resource, created by Eric W. Weisstein. https://mathworld.wolfram.com/OrthonormalBasis.html

Last Accessed April 7, 2022


Eddie 


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

Retro Review: Radio Shack EC-4026

Retro Review:   Radio Shack EC-4026







Quick Facts:


Model:  EC-4026

Company:  Radio Shack

Equivalent Of:  Casio fx-4500P, Casio fx-4500PA

Years:  1989-1991

Type:  Scientific, Programming

Batteries: 1 x CR-2025

Operating Mode:  Algebraic

Memory Registers: 26 (can be extended to 163 through the Defm command)

Program Steps:  1,103 (minimum of 7)

Number of Digits: 10 (display), 12 (precision)


Features


The Radio Shack EC-4026, a clone of the Casio fx-4500P, has a two line display.  On the top row shows formulas, equations, and prompts; and the bottom row displays results, and line numbers in programming mode.  


The modes of the EC-4026 include:


*  Angle Mode:  Degrees, Radians, Grads

*  Display Mode: Fix, Scientific Notation, Norm, Engineering Notation

*  Programming Write 

*  BASE-N:  base conversions and Boolean Logic.  Binary numbers have 32 bits, signed.

*  Linear Regression:  y = A + Bx

*  Single Variable Regression (SD:  Standard Deviation mode)


Extended Memory


By default, there are 26 memory registers, A-Z.   You can use the square brackets [ ] to refer to memory registers indirectly, with the syntax  letter[# registers from letter].


A[ 0 ]: A

A[ 1 ]: B

A[ 2 ]: C

A[ 3 ]: D

...

Z[ 0 ]:  Z


To extend the number of memory registers, execute [ MODE ] [ Ans ] and enter the number of extended memory registers. For example, Defm 10 extends the number of registers to 36, allowing for registers Z[ 1 ] to Z[ 10 ].


Defm 0 returns he number of registers to the default 26. 


Each extended memory costs 8 programming steps.


Independent Memory


The memory M is considered an independent memory with M+ and M- functions.


Formulas

 

In regular mode, we can store one formula (up to 127 steps) into memory with the IN command.  


Expressions can be entered.  If the expression is entered in the form of var=formula, the result is stored into the variable.   


The best part is that you can make prompts and result markers by adding a quoted comment next the variable.  


Use the OUT command to recall the formula and CALC command to run the calculation.


Example:


A"AREA"=π×R"RADIUS"²  [ IN ]


[ CALC ]

RADIUS?    (8.8)

AREA=     (243.2849351)


Integration


The integral command (∫) calculates the integrals of f(x) using Simpson's Rule.  


∫( f(X), low, high, n) 


n is an optional argument.  If n is included, the calculator uses 2^n partitions.  The maximum amount of partitions is 2^9 (512).   During calculation, the screen goes blank except for mode indicators.


Programming


The programming module is an early version of Casio basic.   Each program can have a file name.  The file names are sorted by chronologically.  In write mode, each line has a file number and a line number. (F# L#).  


Store calculations by using the syntax:


var=expressions


Variables can be either be defined (with their values) or undefined (the program will ask for the values each time a loop returns).   Define all the variables with the Fixm command.   We can undefine variables with the curly brackets { }.


The If structure is a little different, with the following symbols are used:


⇒  Then

≠⇒ Else  ( [ 2ndF ] [ a b/c ] )

◺ EndIf


(condition) ⇒ (do if true) : or ⊿ ≠⇒ (do if false) : or ⊿ ◺ (the if loop ends)


Subroutines, Pause (up to 4.5 seconds, with terms of half-seconds), and Goto/Labels (0-9, specific to each program) are included.  


The manual will also list a way to designate a program file as a data bank of names and their telephone numbers.


Sample programs follow.


Volume of a Frustum of a Cone:


Name:  FRUSTUM.CONE

F# L1  {H,Q,R}      // undefine H, Q, R

F# L2  H"HEIGHT"   // prompt for H with the prompt "HEIGHT?"

F# L3  Q"SMALL R" // prompt for Q with the prompt "SMALL R?"

F# L4  R"BIG R"  // prompt for R with the prompt "BIG R?"

F# L5  V"VOL"=H×(Q²+R²+Q×R)×π/3    // calculate volume, display V with "VOL="


Function Table


Name: TABLE

F# L1  {A,B,C}   // undefine A,B,C

F# L2  A"BEG"  // prompt for A with the prompt "BEG?"

F# L3  B"END" // prompt for B with the prompt "END?"

F# L4  N"POINTS" // prompt for N with the prompt "POINTS?"

F# L5  H=(B-A)/N

F# L6  X=A

F# L7  Lbl 0   // start the table

F# L8  X⊿   // display X

F# L9  F=2X-1⊿  // insert f(x) here (F=f(x))

F# L10  X=X+H

F# L11  X≤B⇒Goto 0:◺"FIN"  // if-then structure


Closing Thoughts


The EC-4026 is a great programming calculator.  The programming structure does present a learning curve due it being a beginning version of Casio basic.   


Sources


"Radio Shack EC-4026"  MyCalcDB.  April 21, 2014.   Last Accessed April 3, 2022.  http://mycalcdb.free.fr/main.php?l=0&id=4059


Toth, Viktor T.  "Casio fx-4500P"  rskey.org   2022.   Last Accessed April 3, 2022.  https://www.rskey.org/fx4500p


Toth, Viktor T. "Radio Shack EC-4026" rskey.org.  2022.  Last Accessed April 3, 2022.  https://www.rskey.org/ec4026


Until next time,


Eddie


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

Converting a Line in Parametric Line to a Function Line

Converting a Line in Parametric Line to a Function Line 


From (x(t), y(t)) to y(x)


Express a line, presented in parametric form:


x = A * t + B

y = C * t + D


where A, B, C, and D are constants, and convert it to function form (y(x) or f(x)).


Here is one way to do this:


x = A * t + B

A * t = x - B

t = x / A - B / A


y = C * (x / A - B / A) + D

y = (C/A) * x - B*C/A + D

y = (C/A) * x + (D - B*C/A)


We know have a function in the slope-intercept form where:


slope = C/A


intercept = D - B*C/A


Casio fx-4000P Program:  Converting Parametric Lines to Functional Line

Size:  77 bytes

(line breaks added for readability)


"X=AT+B; A":

?→A:

"B":

?→B:

"Y=CT+D; C":

?→C:

"D":

?→D:

"SLOPE="⊿

C÷A→M⊿

"ITC="⊿

D-B×M→I


Examples


Graph screens are created by the Numworks emulator:  https://www.numworks.com/simulator/


Example 1:

x = 3 * t  - 4 

y = 2 * t + 8


A = 3, B = -4, C = 2, D = 8


Results:

SLOPE = 0.666666667

ITC = 10.66666667






Example 2:

x = -2 * t + 6

y = 4 * t + 3


A = -2, B = 6, C = 4, D = 3


Results:

SLOPE = -2

ITC = 15





Hope you find this useful.  Take care,


Eddie 


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

Swiss Micros DM41X and HP 41C: Numeric Derivatives

Swiss Micros DM41X and HP 41C:  Numeric Derivatives


Introduction


The program DFX calculates one of three types of derivative:


1.  Normal Derivative   (DX)

2.  Logarithmic Derivative (LN)

3.  Power Derivative (PWR)


Where:


Normal Derivative:  f'(x)


Logarithmic Derivative:  d/dx( ln f(x) ) = f'(x) / f(x)  


Power Derivative:  d/dx( f^n(x) ) = n * f^(n-1)(x) * f'(x),  n doesn't have to be an integer


where f'(x) is estimated by:


f'(x) ≈ ( f(x + h) - f(x) ) / h


Variables:  x, h


The program uses a subroutine FX, see the examples for details.  


DM41X and HP 41C Program:  DFX


Uses program FX as a subroutine as f(x).


01 LBL ^T FX

02 RCL 01

03 ^T X?

04 ARCL 01

05 PROMPT

06 STO 01

07 RCL 02

08 ^T H?

09 ARCL 02

10 PROMPT

11 STO 02

12 RCL 01

13 XEQ ^T FX

14 RCL 03

15 RCL 01

16 RCL 02

17 +

18 XEQ ^T FX

19 RCL 03

20 -

21 RCL 02

22 /

23 STO 04

24 ^T 1 DX 2 LN 3 ↑N

25 PROMPT

26 INT

27 STO 05

28 GTO IND 05


29 LBL 01

30 RCL 04 


31 LBL 02

32 RCL 04

33 RCL 03

34 / 

35 GTO 04


36 LBL 03

37 RCL 03

38 ^T N?

39 PROMPT

40 1

41  - 

42 Y↑X

43 LASTX

44 1

43 +

44 *

45 RCL 04

46 *


50 LBL 04

51 RTN



The function FX:


x is loaded in the X stack register (and on display)


01 LBL ^FX

02  execute f(x)

...

##  RTN


For DFX, do not use R01, R02, R03, R04, and R05 in FX.  


Notes:


Sequences such as:

02 RCL 01

03 ^T X?

04 ARCL 01

05 PROMPT


Puts the prompt as X? [contents of R1].   If you want the previous value, press R/S.  Otherwise enter a new value, then press R/S.


This program uses indirect goto statements.  R05 is used to hold the person's choice and uses it to direct which label is executed.


Examples


Example 1:  f(x) = x * sin x


Set FX as:

01 LBL^T FX

02 RAD

03 ENTER

04 ENTER

05 SIN

06 * 

07 RTN


Setting H to 10^-6  (1E-6):


DF:   f'(x)

x = 0.5, Result:  0.9182; x = 1.6, Result: 0.9530


LN:  ln f'(x)

x = 0.5, Result:  3.8305; x = 1.6, Result:  0.5959


PWR: with n = 3,   (f'(x))^3

x = 0.5; Result:  0.1583; x = 1.6;  Result: 7.3128



Example 2:  f(x) = x^2 + 3 * x + 1 = x * (x + 3) + 1


Set FX as:

01 LBL^T FX

02 ENTER

03 ENTER

04 3

05 +

06 *

07 1

08 + 

09 RTN


Setting H to 10^-6  (1E-6):


DF:   f'(x)

x = 3.2, Result:  9.4000; x = 6.8, Result: 16.6000


LN:  ln f'(x)

x = 3.2, Result:  0.4511; x = 6.8, Result: 0.2454


PWR: with n = 1.5,   (f'(x))^1.5

x = 3.2, Result:  64.3677; x = 6.8, Result: 204.7864



Until next time, 


Eddie


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

Python: Financial Functions (2nd Edition)

Python:  Financial Functions (2nd Edition)


This is an update to the python file, which I first released on May 17, 2020:


https://edspi31415.blogspot.com/2020/05/numworkscasio-micropythonpython.html


I am able to transfer and test the python file to a Numworks calculator through the online editor, and TI-84 Plus CE Python through the TI Connect CE.  Because only the math module is used, the python file can be run in most, if not all calculators with Python, as well as Python 3.  


What is included?


*  time value of money calculations

*  net present value and internal rate of return

*  net present value (xnpv) and internal rate of return (xirr) when periods between flows are not consistent, a 365 day-year is assumed

*  simple interest:  calculating interest, total, and solving for principal

*  profit calculations: cost-sell-markup

*  adding sales tax

*  percent change

*  present and future value uniform stream factors

*  compound interest calculations of a single stream:  solve for present value, future value, number of periods, and periodic interest

*  days between dates

*  specific applications:  monthly payment, PITI, qualifying loan amount, sinking fund, expressing a list of amounts as a percent of the sum, prorating an amount among a list of flows


Download the Python file and the instructions (pdf file) here:

https://drive.google.com/file/d/1l7Xg9dM-RHfekKkU7A1Wjay76-yVc56S/view?usp=sharing


Size: about 3,800 bytes.  


Eddie


All original content copyright, © 2011-2020.  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, May 14, 2022

The Sum and Product of Roots of a Quadratic Equation

The Sum and Product of Roots of a Quadratic Equation


Introduction


Let s, t be the roots of the equation a*x^2 + b*x + c = 0.


Let:


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

t = (-b - √(b^2 - 4*a*c)) / (2 * a)


Then


s + t = -b / a

s * t = c / a


We see this topic a lot in algebra, let's see how these properties are derived. Fairly simple.  


Sum of the Roots


s + t

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

= (-2 * b) / (2 * a)

= -b / a


Product of the Roots


s * t 

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

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

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

= (4*a*c) / (4*a^2)



Eddie



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

Retro Review: Hewlett Packard HP 45

Retro Review:   Hewlett Packard HP 45





Quick Facts:


Model:  HP 45

Company:  Hewlett Packard

Years:  1973-1976

Type:  Scientific

Batteries: (original) HP Battery Pack 82001A (rechargeable), compatible batteries can be found on eBay, AC Adapter 82002A

Operating Mode:  RPN

Memory Registers: 9 (R1 - R9), some are used in statistics

Undocumented (by the manual) Feature:  Stopwatch

Original Price:  $395.00 (US) 

Package Includes AC Adapter, User Manual, Pocket Guide, Carrying Case 


Features - History


The HP 45 is the second scientific calculator by Hewlett Packard, first brought to the market in 1973; after the legendary HP 35 was released in 1972.  The HP 45 is the second Hewlett Packard calculator to feature a shift key, after HP's first financial calculator, the HP 80.  


The HP 45 operates on Reverse Polar Notation (RPN).   Here is a Wikipedia page on RPN:  https://en.wikipedia.org/wiki/Reverse_Polish_notation


The HP 45 added more functions to the HP 35, which features include:


* trigonometric functions and inverses

* logarithms and antilogs

* powers and roots

* fixed and scientific 

* factorial of integers

* polar/rectangular conversions

* degrees/degree-minute-second conversions (DD.MMSSSS)

* percent and percent change

*  three angle modes: degree, radians, grads 

* Last x

* three unit conversions

* statistics

* storage and recall arithmetic


When the HP 45 is powered on, the calculator will be in FIX 2 mode.  


Factorial of Integers:   The function n! allows only integers from 0 to 69.  It will be later HP calculators to extend the factorial function to the real numbers.


Polar and Rectangular Conversions:  The conversions involve the X and Y stack.  In polar form, X represents r and Y represents θ.


Conversions:  The HP 45 provides conversion factors for unit conversions. Examples provided in FIX 2 mode. 


[ shift ] [ 7 ]: cm/in.   1 in = 2.54 cm.    


18 in to cm:  18 [ shift ] [ 7 ] [ × ] returns 45.72 cm

50 cm to in:  50 [ shift ] [ 7 ] [ ÷ ] returns 19.69 ft


[ shift ] [ 8 ]:  kg/lb.   1 lb ≈ .4536 kg


200 lb to kg:  200 [ shift ] [ 8 ] [ × ] returns 90.72 kg 

66.5 kg to lb:  66.5 [ shift ] [ 8 ] [ ÷ ] returns 146.61 lb


[ shift ] [ 9 ]: ltr/gal.  1 gal ≈ 3.7854 ltr


150 gal to ltr:  150 [ shift ] [ 9 ] [ × ] returns 567.81ltr

690 ltr to gal:  690 [ shift ] [ 9 ] [ ÷ ] returns 182.28 gal


Percent:  The [ % ] key returns x% of y, while leaving the value in the Y stack.  This could be followed up with [ + ] or [ - ] for percent adding and subtracting calculations.  


Add 6% to 150.

150 [ ENTER ] 6 [ % ] [ + ] returns 159.00


Percent Change:  The [ shift ] [ % ] (∆%) calculates percent change:  (y - x)/y * 100 with the value of the Y stack remains. y is old, x is new.


What is the percent change from 35 to 45?

35 [ ENTER ] 45 [ shift ] [ % ] returns 28.57 (%)


The HP 45 has storage and recall arithmetic for the four arithmetic functions (+, -, ×, ÷).  I love storage arithmetic and any time we get recall arithmetic, it's a huge bonus. 


The keyboard feels good and the keys feel responsive.  


Statistics


The HP 45 has one-variable statistics, which some sums for y-data.


R5 = n

R6 = Σx^2

R7 = Σx

R8 = Σy

RCL Σ+ returns Σx to the X stack and Σy to the Y stack

[ shift ] [ R↓ ] returns x-bar to the X stack and sx to the Y stack


Stopwatch


A famous and undocumented feature of the HP 45 is a stopwatch.  The stopwatch is accessed by the sequence [ RCL ] then pressing [ 7 ], [ 8 ], and [ CHS ] keys at the same time.  Done right the display will be in the form:


hh.mm ss     'ss


Press [ CHS ] to start and stop the timer, and any number keys can be used to store the time for lap records.  The stored time will be stored as a decimal and the two two digit exponent will store the hundredths of seconds. 


Pressing [ CLx ] clears the time and [ ENTER ] returns us to the operator mode.  I understand that due to the lack of crystal, the timer is somewhat inaccurate.   


Closing Thoughts


I love this calculator!   It's good to have a calculator from the 1970s, especially from HP.  


Until next time,


Eddie


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

HP 32S and HP 32SII Week: Maximum, Minimum , Histogram

HP 32S and HP 32SII Week:  Maximum, Minimum , Histogram 





Introduction


The program takes data and determines:


*  maximum of the data set (X)

*  minimum of the data set (Y)

*  bin width using Scott's normal rule (h, see formula below)

*  number of bins (k, rounding is not included)


Scott's normal rule:

h = 3.49 * sx / (n^(1/3))


Number of bins:

k = (max - min) / h

In practice, take the ceiling of k.


Instructions


1.  Enter the first data point.

2.  Press XEQ D  (execute label D)

3.  Enter the next data point, press R/S.  Repeat until the last data point.

4.  Press XEQ C 


HP 32S/32SII Program:  Maximum, Minimum, Bin Width, Number of Bins

Total Size (labels D, S, C): 61.5, plus 48 bytes for statistical data

(D: 6.0, S: 18.0, C:  37.5)



D01 LBL D  // data

D02 CLΣ

D03 STO X

D04 STO Y


S01 LBL S

S02 RCL X

S03 x<>y

S04 x>y?

S05 STO X

S06 RCL Y

S07 x<>y

S08 x<y?

S09 STO Y

S10 Σ+

S11 STOP

S12 GTO S


C01 LBL C

C02 RCL X

C03 STOP

C04 RCL Y

C05 STOP

C06 -

C07 49

C08 1

C09 %   // C07 - C09: build 0.49 in 4.5 bytes instead of 9.5 bytes

C10 3

C11 +

C12 Sx

C13 ×

C14 n

C15 3

C16 1/x

C17 y^x

C18 ÷

C19 STO H

C20 STOP

C21 RCL X

C22 RCL- Y

C23 RCL÷ H

C24 STO K

C25 STOP


Example


Data Set:

4.0

5.8

5.7

5.2

4.6

4.9

6.3

7.1

6.6

6.4


4 XEQ D

5.8 R/S

5.7 R/S

...

6.4 R/S

XEQ C


X:  max:  7.1

Y:  min:  4

h:  1.58387549541

k:  1.95722454763  (2 bins)


Source:


"Histogram"  Wikipedia.  Last Updated March 28, 2022. https://en.wikipedia.org/wiki/Histogram  Last Accessed March 31, 2022.  


Up next:  a review of the HP 45 - May 9, 2022


Eddie 


All original content copyright, © 2011-2022.  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 TI-84 Plus CE: Multiple Linear Regression

Casio fx-CG50 and TI-84 Plus CE: Multiple Linear Regression We have arrived at the last month of 2024. What a crazy year. I hope for...