Post Reply 
(15C) Digital Root, Modulus, and 2D Coordinate Rotation
01-08-2016, 03:24 AM (This post was last modified: 06-15-2017 01:23 PM by Gene.)
Post: #1
(15C) Digital Root, Modulus, and 2D Coordinate Rotation
Link:

http://edspi31415.blogspot.com/2016/01/h...nd-2d.html


HP 15C: Digital Root

Input: Enter an integer and execute Label A (or whatever label you want to assign).

Program:

Code:
Step    Key    Key Code
001    LBL A    42, 21, 11
002    ENTER    36
003    ENTER    36
004    1    1
005    -    30
006    9    9
007    ÷     10
008    INT    43, 44
009    9    9
010    *    20
011    -    30
012    RTN    43, 32

Formula used: (Define DR(n) as the digital root function)
DR(n) = n – 9 * int((n-1)/9), n > 0

DR returns the sum of n’s digits and repeats until a single digit remains.

Examples:
DR(4514) = 5
DR(9376) = 7
DR(636088) = 4
DR(761997) = 3

HP 15C: Modulus Function

Input:
Y: A
X: B

The program calculates A mod B.

Program:

Code:
Step    Key    Key Code
001    LBL B            42, 21, 2
002    STO 2    44, 2
003    X<>Y      34
004    STO 1    44, 1
005    X<>Y      34
006    ÷            10
007    FRAC            42, 44
008    RCL* 2    45, 20, 2
009    STO 3    44, 3
010    RCL 1     45, 1
011    RCL* 2    45, 20, 2
012    TEST 1 (x > 0)    43, 30, 1
013    GTO 1    22, 1
014    RCL 3       45, 3
015    RCL+ 2    45, 40, 2
016    STO 3    44, 3
017    RTN          43, 32
018    LBL 1       42, 21, 1
019    RCL 3          45, 3
020    RTN          43, 32

Formula Used:
A mod B = B * frac(A/B)
Add B to result if A*B < 0.

Registers Used:
R1 = A
R2 = B
R3 = A mod B


Examples:
A = 48, B = 3, result = 0
A = 41.3, B = 12, result = 5.3
A = 48, B = -7, result = -1
A = -50.2, B = 36, result = 21.8

HP 15C: 2D Coordinate Rotation

Input: Store the following: X in R4, Y in R5, and θ in R3. Run the program.

Results are stored in R6 and R7, for X’ and Y’, respectively. X’ is displayed first, press R/S to get Y’.

This program uses the Polar to Rectangular conversion.

Program:

Code:
Step    Key    Key Code
001    LBL C           42, 21, 13
002    RCL 3      45, 3
003    RCL 4      45, 4
004    >R           42, 1
005    STO 6    44, 6
006    X<>Y     34
007    STO 7    44, 7
008    RCL 3            45, 3
009    RCL 5            45, 5
010    >R            42, 1
011    RCL 7            45, 7
012    +            40
013    STO 7    44, 7
014    X<>Y            34
015    CHS            16
016    RCL 6      45, 6
017    +            40
018    STO 6    44, 6
019    R/S           31
020    X<>Y       34
021    RTN          43, 32


Formulas Used:
X’ = X * cos θ – Y * sin θ
Y’ = X * sin θ + Y * cos θ

Examples:
X (R4) = 1, Y (R5) = 2, θ (R3) = 30°. Results: X’ (R6) ≈ -0.1340, Y’ (R7) ≈ 2.2321
X (R4) = 6.45, Y (R5) = 5.25, θ (R3) = 176°. Results: X’ (R6) ≈ -6.8005, Y’ (R7) ≈ -4.7872
Visit this user's website Find all posts by this user
Quote this message in a reply
01-08-2016, 11:23 PM
Post: #2
RE: 15C: Digital Root, Modulus, and 2D Coordinate Rotation
(01-08-2016 03:24 AM)Eddie W. Shore Wrote:  HP 15C: 2D Coordinate Rotation

The same using complex numbers:

Code:
001 - 42,21,13  LBL C
002 -    45  4  RCL 4
003 -    45  5  RCL 5
004 -    42 25  I
005 -        1  1
006 -    45  3  RCL 3
007 -    42 25  I
008 -    42  1  ->R
009 -       20  x
010 -    44  6  STO 6
011 -    42 30  Re<>Im
012 -    44  7  STO 7
013 -    43 32  RTN

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)