Saturday, April 17, 2021

Fun with the HP 20S (April 17, 2021 Edition)

Fun with the HP 20S (April 17, 2021 Edition)


A Quick Note - Spam Comments 

I noticed that my blog recently had a lot spam comments, especially since the beginning of this year.  Because of this I am considering turning off the ability to leave comments altogether.  If you are going to comment, please be courteous and stay on topic.  No one wants to read the same spam post about off-shore casinos, printers, or scandalous divorce inquiries.

Thank you and now, on with the post.  



Integer Division


The program calculates the quotient and remainder of the division: 


a ÷ b


Instructions:


Enter a, press [ XEQ ] ( F ), enter b.   Get the quotient, press [ R/S ], get the remainder



Program:


01 61,41,F         LBL F

02 21,2 STO 2

03 45        ÷

04 26        R/S

05 21, 1    STO 1

06 74          =

07 21,0      STO 1

08 51,45    IP

09 26          R/S

10 22,0      STO 0

11 61,45    FP

12 55        ×

13 22,1      RCL 1

14 74        =

15 51,33,0         FIX 0

16 61,44    RND   (round)

17 61,34    ALL

18 61,26    RTN



FIX 0, RND, ALL:  round the number in the display to the nearest integer


Examples:


74 ÷ 6  = 12 R 2

Keystrokes:  74, XEQ F, 6, R/S (12) R/S (2)


1576 ÷ 237 = 6 R154


Day Number


This calculates the day number given the month and the date.   A 365-day year is assumed.  


Instructions:

1.  Store month in memory register 1

2.  Store day in memory register 2

3.  Press XEQ A


Program:


01 61,41,A         LBL A

02 22,1      RCL 1

03 31        INPUT

04 2          2

05 61,42    x≤y?

06 51,41,1         GTO 1

07 33          (

08 33        (

09 22,1      RCL 1

10 75        +

11 1          1

12 34          )

13 55        ×

14 3            3

15 0          0

16 73        .

17 6          6

18 34          )

19 51,45    IP

20 65        -

21 6            6

22 3          3

23 74          =

24 21,3      STO 3

25 51,41,2         GTO 2

26 61,41,1         LBL 1

27 33          (

28 33        (

29 22,1      RCL 1

30 65        -

31 1          1

32 34      )

33 55        ×

34 6            6

35 3          3

36 45        ÷

37 2          2

38 34        )

39 51,45    IP

40 74        =

41 21,3      STO 3

42 61,41,2         LBL 2

43 75        +

44 22,2      RCL 2

45 74        =

46 21,3      STO 3

47 61,26    RTN


Examples:


February 16:  2 STO 1, 16 STO 2, XEQ A.  Result:  47

August 22:  8 STO 1, 22 STO 2, XEQ A.   Result:  234


Source:

Duffett-Smith, Peter.  Practical Astronomy With Your Calculator  2nd Ed.  Cambridge University Press: Cambridge.  1979  ISBN 0-521-28411-2


Astronomy:  Geocentric Parallax


The program calculates the quantities ρ sin θ' and ρ cos θ' where:


ρ = distance the observer is from the center of the Earth in meters

θ' = geocentric latitude in degrees


Inputs:


h = height of observer above sea level in meters

L = latitude of the observer in degrees, north is positive


Calculations:


h' = h / 6378140   (estimated radius of Earth is about 6,378 km)

u = atan(0.996647 tan L)

ρ sin θ' = 0.996647 sin u + h' sin L

ρ cos θ' = cos u + h' cos L


Program:


01 61,41,b         LBL B

02 61,23    DEG

03 33          (

04 22,1      RCL 1

05 25        TAN

06 55        ×

07 73        .

08 9          9

09 9          9

10 6            6

11 6          6

12 4          4

13 7          7

14 21,0      STO 0

15 34          )

16 51,25    ATAN

17 21,3      STO 3

18 22,2      RCL 2

19 45        ÷

20 6            6

21 3            3

22 7            7

23 8          8

24 1            1

25 4          4

26 0          0

27 74          =

28 21,4        STO 4

29 22,0      RCL 0

30 55          ×

31 22,3      RCL 1

32 23        SIN

33 75        +

34 21,1      RCL 1

35 23          SIN

36 55            ×

37 22, 4        RCL 4

38 74        =

39 26          R/S

40 22, 3        RCL 3

41 24            COS

42 75          +

43 22, 4      RCL 4

44 55        ×

45 22, 1      RCL 1

46 24          COS

47 74          =

48 61,26      RTN


Registers used:


R1 = L  (input)

R2 = h   (input)

R3 = u

R4 = h / 6378140

R0 = 0.996647


Example:


Input:

L = 45.76° N

h = 53.48 m


54.76 STO 1, 53.48 STO 2, XEQ B

Result:  

ρ sin θ' = .712859241, R/S

ρ cos θ' = .698873028


Source:

Duffett-Smith, Peter.  Practical Astronomy With Your Calculator  2nd Ed.  Cambridge University Press: Cambridge.  1979  ISBN 0-521-28411-2


Eddie

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