Wednesday, July 4, 2018

Fun with the HP 15C


Fun with the HP 15C

Happy Independence Day, United States!

Fractional Derivative:  kth Derivative of f(x) = x^n

This program calculates the kth derivative of x^n. The program allows for partial derivatives of x^n (where k is not an integer, such as half-integers).

Formula:

d^k/dx^k x^n = n!/(n-k)! * x^(n-k)

Input:
R0: point (x’)
R1:  n
R2: k

Program:

Step
Key
Code
001
LBL A
42, 21, 11
002
RCL 0
45, 0
003
RCL 1
45, 1
004
RCL - 2
45, 30, 2
005
y^x
14
006
LAST x
43, 36
007
x!
42, 0
008
1/x
15
009
*
20
010
RCL 1
45, 1
011
x!
42, 0
012
*
20
013
RTN
43, 32

Example:

d/dx^4 x^8  at x = 6

R0 = x’ = 6
R1 = n = 8
R2 = k = 4

Result:  2177280

d/dx^1.5 x^3.4 at x = 1

R0 = x’ = 1
R1 = n = 3.4
R2 = k = 1.5

Result:  5.5469

Sight Reduction Table

The program calculates altitude and azimuth of a given celestial body.

Inputs:

R1: Local Hour Angle (LHA), west is positive, east is negative
R2: The observer’s latitude on Earth, north is positive, south is negative (L)
R3: Declination of the celestial’s body, north is positive, south is negative (δ)

Each entry will need to be in decimal format.  If your angels are in HMS (hours-minutes-seconds) format, convert the angels to decimals by H before storing the values.

Formulas:

Altitude: 
H = asin (sin δ sin L + cos δ cos L cos LHA)

Azimuth:
Z = acos ((sin δ – sin L sin H) ÷ (cos H cos L))
If sin LHA < 0 then Z = 360° - Z

Outputs:

Altitude (in decimal), R/S, Azimuth (in decimal)

Program:

Step
Key
Code
001
LBL C
42, 21, 13
002
DEG
43, 7
003
RCL 3
45, 3
004
SIN
23
005
RCL 2
45, 2
006
SIN
23
007
*
20
008
RCL 3
45, 3
009
COS
24
010
RCL 2
45, 2
011
COS
24
012
*
20
013
RCL 1
45, 1
014
COS
24
015
*
20
016
+
40
017
ASIN
43, 23
018
STO 4
44, 4
019
R/S
31
020
SIN
23
021
RCL 2
45, 2
022
SIN
23
023
*
20
024
CHS
16
025
RCL 3
45, 3
026
SIN
23
027
+
40
028
RCL 4
45, 4
029
COS
24
030
RCL 2
45, 2
031
COS
24
032
*
20
033
÷
10
034
ACOS
43, 24
035
STO 5
44, 5
036
RCL 1
45, 1
037
SIN
23
038
TEST 2 (x<0)
43, 30, 2
039
GTO 1
22, 1
040
3
3
041
6
6
042
0
0
043
RCL - 5
45, 30, 5
044
STO 5
44, 5
045
LBL 1
42, 21, 1
046
RCL 5
45, 5
047
RTN
43, 32

Source:  “NAV 1-19A Sight Reduction Table”    HP 65 Navigation Pac.  Hewlett Packard, 1974.

Three Point Lagrangian Interpolation

This program calculates a point (x0, y0) given three known points (x1, y1), (x2, y2), and (x3, y3) where x0 is in between min(x1, x2, x3) and max(x1, x2, x3).  Ideally, x1 < x2 < x3.

Input:

R0 = x0 (on the x stack)

Store before running the program:

R1 = x1, R4 = y1
R2 = x2, R5 = y2
R3 = x3, R6 = y3

Other registers used: R7, R8, R9

Step
Key
Code
001
LBL E
42, 21, 15
002
STO 0
44, 0
003
RCL 4
45, 4
004
STO 7
44, 7
005
RCL 5
45, 5
006
STO 8
44, 8
007
RCL 6
45, 6
008
STO 9
44, 9
009
RCL 0
45, 0
010
RCL - 1
45, 30, 1
011
STO * 8
44, 20, 8
012
STO * 9
44, 20, 9
013
RCL 0
45, 0
014
RCL – 2
45, 30, 2
015
STO * 7
44, 20, 7
016
STO * 9
44, 20, 9
017
RCL 0
45, 0
018
RCL – 3
45, 30, 3
019
STO * 7
44, 20, 7
020
STO * 8
44, 20, 8
021
RCL 1
45, 1
022
RCL – 2
45, 30, 2
023
STO ÷ 7
44, 10, 7
024
CHS
16
025
STO ÷ 8
44, 10, 8
026
RCL 1
45, 1
027
RCL – 3
45, 30, 3
028
STO ÷ 7
44, 10, 7
029
STO ÷ 9
44, 10, 9
030
RCL 2
45, 2
031
RCL – 3
45, 30, 3
032
STO ÷ 8
44, 10, 8
033
STO ÷ 9
44, 10, 9
034
RCL 7
45, 7
035
RCL + 8
45, 40, 8
036
RCL + 9
45, 40, 9
037
RTN
43, 32

Example:

R1 = 5, R4 = 0.4
R2 = 10, R5 = 0.9
R3 = 15, R6 = 1.3

R0 = 12, result: 1.0720

R0 = 8, result: 0.7120

Source:  R. Woodhouse.  “Lagrangian Interpolation Routines” Datafile Summer 1984 Vol. 3 No. 3, Page 14

Quadratic Equation with Complex Coefficients

This program solves the equation where B and C are complex numbers:

x^2 + B*x + C = 0

where the roots are:

x = -B/2 ± (B^2/4 – C)

Store the following values before running:

R1 = real(B),  R2 = imag(B)
R3 = real(C), R4 = imag(C)

Output:

Root 1 (press [ f ], hold (i) for the complex part), R/S, Root 2

Program:

Step
Key
Code
001
LBL C
42, 21, 13
002
GSB 1
32, 1
003
GSB 2
32, 2
004
+
40
005
R/S
31
006
GSB 1
32, 1
007
GSB 2
32, 2
008
-
30
009
RTN
43, 32
010
LBL 1
42, 21, 1
011
RCL 1
45, 1
012
RCL 2
45, 2
013
I
42, 25
014
2
2
015
CHS
16
016
÷
10
017
RTN
43, 32
018
LBL 2
42, 21, 2
019
RCL 1
45, 1
020
RCL 2
45, 2
021
I
42, 25
022
x^2
43, 11
023
4
4
024
÷
10
025
RCL 3
45, 3
026
RCL 4
45, 4
027
I
42, 25
028
-
30
029
11
030
RTN
43, 32

Example:

x^2 + (-1 + i)*x + (3i) = 0

R1 = -1, R2 = 1
R3 = 0, R4 = 3

Results:
1.8229 – 1.8229i
-0.8229 + 0.8229i

x^2 + 3*x + (-5 + 6i) = 0

R1 = 3, R2 = 0
R3 = -5, R4 = 6

Results:
1.3862 – 1.0394i
-4.3862 + 1.0394i

Eddie

All original content copyright, © 2011-2018.  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.  Please contact the author if you have questions.

  Casio fx-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs Today’s blog entry is a comparison of how a hist...