Saturday, November 25, 2023

HP 15C, DM42, HP 27S: Floor and Ceiling Functions

HP 15C, DM42, HP 27S:   Floor and Ceiling Functions


(Updated on 12/22/2023 - see note below for the HP 15C versions)


Notes :


HP 15C: includes  HP 15C, Original, Limited, and Collector's Edition, and apps

DM42: includes HP 42S, DM42, Free42, Plus42




Introduction:  Floor and Ceiling Functions


The floor and ceiling functions are two common functions that transfers a number to an integer.   



Floor Function



Floor:   The greatest integer that is less than or equal to x.  A common symbol for floor is |_x_| and a function call is floor(x).


Let int(x) be the integer part function (sometimes labeled intg(x) or lp(x)), and frac(x) be the fractional part function (sometimes labeled fp(x)).


#  x is an integer

If frac(x) = 0, then return floor(x) =  x     


# x is not an integer

If x ≥ 0, then return floor(x) = int(x)

If x < 0, then return floor(x) = int(x) - 1


Per the function.wolfram.com web page: an equivalent using the modulus function for floor(x) is:


floor(x) = x - x mod 1


Examples:


floor(2.8) = 2

floor(6) = 6

floor(-2.8) = -3



Ceiling Function


Ceiling:  The least integer that is greater than or equal to x.  A common symbol for ceiling is |-x-| (except the horizontal lines are the top) and a function call is either ceil(x) or ceiling(x).  


#  x is an integer

If frac(x) = 0, then return ceil(x) =  x     


# x is not an integer

If x ≥ 0, then return ceil(x) = int(x) + 1

If x < 0, then return ceil(x) = int(x) 


Per the function.wolfram.com web page: an equivalent using the modulus function for floor(x) is:


ceil(x) = x + (-x) mod 1


Examples:

ceil(2.8) = 3

ceil(6) = 6

ceil(-2.8) = -2



Calculator Code:  HP 15C, DM 42, HP 27S



HP 15C


This program is NOT accurate for -1 < x < 0 (such as x = -0.5).  Gratitude to Werner for alerting me of this.  (12/22/2023)


Three labels are used:

D:  floor function

E:  ceiling function

1:  used in calculation for both  (roll stack down one extra time when frac(x)≠0)


step #:  key code : key


000:  42, 21, 14:  LBL D

001:  __, __, 36:  ENTER

002:  __, 42, 44:  FRAC

003:  __, 43, 20:  x=0

004:  __, 22, _1:  GTO 1

005:  __, __, 33:  R↓

006:  __, 43, 44:  INT

007:  43, 30, _3:  TEST 3  (x≥0)

008:  __, 43, 32:  RTN

009:  __, __, _1:  1

010:  __, __, 30:  -

011:  __, 43, 32:  RTN


012:  42, 21, 15:  LBL E

013:  __, __, 36:  ENTER

014:  __, 42, 44:  FRAC

015:  __, 43, 20:  x=0

016:  __, 22, _1:  GTO 1

017:  __, __, 33:  R↓

018:  __, 43, 44:  INT

019:  43, 30, _2:  TEST 2 (x<0)

020:  __, 43, 32:  RTN

021:  __, __, _1:  1

022:  __, __, 40:  +

023:  __, 43, 32:  RTN


024:  42, 21, _1:  LBL 1

025:  __, __, 33:  R↓

026:  __, 43, 32:  RTN






DM42/Free 42/HP 42S


00 { 16-Byte Prgm }

01▸LBL "FLOOR"

02 ENTER

03 ENTER

04 1

05 MOD

06 -

07 RTN

08 END


00 { 15-Byte Prgm }

01▸LBL "CEIL"

02 ENTER

03 +/-

04 1

05 MOD

06 +

07 RTN

08 .END.



HP 27S


FLOOR=X-MOD(X:1)


CEIL=X+MOD(-X:1)



Sources


Wolfram Research, Inc.   "Floor Function".  Path:  Integer Functions > Floor[z] > Representations through equivalent functions > With related functions.   Retrieved October 30, 2023.


https://functions.wolfram.com/IntegerFunctions/Floor/27/01/05/



Wolfram Research, Inc.   "Ceiling Function".  Path:  Integer Functions > Ceiling[z] > Representations through equivalent functions > With related functions.   Retrieved October 30, 2023.


