Showing posts with label Julian Date. Show all posts
Showing posts with label Julian Date. Show all posts

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



Thursday, May 28, 2015

HP Prime, TI-84 Plus, Casio Prizm: Julian Day Shortcut Formulas

Julian Day Shortcut Formulas

Here are a couple of formulas that can be used to quickly get the Julian Day.  (I haven't figured how to include the time yet).


HP Prime (Rev. 7820):

yyyy:  four digit year, mm:  two digit month, dd: two digit day.  The international date format is used.

From December 31, 1899:

JD = DDAYS(1899.1231,yyyy.mmdd) + 2415020

Alternatively, from November 16, 1858:

JD = DDAYS(1858.1116, yyyy.mmdd) + 2.4E6


TI-84 (and BA II  Plus to that extent):

Dates are good from January 1, 1950 to December 31, 2049:

JD = dbd(1.0150, mm.ddyy) + 2433283

The days between dates function (dbd) is accessed by pressing [ APPS ], [ 1 ], [ALPHA], [ x^-1] (D).  

Casio Prizm and fx-Graphing calculators:

Dates are good from January 1, 1901 to December 31, 2099:

JD = Days_Prd(1,1,1901,mm,dd,yyyy) + 2415386

Where to find Days_Prd:  [ OPTN ], ( > ) (until you see the FINANCE sub menu), (FINANCE), ( > ), (DAYS), (PRD)

Hope you find this helpful.

Source:
"Julian Day"  http://en.wikipedia.org/wiki/Julian_day   Retrieved May 28, 2015


Eddie


This blog is property of Edward Shore.  2015.


Wednesday, February 11, 2015

HP Prime, HP 42S, HP 12C: Julian Date

The following program calculates the Julian Date given:

M = month

D = day
Y = year, four digits
UT = Universal Time.  The universal time is notated by 0:00 to 24:00, as the current time at the Greenwich Mean Time.  Depending on where you live, it may be necessary to adjust the current time in your time zone to get Greenwich Mean Time.  For example, add 8 hours to the Pacific Standard Time, and add 7 hours to the Pacific Daylight Savings time, to get the equivalent Greenwich Mean Time for the Pacific Time Zone.  You may have to adjust the day number by 1 (either way) as a consequence. 

Formula for the Julian Date:


j:=367*Y-IP(7*(Y+IP((M+9)/12))/4)

-IP(3*(IP((Y+(M-9)/7)/100)+1)/4)

+IP(275*M/9)+D+1721028.5+H/24

where IP is the integer function.  The integer function is also symbolized by INT, INTG, and iPart.  This is the most complete formula, as there are shortcut formulas for Julian Date.


Source for formula:  http://scienceworld.wolfram.com/astronomy/JulianDate.html 


Here are the programs for Julian Date for three different HP calculators:  HP Prime, HP 42S, and HP 12C.


My thanks to Jason Foose who traded with me, I now have a 42S.  He asked to trade me for my one of my 50g's.  


Julian Date:  HP Prime


EXPORT JULIAN(M,D,Y,H)

BEGIN
// wolfram.com
// 2015-02-08
// H UT time
// +8 PST +7 PDT
LOCAL j;
j:=367*Y-IP(7*(Y+IP((M+9)/12))/4)
-IP(3*(IP((Y+(M-9)/7)/100)+1)/4)
+IP(275*M/9)+D+1721028.5+H/24;
RETURN j;

END;

Julian Date:  HP 42S


Before running the program "JD", store the following:

Month (M) to Memory 01
Day (D) to Memory 02
Year (Y) to Memory 03
Universal Time (H) to  Memory 04

The Julian Date is stored in Memory 00.

(edited 2/13/2015 - thanks Mike)

00   { 102-Byte Prgm }

01   LBL "JD"
02   367
03   RCLx 03
04   STO 00
05   9
06   RCL+ 01
07   12
08   ÷
09   IP
10   RCL+ 03
11   7
12   x
13   4
14   ÷
15   IP
16   STO- 00
17   -9
18   RCL+ 01
19   7
20   ÷
21   RCL+ 03
22   100
23    ÷
24    IP
25    1
26    +
27    0.75
28    x
29    IP
30    STO- 00
31    275
32    RCLx 01
33    9
34    ÷
35   IP
36   STO+ 00
37   RCL 00
38   RCL+ 02
39   1721028.5
40   +
41   RCL 04
42   24
43   ÷
44    +
45   STO 00
46   RCL 00
47  .END.

Examples:

January 7, 2015;  12:35 UT
M = 1, D = 7, Y = 2015,  H = 12.58333333

Result:  JD = 2,457,030.02431

December 17, 2230;  18:30 UT
M = 12, D = 17, Y = 2230, H = 18.5

Result:  JD = 2,535,901.27083


Julian Date:  HP 12C

This program uses the ΔDYS function.  Universal time is assumed to be 12:00.  

Step    Key    Key Code
01       1         1
02       .          48
03       0         0
04       1         1 
05       2         2
06       x<>y   34
07       ΔDYS 43 26
08       2         2 
09       4         4
10       5         5
11       1         1
12       5         5
13       4         4
14       5         5
15       +        40


Examples:

June 30, 2016;   JD = 2,457,570

October 31, 2111:  JD = 2,492,390

Hopefully this program will be helpful.  Until next time,

Eddie



This blog is property of Edward Shore.  2015




Sunday, May 19, 2013

HP15C: Julian Date from Gregorian Date

Thanks to the University of Texas at San Antonio Computer Science Department. The explanation and formulas can be found by clicking on this link.

Note: This program only works for dates on or after October 15, 1582. Thank you Dieter.


Calculator
HP 15C (can be adopted with any RPN keystroke calculator)

Input
Preload the following information into these registers:
R1 = month (1 for January, 12 for December)
R2 = date
R3 = year in four digits (example: 2013)

Output
R0 = Julian Date

Temporary
R4 = a = integer((14-month)/12)
R5 = y = year + 4800 - a

Formulas
(See link above)
a = integer((14-month)/12)
y = year + 4800 - a
m = month + 12a - 3
Julian Date = day + integer((153m+2)/5) + 365y + integer(y/4) - integer(y/100) + integer(y/400) - 32045

Assumptions: 12:00 PM Universal Time is assumed (that's 7:00 AM in Pacific Standard Time or 8:00 AM in Pacific Daylight Savings Time)

Program
LBL A
1
4
RCL - 1
1
2
÷
INT
STO 4
4
8
0
0
RCL + 3
RCL - 4
STO 5
RCL 2
STO 0
1
2
RCL × 4
RCL + 1
3
-
1
5
3
×
2
+
5
÷
INT
STO + 0
3
6
5
RCL × 5
STO + 0
RCL 5
4
÷
INT
STO + 0
RCL 5
1
%
CHS
INT
STO + 0
RCL 5
4
÷
1
%
INT
STO + 0
RCL 0
3
2
0
4
5
-
STO 0
RTN


In HP RPN calculators, a number followed by 1, %, divides said number by 100.

Example:

March 14, 1977 has a Julian Date of 2,443,217
April 28, 2012 has a Julian Date of 2,456,046
December 31, 2015 has a Julian Date of 2,457,388

This blog is property of Edward Shore. 2013



Earth's Radius by Latitude

Earth's Radius by Latitude Introduction: Calculating the Earth’s Radius In quick, general calculations, we assume that the...