Thursday, July 6, 2017

Fun With the HP 42S

Fun With the HP 42S

Previous Links:

HP 42S Programming Part I:  Matrix Column Sum, GCD, Error Function:  http://edspi31415.blogspot.com/2016/07/hp-42s-programming-part-i-matrix-column.html

HP 42S Programming Part II:  Dew Point, Ellipse Area and Eccentricity, Easy Transverse:
http://edspi31415.blogspot.com/2016/07/hp-42s-programming-part-ii-dew-point.html

HP 42S Programming Part III: Numerical Derivative, Recurring Sequences, Fractions:
http://edspi31415.blogspot.com/2016/07/hp-42s-programming-part-iii-numerical.html



HP 42S Julian Date

Given month, day, year, and university time (Greenwich), the Julian date is calculated.  For January 1, 2000 at 12:00 AM, the date is 2,451,545.5.

00 {141-Byte Prgm}
01 LBL “JULDATE”
02 “MONTH”
03 PROMPT
04 STO 01
05 “DAY”
06 PROMPT
07 STO 02
08 “4 DIGIT YEAR”
09 PROMPT
10 STO 03
11 “UT TIME”
12 PROMPT
13 STO 04
14 367
15 RCL* 03
16 STO 00
17 9
18 RCL+ 01
19 12
20 ÷
21 IP
22 RCL+ 03
23 4
24 ÷
25 7
26 *
27 IP
28 STO -00
29 RCL 01
30 9
31 –
32 7
33 ÷
34 RCL+ 03
35 100
36 ÷
37 IP
38 3
39 *
40 4
41 ÷
42 IP
43 STO- 00
44 275
45 RCL* 01
46 9
47 ÷
48 IP
49 STO+ 00
50 RCL 02
51 STO+ 00
52 1721028.5
53 STO+ 00
54 RCL 04
55 24
56 ÷
57 STO+ 00
58 RCL 00
59 END

Example:

Input:  May 8, 2017, 03:00 UT.  Result:  2457881.6250

HP 42S Sun Approximate Declination, Altitude, and Azimuth


Input:  Days after the vernal equinox (typically March 21), Earth’s latitude (north/south), number of hours after local noon (example:  for 7 AM, enter -5.  For 7 PM, enter 7).

00 { 147-Byte Prgm }
01 LBL “SUNAA”
02 DEG
03 “DAYS AFTER EQ.”
04 PROMPT
05 STO 00
06 “LATTITUDE”
07 PROMPT
08 STO 01
09 “HRS AFTER NOON”
10 PROMPT
11 STO 02
12 0.9856
13 RCL* 00
14 SIN
15 23.45
16 *
17 STO 04
18 COS
19 RCL 01
20 COS
21 *
22 15
23 RCL* 02
24 COS
25 *
26 RCL 01
27 SIN
28 RCL 04
29 SIN
30 *
31 +
32 ASIN
33 STO 05
34 SIN
35 RCL 01
36 SIN
37 *
38 RCL 04
39 SIN
40 –
41 RCL 05
42 COS
43 RCL 01
44 COS
45 *
46 ÷
47 ACOS
48 STO 06
49 RCL 04
50 “DECLINATION”
51 AVIEW
52 STOP
53 RCL 05
54 “ALTITUDE”
55 AVIEW
56 STOP
57 RCL 06
58 “AZIMUTH”
59 AVIEW
60 END


Example:

Input:  100 days after the vernal equinox, 43.72° N, about 12 noon (T = 0)
Results:  Declination ≈ 23.1888°, Altitude:  69.4688°, Azimuth: 0.0002°

 HP 42S Chebyshev Polynomial

The trigonometric definition is used to calculate T_n(x):

For |x| > 1, cosh (n * acosh x)
For |x| ≤ 1, cos (n * acos x)

00 {42-Byte Prgm}
01 LBL “CHEBY”
02 “N”
03 PROMPT
04 STO 00
05 “X”
06 PROMPT
07 STO 01
08 ABS
09 1
10 X≥Y?
11 GTO 00
12 RCL 01
13 ACOSH
14 RCL* 00
15 COSH
16 GTO 01
17 LBL 00
18 RCL 01
19 ACOS
20 RCL* 00
21 COS
22 LBL 01
23 END

Examples:

T_4(2) (n = 4, x = 2).  Result:  97

T_4(0.5)  (n = 4, x = 0.5)  Result:  -0.5

HP 42S Pulley

There are two weights in a pulley system, held by a rope has a negligible contribution.  The program uses SI units (kg, m, s, with g = 9.80665 m/s^2).  The simultaneous equations solve for acceleration (m/s^2) and tensions:

T – m1 * a = m1 * g
T + m2 * a = m2 * g

Source:  HP 22S Science Student Applications.  Edition 1.  Corvallis, Oregon.  May 1988

00 {161-Byte Prgm}
01 LBL “PULLEY”
02 “MASS 1 (KG)”
03 PROMPT
04 STO 01
05 “MASS 2 (KG)”
06 PROMPT
07 STO 02
08 9.80665
09 STO 00
10 2
11 ENTER
12 2
13 DIM “MAT1”
14 INDEX “MAT1”
15 1
16 STOEL
17 J+
18 RCL 01
19 +/-
20 STOEL
21 2
22 ENTER
23 1
24 STOIJ
25 1
26 STOEL
27 J+
28 RCL 02
29 STOEL
30 2
31 ENTER
32 1
33 DIM “MAT2”
34 INDEX “MAT2”
35 RCL 00
36 RCL* 01
37 STOEL
38 I+
39 RCL 00
40 RCL* 02
41 STOEL
42 RCL “MAT1”
43 INVRT
44 RCL “MAT2”
45 *
46 STO “MAT3”
47 INDEX “MAT3”
48 RCLEL
49 “T”
50 AVIEW
51 STOP
52 I+
53 RCLEL
54 “a”
55 AVIEW
56 END

Example:  m1 = 32 kg, m2 = 56 kg
Result:  tension = 399.3981, a = 2.6745 m/s^2

 HP 42S Rotation Matrix

R = [[ cos θ, -sin θ ],[ sin θ, cos θ ]]

00 {138-Byte Prgm}
01 LBL “ROTATE2”
02 DEG
03 “ANGLE °”
04 PROMPT
05 STO 00
06 1
07 ENTER
08 2
09 DIM “MAT1”
10 INDEX “MAT1”
11 “X0”
12 PROMPT
13 STOEL
14 J+
15 “Y0”
16 PROMPT
17 STOEL
18 2
19 ENTER
20 2
21 DIM “MAT2”
22 INDEX “MAT2”
23 RCL 00
24 COS
25 STOEL
26 J+
27 RCL 00
28 SIN
29 +/-
30 STOEL
31 2
32 ENTER
33 1
34 STOIJ
35 RCL 00
36 SIN
37 STOEL
38 J+
39 RCL 00
40 COS
41 STOEL
42 RCL “MAT1”
43 RCL “MAT2”
44 *
45 STO “MAT3”
46 INDEX “MAT3”
47 RCLEL
48 “X1”
49 AVIEW
50 STOP
51 J+
52 RCLEL
53 “Y1”
54 AVIEW
55 END

Example:
Input:  [3, -2], at an angle θ = 40°
Result:  [ 1.0126, -3.4605 ]

 Always fun working with the classic HP 42S!

Eddie

This blog is property of Edward Shore



Fun with the HP 30b

Fun with the HP 30 b Introduction The following programs are for the HP 30b Business Professional. Did you know that the 30b...