https://functions.wolfram.com/IntegerFunctions/Ceiling/27/01/05/




Eddie


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

HP 32S and HP 15C: Synthetic Division

HP 32S and HP 15C:   Synthetic Division



These programs perform synthetic division, where a polynomial of degree n is divided by the binomial term x - x_0:


[a_n × x^n + a_(n-1) × x^(n-1) + a_(n-2) × x^(n-2) + ... a_1 × x + a_0] ÷ (x - x_0)


With the result of the division is:


[q_(n-1) × x^(n-1) + q_(n-2) × x^(n-2) + ... + q_1 × x + q_0] + R ÷ (x - x_0)


where: 


q_(n-1) = a_n

R is the remainder.



HP 32S/32SII:  Synthetic Division


The degree of the polynomial can go up to 24, with the variables set up as:


p(x) = [ A + B × x + C × x^2 + D × x^3 + ... + Y × x^24 ] ÷ (x - Z)


where

A is the constant

B is the coefficient of x

C is the coefficient of x^2 

and so on...

Z = x_0


Flag 1 is used as an indicator that there are coefficients q_k.  



Code:


S01  LBL S

S02  CF 1

S03  1

S04  +

S05  STO i

S06  SF 1

S07  RCL (i)

S08  STOP

S09  DSE i


Z01  LBL Z

Z02  RCL× Z

Z03  RCL+ (i)

Z04  STOP

Z05  DSE i

Z06  GTO Z

Z07  CF 1

Z08  RTN


Total Memory:  S:  13.5 bytes, Z:  12.0 bytes, Total:  25.5 bytes


To run:  store the coefficients and x0.  Enter the degree of the polynomial and press XEQ S.  



HP 15C:  Synthetic Division


The degree of the polynomial can go as high as you want, as long as you have registers.   The variables set up as:


p(x) = [ R0 + R1 × x + R2 × x^2 + R3 × x^3 + ... ] ÷ (x - R0)


where

R0 is the constant

R1 is the coefficient of x

R2 is the coefficient of x^2 

and so on...

R0 = x_0


Flag 8 is used as an indicator (C on the screen) that there are coefficients q_k.  In effect, this turns on complex mode, which would create a stack of imaginary numbers.  The complex mode for the HP 15C requires five registers to run.  


Code:


001  LBL A:   42,21,11

002  CF 8:  43, 5, 8

003  1:  1

004  +:  40

005  STO I:  44, 25

006  SF 8:  43, 4, 8

007  RCL (i):  45, 24

008  R/S:   31

009  DSE I:  42, 5, 25


010  LBL 0:  42, 21, 0

011  RCL× 0:  45, 20, 0

012  RCL+ (i):  45,40,24

013  R/S:  31

014  DSE I:  42, 5,25

015  GTO 0:  22, 0

016  CF 8:  43, 5, 8

017  RTN:  43,32


To run:  store the coefficients and x0.  Enter the degree of the polynomial and press GSB A.  



Examples



Example 1:  [ 4x^3 + 3x^2 + 2x - 5 ] ÷ [ x -  1 ]


HP 32S:

A:  -5,  B:  2,  C:  3,  D:  4,  Z:  1


HP 15C: 

R1:  -5,  R2:  2,  R3:  3,  R4:  4,  R0:  1


Degree: 3


3 XEQ S/GSB A:


Results:  

4   (x^2)  R/S

7   (x)   R/S

9   (constant)  R/S

4  (remainder)


4x^2 + 7x + 9 + 4 ÷ (x-1)



Example 2:  [ x^4 - 3x^2 + 6x + 3 ] ÷ [ x + 3 ]


HP 32S:

A:  3,  B:  6,  C:  -3, D:  0,  E:  1,  Z:  -3


HP 15C:

R1:  3,  R2:  6,  R3:  -3, R4:  0,  R5:  1,  R0:  -3


Degree:  4


4 XEQ S/GSB A


Results:

3   (x^3)  R/S

6   (x^2)  R/S

-3   (x)   R/S

0   (constant)  R/S

1  (remainder)


x^3 - 3x^2 + 6x - 12 + 39 ÷ (x + 3)



Example 3:  [ x^3 - 42x^2 + 395x + 966 ] ÷ [ x - 21 ]


HP 32S:

A:  966,  B:  395,  C:  -42,  D:  1,  Z:  21


HP 15C:

R1:  966,  R2:  395,  R3:  -42,  R4:  1,  R0:  21


Degree:  3


3 XEQ S/GSB A:


Results:  

1   (x^2)  R/S

-21   (x)   R/S

-46   (constant)  R/S

0 (remainder)


x^2 - 21x - 46



Source


Hewlett Packard.  "Synthetic Division"   HP-65 Math Pac 1.   September 1974.   pp. 34-35, 99




Next blog post:  November 25, 2023


Eddie


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

HP 42S/DM42 Programs in the Style of HP 65/67 Cards

HP 42S/DM42 Programs in the Style of HP 65/67 Cards


Programming Cards


In the 1970s, a programmable scientific calculators stored programs on magnetic cards.   The magnetic cards were then loaded on to calculator.   Two such calculators that used magnetic cards are the legendary HP 65 and HP 67, both from Hewlett Packard.    


The aim of these programs is to simulate classic programs from the HP 65 and HP 67 as they are stored on the cards, with prompts and messages to enhance the user experience.

The HP 65 had five user-definable keys A-E, while the HP 67 adds five additional user-defined labels a-e through a shift-key combination.

The MENU command on the HP 42S* creates a user key menu within a program, up to six keys.   I use this command to simulate running programs from loading cards.

(*and Free42, Plus42, Swiss Micros DM42)

The file included in the link below include four programs that are ported from various application books (pacs) of the HP 65 and HP 67.   


Demonstration Program:  demo.raw


When the program is run, a card is "simulated".   


I usually have the card in this format:

Left keys:  inputs, will sometimes give outputs

Key 4 (or 5): labeled CALC, get outputs

Key 6:  EXIT.  Exits the program.  Simulates removing the card.  


Demonstration


Key 1:  enter X coordinate

Key 2:  enter Y coordinate

Key 4:  calculate the norm

Key 6:  exit the program



Notes:  before GTO 30,  I have a pause command (PSE) so the menu returns.  

If I have multiple outputs, I have a stop command (STOP).  


Message convention: 

Prompts with a colon:  (:)  input

Prompts with an equals sign:  (=)  output


#  comments


00 { 134-Byte Prgm }

01▸LBL "DEMO"

02 "VECT NORM/ANG"         #  short description of the program

03 AVIEW

04 PSE                                        #  pauses the screen (allows for print)

05 "BY EWS"

06 AVIEW

07 PSE

08▸LBL 30                           # label 30 starts the menu

09 "→X"

10 KEY 1 XEQ 21

11 "→Y"

12 KEY 2 XEQ 22

13 "CALC"

14 KEY 4 XEQ 24

15 "EXIT"

16 KEY 6 XEQ 26

17 MENU                       # menu setup

18▸LBL 00

19 STOP

20 GTO 00                     # repeats the menu unless a menu key is pressed

21▸LBL 21                   # enter X

22 STO 01

23 "X:"

24 ARCL ST X   

25 AVIEW

26 PSE

27 GTO 30

28▸LBL 22                # enter Y

29 STO 02

30 "Y:"

31 ARCL ST X

32 AVIEW

33 PSE

34 GTO 30

35▸LBL 24            # calculate

36 RCL 02

37 RCL 01

38 →POL

39 "NORM="

40 ARCL ST X

41 AVIEW

42 STOP

43 "ANGLE="

44 ARCL ST Y

45 AVIEW

46 PSE

47 GTO 30

48▸LBL 26       # exit routine

49 CLMENU

50 EXITALL

51 .END.


Sample Output:


VECT NORM/ANG

BY EWS

X:5.7500

Y:6.8500

NORM=8.9434

ANGLE=49.9894


Program Space vs. Information Labels


When messages and alpha strings are added, along with the necessary AVIEW, PSE, and STOP commands, the program space requirements increase.   I put these messages to make the program as user friendly as possible.  



What's Included in the Zip Drive


Five programs:


Demonstration Program:  demo.raw

Sight Reduction Table:  str.raw

Physiologic Shunt and Fick:  phsy.raw

1-D Normal Shocks for Ideal Gases:  shock.raw

P and S Seismic Wave Velocity:  seismic.raw


PDF file of instructions and program listing



Download here (zip file):  

https://drive.google.com/file/d/1_0F_DHCGxcLbmCtrhMQbKShjrpBUgB7i/view?usp=share_link


Enjoy and please let me know, I plan to create another volume of these style of programs.  



Note:  The next blog entry will be on November 18, 2023


Eddie 


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

Retro Review: Sharp PC-1248

Retro Review:  Sharp PC-1248





Quick Facts


Model:  PC-1248

Company:  Sharp

Years:  circa 1986, years of production unknown

Type:  Scientific, Pocket Computer

Power:  2 x CR-2032 batteries

Display:  1 line, 16 characters

Programming Language:  BASIC

Memory:  7,422 bytes


Program and Run


The Sharp PC-1248 is a credit card sized BASIC pocket computer, which is stored in a slip on hard case.  The screen is one line, containing up to 16 characters.  


There is one program space, allowing for line numbers from 1 to 999.   The range of commands are adequate for general mathematical applications.  


There are several peripherals available for PC-1248, including a printer and a cassette tape recorder to save and load programs.


Sharp also produced the PC-1246S pocket computer around the same time, only with memory capacity of 1,278 bytes.  


PC-1248 vs EL-5500 III




The PC-1248 operates similarly to the Sharp EL-5500 III pocket calculator; though it lacks the statistics mode and matrix operations.    I reviewed the EL-5500 III in 2017:  https://edspi31415.blogspot.com/2017/01/retro-review-sharp-scientific-computer.html



Keyboard:  It Could Have Been Better


To be honest, the keys are pretty hard to press.   I used a q-tip to press the keys at first when a soft-like stylus did not work.  However, the keys does have button under the keyboard.  This is the biggest complaint I have with the PC-1248.



Final Thoughts


I like the form factor of the PC-1248, and the command set is good for quick calculations on the run.   The computer is to the point, basic programming.   As I mentioned, the keys could have been better.   



Sample Programs for the PC-1248


Math Statement Builder: RUN 40


40 PAUSE "MATH STMT BUILD"

42 A = RND 21-1

44 B = RND 21-1

46 C = RND 21-1

48 D = A*B+C

50 PRINT A; "*"; B; "+''; C; "="; D:  END


Examples:  (results will vary)


4. * 3. + 7. = 19.


13. * 16. + 2. = 210.


2. * 8. + 3. = 19.


Net Present Value: RUN 60


60 PAUSE "NET PRESENT VALUE": CLEAR

62 INPUT "CF0:"; N, "RATE:"; I

64 J=1

66 INPUT "FLOW:"; F, "FREQ:"; K

68 FOR L=1 TO K: N=N+F/(1+I/100)^J: J=J+1

70 NEXT L

72 INPUT "MORE=1"; L

74 IF L=1 THEN 66

76 PRINT USING "########.##"; "NPV:"; N

78 END


Examples:


CF0:  -5000

CF1:   3000, frequency 1

CF2:  6000, frequency 1

Rate: 3%


Result:  NPV = 3568.20


CF0: -5000

CF1: 500, frequency 12

CF2:  0, frequency 6

CF3:  1000, frequency 6

Rate:  2.95%


Result:  NPV = 3207.18 



Future Value:  Continuing Compound Interest:  RUN 110


110 PAUSE "FV - CONT. CMPD. INT.": CLEAR

112 INPUT "PV? "; P

114 INPUT "RATE? "; R:  R=R/100

116 INPUT "YEARS? "; T

118 F=P*EXP(R*T)

120 PRINT USING "########.##"; "FV = "; F

122 END


Examples:


P = 5000, R = 5, T = 5.   Result:  F = 6420.12


P = 1000, R = 6, T = 20.  Result:  F = 3320.11


Source


"The Sharp PC-1246 computer":  http://pocket.free.fr/html/sharp/pc-1246s_e.html

"The Sharp PC-1248 computer": http://pocket.free.fr/html/sharp/pc-1248_e.html

The pocket computer museum.   1999-2022.  

Retrieved October 12, 2023.  


Eddie


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

HP 15C and Casio fx-9750GIII: Solving Recurrence Relations

HP 15C and Casio fx-9750GIII:   Solving Recurrence Relations


Introduction


The following program attempts to find a closed-form formula to the recurrence relation:


(I)

a_n + P × a_n-1 + Q × a_n-2 = 0


or 


(II)

a_n = -P × a_n-1 + -Q × a_n-2


Without loss of generality, usually P and Q in the latter form (II) are presented as positive constants.  


Two initial conditions are provided, a_0 and a_1 (where n = 0 and n = 1, respectively).  


Equation (I) can be transformed into the characteristic equation:


x^2 + P × x + Q = 0


where the roots are:


x = ( -P ± √(P^2 - 4 × Q)) ÷ 2


and the roots are x = S and x = T.  Assume that the roots S and T are real numbers.


If S ≠ T, the solution is in the form of:


a_n = B × S^n + C × T^n


where B and C are determined by the equations:

a_0 = B + C

a_1 = B × S + C × T


If S = T, the solution is in the form of:


a_n = B × S^n + C × n × S^n


where B and C are determined by the equations:

a_0 = B

a_1 = S × (B + C)




HP 15C:  Solving Recurrence Relations 


Store values to the following registers:


R1 = P 

R2 = Q

R3 = I 

R4 = J


Output registers:


R5 = S

R6 = T

R7 = B

R8 = C


Code:

Step :  Key :  Code


001 :  LBL A :  42,21,11    (solve for S, T)

002 :  RCL 1 :  45,1

003 :  x^2 :  43,11

004 :  4  :   4

005 : RCL× 2 : 45,20, 2

006 : - :  30

007 : √  : 11

008 : STO 0 : 44, 0

009 : RCL- 1 : 45,30, 1

010 : 2 : 2

011 : ÷ : 10

012 : STO 5 : 44, 5

013 : RCL- 0 : 45,30, 0

014 : STO 6 : 44, 6

015 : RCL 5 : 45, 5

016 : TEST 6 : 43,30, 6  (x ≠ y)

017 : GTO 1 : 22, 1


018 : RCL 3 : 45, 3  (if S = T, solve for B, C)

019 : STO 7 : 44, 7

020 : RCL 4 : 45, 4

021 : RCL 5 : 45, 5

022 : RCL× 7 : 45,20, 7

023 : - : 30

024 : RCL÷ 5 : 45,10, 5

025 : STO 8 : 44, 8

026 : GTO 2 : 22, 2


027 : LBL 1 : 42,21, 1  (if S≠T, solve for B, C)

028 : RCL 6 : 45, 6

029 : RCL× 3 : 45,20, 3

030 : RCL- 4 : 45,30, 4

031 : RCL 6 : 45, 6

032 : RCL- 5 : 45,30, 5

033 : ÷ : 10

034 : STO 7 : 44, 7

035 : RCL 5 : 45, 5

036 : CHS : 16

037 : RCL× 3 : 45,20, 3

038 : RCL+ 4 : 45,40, 4

039 : RCL 6 : 45, 6

040 : RCL- 5 : 45,30, 5

041 : ÷ : 10

042 : STO 8 : 44, 8


043 : LBL 2 : 42,21, 2 (view results)

044 : RCL 7 : 45, 7

045 : R/S : 31

046 : RCL 5 : 45, 5

047 : R/S : 31

048 : RCL 8 : 45, 8

049 : R/S : 31

050 : RCL 6 : 45, 6

051 : RTN : 45, 32


Casio fx-9750GIII Program: RCHAR


Text file listing:


'ProgramMode:RUN

"2023_-_09_-_26 EWS"

ClrText

"SOLVE"

"A(N) _+_ P_*_A(N_-_1) "

"_+_ Q_*_A(N_-_2) = 0"

"P"?->P

"Q"?->Q

"A(0)"?->I

"A(1)"?->J

(-P+Sqrt(P^<2>-4Q))/2->S

(-P-Sqrt(P^<2>-4Q))/2->T

If S<>T

Then 

(T*I-J)/(T-S)->B

(-S*I+J)/(T-S)->C

ClrText

Locate 1,3,"B_*_S_^_N _+_ C_*_T_^_N"

Else 

I->B

(J-S*B)/S->C

ClrText

Locate 1,3,"B_*_S_^_N _+_ C_*_N_*_T_^_N"

IfEnd

Locate 1,4,"B="

Locate 4,4,B

Locate 1,5,"S="

Locate 4,5,S

Locate 1,6,"C="

Locate 4,6,C

Locate 1,7,"T="

Locate 4,7,T



Notes:  

This is the text file from Casio fx-9750GIII.  

_:  space

->:  store  (→)

^<2>:  ^2

Sqrt:  √

<>: ≠


Examples


1.  a_n - 11 × a_n-1 + 24 = 0,  a_0 = 3, a_1 = 8


Characteristic Equation:  x^2 - 11x + 24 = 0


Roots:  S = 3, T =-8


Different Roots


3 = B + C

8 = 3 × B - 8 × C


B = -0.2, C = 3.2


Solution:


a_n = -0.2  × 8^n + 3.2 × 3^n



2.  a_n + 6 × a_n-1 + 9 × a_n-2 = 0, a_0 = 2, a_ 11


Characteristic Equation:  x^2 + 6x + 9 = 0


Roots:  S = T = -3


Same Roots


2 = B 

10 = -3 × (B + C)


B = 2, C = -16/3 ≈ -4.3333


Solution:


a_n = 2 × (-3)^n - 16/3 × n × (-3)^n



3.  a_n - 6 × a_n-1 + 4 × a_n-2 = 0, a_0 = 1, a_1 = 15


Characteristic Equation:  x^2 - 6x + 4 = 0


Roots:  

S = 3 + √5 ≈ 5.236067977

T = 3 - √5 ≈ 0.7639320225


Different Roots


1 = B + C

15 = (3 + √5) × B - (3 - √5) × C


B ≈ 3.183281573

C ≈ -2.183281573


Solution:


a_n ≈

3.183281573 × 5.236067977^n - 2.183281573 × 0.7639320225^n



Source


Levin, Oscar.  "2.4 Recurrence Relations"  Discrete Mathematics: An Open Introduction  openmathbooks.org  University of Northern Colorado.   Retrieved August 30, 2023.  https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Discrete_Mathematics_(Levin)/2%3A_Sequences/2.4%3A_Solving_Recurrence_Relations


Eddie


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

Retro Review: Casio fx-19

Retro Review: Casio fx-19



Quick Facts


Model: fx-19

Company: Casio

Production Years:  1976 - 1977

Power:  4 AA batteries.   AC adopter is available.

Type:  Scientific

Operating System:  Chain

Memory Registers:  1

Display:  One line:  8 digits or 5 digits with 2 digit exponent (10^xx)








Features and Keyboard


This is an early Casio scientific calculator with a standard set of features:


*  logarithm, antilogarithm (base 10 and e)

*  trigonometry

*  fractions (auto simplification)

*  one variable statistics


The fx-19 has 38 keys with two switches:  one for power and one for mode selection.  The mode selection switch has three angle modes (radians, degrees, grads) and one variable statistics (S.D σ).   


There is only one shift button, [ arc ], which is only for the inverse trigonometric functions arcsin, arccos, and arctan.  


Everything is displayed in floating point mode.  



Statistics Mode


In statistics mode, a lot of the keys are repurposed:


[ AC ]:   clear all statistical data

[ = ]:  enter statistical data 

[ ° ' '' ] ( σn ):  population deviation

[ 1/x ] ( σn-1 ): standard deviation

[ MC ] ( x-bar ):  mean 

[ MR ] ( n ):  number of data points

[ M- ] ( Σx ): sum of data points

[ M+ ] (Σx^2 ): sum of the square of data points


Example:  

Data Set:  { .786, .869, .542, .599, .649 }


In SD mode, 

[ AC ] .786 [ = ] .869 [ = ] .542 [ = ] .599 [ = ] .649 [ = ]

[ ° ' '' ] ( σn ):  0.120928

[ 1/x ] ( σn-1 ): 0.1352017

[ MC ] ( x-bar ):  0.689

[ MR ] ( n ):  5

[ M- ] ( Σx ): 3.445

[ M+ ] (Σx^2 ): 2.446723



Chain Mode


As we can tell from the pictures, there are no parenthesis keys.   The calculator operates in chain mode, which means the order of operations are not followed.   


In the following examples, the Degrees mode is set.  



Examples:


8 [ × ] 5 [ + ] 11 [ = ]  returns 51


5 [ + ] 8 [ × ] 11 [ = ]  returns 143



For complex calculations, often the use of the memory keys [ M+ ], [ M- ], [MR], and [ MC ] are needed.  Unfortunately, there is no indicator whether a non-zero number is in memory.   Hence, checking with the [ MR ] key is needed.   


Like many four-function regular calculations, [ M+ ] and [ M- ] complete pending operations.


Examples:


71 × 27 + 28 × 16 - 39 × 14


[ MC ]

71 [ × ] 27 [ M+ ]

28 [ × ] 16 [ M+ ]

39 [ × ] 14 [ M- ]

[ MR ]


Result:  1819



sin(30 + 0.05) / sin(30 - 0.05)


In division rational expressions, I prefer to tackle the denominator first.  


[ MC ] 

30 [ - ] .05 [ = ] [ sin ] [ M+ ]

30 [ + ] .05 [ = ] [ sin ] [ ÷ ] [ MR ] [ = ]


Result:  1.0030275



The Power Key


The power key [ x^y ] requires two arguments, the base (x) and the exponent (y).   When the power key is first press, the natural logarithm of x is displayed.


8^5

8 [ x^y ]    (Display:  2.0794415)

5 [ = ]     (Display:  32768)



The user of the power key is a treated as a separation calculation.   If we press any function for x, the power is canceled out.


6^(log 2)


Incorrect way:

6 [ x^y ] 2 [ log ] [ = ]

Result:   0.30103   (log 2)


Correct way:

[ MC ] 2 [ log ] [ M+ ]

6 [ x^y ] [ MR ] [ = ] 

Result:  1.7149319



The exception is roots, x [ x^y ] y [ 1/x ] [ = ]


7^(1/5)


7 [ x^y ] 5 [ 1/x ] [ = ]

Result:  1.4757732



Final Thoughts


The fx-19 is a classic calculator, and is a good option for those who want both a scientific calculator but operates more like a four-function calculator.   The fx-19 is still relatively available.   



Source


"Casio fx-19"  calculator.org.  

https://www.calculator.org/calculators/Casio_fx-19.html

Retrieved October 1, 2023



Eddie


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

Numworks: Polynomial Fit with Numpy (Software version 21 or later)

Numworks:  Polynomial Fit with Numpy  (Software version 21 or later)



The scripts polyfit.py and polyfitg.py perfectly fit a polynomial to a set of points.  For a set of n points, a polynomial of degree n-1 can be perfect fit to the set of points.   For instance,  2 points fit a perfect line,  3 points fit a quadratic polynomial, and 4 points fit a cubic polynomial.    Software version 21 or later is required as the numpy module is used.  


Numworks:  polyfit


polyfit.py:    Fit a number of points to a curve using the numpy module

403 bytes


from math import *

import numpy as np


# 2023-09-25 EWS


n=input("number of points? ")

n=int(n)

d=n-1

x=np.ones(n)

y=np.ones(n)

k=0


while k<n:

  print("point "+str(k+1))

  x[k]=float(input("x? "))

  y[k]=float(input("y? "))

  k+=1


p=np.polyfit(x,y,d)

# list coefficients

print("polynomial vector:")

print("x**n:  coef")


for k in range(n):

  print(str(n-k-1),":  ",str(p[k]))


print(p)




Numworks:  polyfitg


polyfitg.py:   Same as polyfit except a graph of the polynomial is drawn.   The coefficients are shown for 3 before the graph is drawn.  

743 bytes 


from math import *

from time import *

from matplotlib.pyplot import *

import numpy as np


# 2023-09-25 EWS

n=input("number of points? ")

n=int(n)

d=n-1

x=np.ones(n)

y=np.ones(n)

k=0


while k<n:

  print("point "+str(k+1))

  x[k]=float(input("x? "))

  y[k]=float(input("y? "))

  k+=1


p=np.polyfit(x,y,d)


# list coefficients

print("polynomial vector:")

print("x**n:  coef")


for k in range(n):

  print(str(n-k-1),":  ",str(p[k]))


print("\nplotting...")

sleep(3)


# graphing portion

c=(np.max(x)-np.min(x))/100

xc=[]

yc=[]


for i in range(101):

  xp=np.min(x)+i*c

  yp=np.polyval(p,xp)

  xc.append(xp)

  yc.append(yp)


axis((min(xc)-.5,max(xc)+.5,min(yc)-.5,max(yc)+.5)) 

axis(True)

grid(True)

plot(xc,yc,color="purple")

show()





Eddie


All original content copyright, © 2011-2023.  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 15C: The I Squared Rule and HHC 2026

HP 15C: The I Squared Rule and HHC 2026 HHC 2026 Videos Before we start, the videos for HHC 2026 are up! Please take a look, ev...