Thursday, February 26, 2015

Throwback Thursday: Programs for the HP 49g+/50g from 2003-2007

Throwback Thursday:  Programs for the HP 49g+/50g from 2003-2007

My first Hewlett Packard calculator was an HP 48G+, which I bought in 2000.  I really did not get serious into RPN and RPL until I bought an HP 49g+ in 2003.  Despite keyboard problems, the 49g+ was my go-to calculator.   The first 49g+ had a plus key that came loose, the second one I had trouble with the ON button.  Thankfully, by the time the HP 50g was released, the keyboard was reliable.  I bought my first 50g I think in 2003 – not sure.  It was the standard black 50g with orange and white text. Several years later, I ordered the blue 50g from Spain.  Recently, I traded the black 50g with a friend of mine (me getting a HP 42S in return). 

During 2003 to 2006 (I wish I noted the dates when I programmed these things back then), I made a library of programs that covered math, science, finance, and stats.  After finding them still on the SD card, today, I am going to list some of my favorite programs from that era. 

All the programs presented were done in User RPL and most of them, if not all of them, should be able to be used on any of the HP 48 series.  (no guarantees)

QCKPLOT – Simplified Plot Screen
(updated 2/19/2015)

QCKPLOT is probably my favorite out of the bunch.  QCKPLOT allows the user to plot a single function y(x) in a familiar graph set up screen input interface.  The plotting interface with the 49g+ and 50g took a while to get used to. 



QCKPLOT:
<< ‘X’ PURGE
“Quick Function Plot” 
{ { “y(x)=” “Enter y(x)” }
{ “xmin=” “x minimum” }
{ “xmax=” “x maximum” }
{ “ymin=” “y minimum” }
{ “ymax=” “y maximum” } }
{ 2 2 } { } { } INFORM
IF 0 == THEN KILL END
EVAL YRNG XRNG STEQ ‘X’ INDEP FUNCTION (0,0) AXES
ERASE DRAX DRAW PICT {#0d #0d} “Y=” EQ →STR + 1
→GROB GOR PICTURE >>

You can use RPN to build expressions.  However, everything for the window variables must evaluate to numbers.  For example, if you want to set xmax to 2π, use 2 π * →NUM [ENTER].  Which brings me to my next favorite…

PCTXT:  Puts text on the graph screen.

PCTXT inserts a text screen to any Cartesian point on the graph screen.  The program does not immediately show the graph screen upon completion, which allows for use as a subroutine.  If PCTXT is used a standalone program, press the left arrow button [ ← ] or hold [left shift] while pressing [ F3 ] to see the results. (I am assuming you are in RPN mode).

Input:
2:  coordinates
1:  string

PCTXT:
<< 1 →GROB PICT ROT C→PX ROT GXOR >>

ZETA41:  Zeta Function Approximation

The HP 49g+/50g does not have a built in Reimann Zeta function.  Using the standard definition of the zeta function takes forever.

Σ(I=1, infinity, 1/X^Z)

 What is presented here is a series that converges faster than the standard definition. The upper limit of 250 is arbitrary – you can increase the upper limit for better accuracy, but keep in mind it there is a cost in calculation time. The accuracy increases as X increases.

Input:
1:  X

ZETA41:
<< → X ‘∑(I=1,250,(-1)^(I+1)/I^X)/(1-2^(1-X))’ >>

FIB:  nth Fibonacci Number

FIB uses an explicit formula to calculate the nth Fibonacci number, rather than use a sequence loop. 

Input:
1:  N

FIB:
<< → N
<< 1 5 √ + 2 / N ^ 1 5 √ - 2 / N ^
- 5 √ / EVAL 0 RND >> >>

Test:  FIB(8) = 21,  FIB(12) = 144

CRDTRN Subroutine:  (Coordinate Transformation)

CRDTRN transforms a coordinate (x, y) to a new coordinate (x’, y’) with new center (xc, yc) and rotation angle θ.  CRDTRN is both a good standalone program and a useful subroutine.

Input:
5:  XOLD
4:  YOLD
3:  XCTR
2:  YCTR
1:  θ

CRDTRN
<< → XOLD YOLD XCTR YCTR θ
<< XOLD YOLD R→C XCTR YCTR R→C – θ DUP COS →NUM SWAP NEG SIN →NUM R→C * >> >>

Example:  Let the original coordinate be (1,2)  What would be the coordinates if the center was moved to (-1, 3) and the plane was rotated 60⁰ (π/3 radians)?

In Raidian Mode:
5:  1
4:  2
3:  -1
2:  3
1:  π/3

New coordinate:  (.13397456215, -2.23205080757)

QUADRES:  Quadratic Regression (uses ∑DAT)
(Update 2/19/2015)

QUADRES aims to fulfill a missing statistical regression for the HP 49g+/50g series:  quadratic regression.

Y = a*X^2 + b*X + c

The program uses the standard system statistics matrix ΣDAT.  The coefficients are returned in a matrix:

[[ c ]
[ b ]
[ a ]]

Example:

ΣDAT =
[[ 2, .23 ]
[ 3, .58 ]
[ 4, .96 ]
[ 8 1.85 ]
[ 16 3.66 ]]

Results:
[[ -.302930140195 ]
[ .304114954514 ]
[ -3.55628308881E-3 ]]

Or Y = -3.55628308881E-3*X^2 + .304114954514*X - .302930140195

QUADRES:
<< ∑DAT 1 COL- VANDERMONDE DUP SIZE OBJ→ DROP DROP 3 2 →LIST {1,1}
SWAP SUB LSQ >>

CSUM:  Sum of each of the matrix’s columns
RSUM:  Sum of each of the matrix’s rows

An example for CSUM and RSUM:

Matrix:
[[ 2, 3, -7 ]
[ 1, 8, 1 ]
[ -3, 4, 6 ]]

CSUM: [0, 15, 0]
RSUM: [-2, 10, 7]

Input:  Matrix

CSUM:
<< →COL → S
<< 1 S START AXL ∑LIST S ROLL NEXT
S →LIST AXL >> >>

RSUM:
<< →ROW → S
<< 1 S START AXL ∑LIST S ROLL NEXT
S →LIST AXL >> >>

LVEVAL:  Evaluate (simplify) every element in a list or vector

LVEVAL evaluates and simplifies each component of a given list or vector.  For example, LVEVAL turns a list consisting of:

{‘e^2’, ‘π/2’, ‘5.273*LOG(3.44)’} to:

In exact mode:
{‘e^2’, ‘π/2’, 2.82927266768}

Or in approximate mode:
{7.38905609893, 1.5707963268, 2.82927266768}

Input:
1:  list/vector

LVEVAL:
<< → LV
<< LV TYPE 5 IF ≠
THEN LV AXL ‘LV’ STO 1 SF END 1 LV SIZE
FOR I LV I GET EVAL LV I 3 ROLL PUT ‘LV’
STO NEXT IF 1 FS? THEN LV AXL ‘LV’ STO 1
CF END LV >> >>



Bezier Curve

This program draws a Bezier curve.  I honestly don’t quite remember what α0, β0, α1, and β1 represent – I think they are points that are not on the curve be affect the path of the curve. (X0, Y0) and (X1, Y1) are end points. 


« 'T' PURGE PARAMETRIC { T 0. 1. } INDEP "Bézier Curve" { "X0" "Y0" "α0" "ß0" "X1" "Y1" "α1" "ß1" } { 2. 4. } { } { } INFORM 0.
  IF ==
  THEN KILL
  END OBJ→ DROP → X0 Y0 α0 ß0 X1 Y1 α1 ß1
  « X0 X1 - 2. * α0 α1 + 3. * + 'T' 3. ^ * X1 X0 - 3. * α1 α0 2. * + 3. * - 'T' 2. ^ * + α0 3. * 'T' * + X0 + Y0 Y1 - 2. * ß0 ß1 + 3. * + 'T' 3. ^ * Y1 Y0 - 3. * ß1 ß0 2. * + 3. * - 'T' 2. ^ * + ß0 3. * 'T' * + Y0 + i * + 'XY1(T)' SWAP = DEFINE 'T' XY1 STEQ 'T' XY1 ERASE AUTO DRAX DRAW PICTURE  »  »


One Minute Marvels

The document “One Minute Marvels” by Richard Nelson and Wlodek Mier-Jedrzejowicz is a collection of short, very effective RPL programs for the HP 48 series.  Programs include list operations (including rotate a list’s elements, fill a list with zeroes, randomize a list), calendar functions (including day of the week, stopwatch programs), and math and utility programs (LCD, GCM, Ulad Principle, quick quadratic equation, and flag toggles just to name a few).  For owners of the HP 48 series, including HP 49g+/50g, I consider this document an excellent addition to your mathematics library.

Link to download “One Minute Marvels”:  http://www.hpcalc.org/details.php?id=1691


Cheers to the HP 48 series and my trusty blue HP 50g!

Eddie



This blog is property of Edward Shore – 2015.

Sunday, February 22, 2015

HP Prime and TI-84+: RLC Parallel Circuit and Impedance

RLC Parallel Circuits and Impedance

 
Parallel RLC Circuit



The program RLCPAREL calculates:

* The total impedance of the circuit, and its magnitude in ohms
* Phase angle in a circuit in degrees.
* Current of the series in amps.

Input:
Battery/Source:  enter voltage and frequency
Add as many resistors (R) (in Ohms Ω), capacitors (C) (in farad), and inductors (L) (in henrys) as needed.

Notes:
HP Prime program only:  On the input screen, enter the real (a) and imaginary (if needed) (bi) parts separately.  Complex numbers can be directly entered on the TI-84+ program.

Example:
Parallel circuit powered by a 14 V, 5000 Hz battery.  The circuit has:
a resistor of 100 Ω, a capacitor of 3.2*10^-6 farads, and an inductor of 0.082 henrys.

Results:
Total Resistance:
0.987305540105 – 9.88715235955*i
Magnitude:
9.93632497508
Phase Angle:
84.2974952432
Current:
1.40897163037

HP Prime:  RLCPAREL

// Impedance of a Parallel
// EWS 2015-02-22
// Turn allow complex from real input on
// Declare subroutines
chsubr();
casubr();

// Main Routine
EXPORT RLCPAREL()
BEGIN
// initial steps
Z0:=0;
// radian mode
HAngle:=0;
// counter
I:=0;
// battery information
INPUT({V,F},"Battery Information",
{"V = ","F = "},
{"Volts","Frequency (Hz)"});
chsubr();
END;


// Choose Subroutine
chsubr()
BEGIN
LOCAL ch;
CHOOSE(ch,"# of Components: "+STRING(I),
{"Add Resistor (R)",
"Add Capacitor (C)",
"Add Inductor (L)",
"Calculate"});
// Execute calculation subroutine
casubr(ch);
END;

// Calculation Subroutine
casubr(x)
BEGIN
LOCAL a,b;
IF x==1 THEN
INPUT({a,b},"Add Resistor (Ω)",
{"a =","bi ="});
Z0:=Z0+1/(a+b*i);
I:=I+1;
chsubr();
END;

IF x==2 THEN
INPUT({a,b},"Capacitor (farad)",
{"a =","bi="});
Z0:=Z0-1/(i/(2*π*F*(a+b*i)));
I:=I+1;
chsubr();
END;

IF x==3 THEN
INPUT({a,b},"Inductor (henry)",
{"a =","bi="});
Z0:=Z0+1/(i*2*π*F*(a+b*i));
I:=I+1;
chsubr();
END;

// Termination
IF x==4 THEN
Z0:=1/Z0;
PRINT();
PRINT("Total Resistance = "+Z0);
PRINT("Magnitude (Ω) = "+ABS(Z0));
PRINT("Phase Angle (°) ="+
STRING(−ARG(Z0)*180/π));
PRINT("Current (amps) = "+
STRING(V/ABS(Z0)));
RETURN Z0;
END;
END;

TI-84+: RLCPAREL

a+bi   // Complex mode
Radian  // Radians mode
0→Z
Disp “BATTERY”
Disp “V = VOLT”
Disp “F = FREQ (HZ)”
Prompt V,F
Lbl 0
Menu(“CIRCUIT”,”+ RESISTOR”,1,”+ CAPACITOR”,2,
“+ INDUCTOR”,3,”CALCULATE”,4)
Lbl 1
Input “R (OHMS):”,R
Z+1/R→Z
Goto 0
Lbl 2
Input “C (FARAD):”,C
Z-(2πFC)/i→Z
Goto 0
Lbl 3
Input “L (HENRY):”,L
Z+1/(i2πFL)→Z
Goto 0
Lbl 4
1/Z→Z
Disp “IMPEDANCE=”
Pause Z
Disp “MAGNITUDE=”
Pause abs(Z)
Disp “PHASE ANGLE (°)=”
Pause -angle(Z)*180/π
Disp “CURRENT (AMPS)=”
Pause V/abs(Z)

Sources:
ElectronicsTutorials.  Parallel RLC Circuit Analysis  URL: 
Retrieved February 22, 2015


Van Valkenburg, Mac E. (Editor) and Wendy M. Middelton (Editor)
"Reference Data for Engineers: Radio, Electronics, Computer, and
Communications"  9th Edition.  Newnes, Butterworth-Heinemann:  Wolburn,
MA  2002.  Print.

This blog is property of Edward Shore.  2015.


HP Prime and TI-84+: RLC Series Circuit and Impedance

RLC Series

 
RCL Series Circuit

The program RLCSERIES (RLCSERIE for TI-84+) calculates:

·     *    The total impedance of the circuit, and its magnitude in ohms
·     *    Phase angle in a circuit in degrees.
·     *    Current of the series in amps.

Input:
Battery/Source:  enter voltage and frequency
Add as many resistors (R) (in Ohms Ω), capacitors (C) (in farad), and inductors (L) (in henrys) as needed. 

Notes:
HP Prime program only:  On the input screen, enter the real (a) and imaginary (if needed) (bi) parts separately.  Complex numbers can be directly entered on the TI-84+ program.

Example:
Series circuit powered by a 14 V, 5000 Hz battery.  The circuit has: a resistor of 100 Ω, a capacitor of 3.2*10^-6 farads, and an inductor of 0.082 henrys.

Results:
Total Resistance:
100 + 2566.158792*i
Magnitude:
2568.10649035
Phase Angle:
87.7683842611°
Current:
5.45148733225 * 10^-3

HP Prime: RLCSERIES

// Impedance of a Series
// EWS 2015-02-22
// Turn allow complex from real input on
// Declare subroutines
chsubr();
casubr();

// Main Routine
EXPORT RLCSERIES()
BEGIN
// initial steps
Z0:=0;
// radian mode
HAngle:=0;
// counter
I:=0;
// battery information
INPUT({V,F},"Battery Information",
{"V = ","F = "},
{"Volts","Frequency (Hz)"});
chsubr();
END;


// Choose Subroutine
chsubr()
BEGIN
LOCAL ch;
CHOOSE(ch,"# of Components: "+STRING(I),
{"Add Resistor (R)",
"Add Capacitor (C)",
"Add Inductor (L)",
"Calculate"});
// Execute calculation subroutine
casubr(ch);
END;

// Calculation Subroutine
casubr(x)
BEGIN
IF x==1 THEN
INPUT(R,"Add Resistor","R =",
// Impedance of a Series
// EWS 2015-02-22
// Turn allow complex from real input on
// Declare subroutines
chsubr();
casubr();

// Main Routine
EXPORT RLCSERIES()
BEGIN
// initial steps
Z0:=0;
// radian mode
HAngle:=0;
// counter
I:=0;
// battery information
INPUT({V,F},"Battery Information",
{"V = ","F = "},
{"Volts","Frequency (Hz)"});
chsubr();
END;


// Choose Subroutine
chsubr()
BEGIN
LOCAL ch;
CHOOSE(ch,"# of Components: "+STRING(I),
{"Add Resistor (R)",
"Add Capacitor (C)",
"Add Inductor (L)",
"Calculate"});
// Execute calculation subroutine
casubr(ch);
END;

// Calculation Subroutine
casubr(x)
BEGIN
LOCAL a,b;
IF x==1 THEN
INPUT({a,b},"Resistor (Ω)",
{"a =","bi="});
Z0:=Z0+(a+b*i);
I:=I+1;
chsubr();
END;

IF x==2 THEN
INPUT({a,b},"Capacitor (farad)",
{"a =","bi="});
Z0:=Z0-i/(2*π*F*(a+b*i));
I:=I+1;
chsubr();
END;

IF x==3 THEN
INPUT({a,b},"Inductor (henry)",
{"a =","bi="});
Z0:=Z0+i*2*π*F*(a+b*i);
I:=I+1;
chsubr();
END;

// Calculation
IF x==4 THEN
PRINT();
PRINT("Impedance = "+Z0);
PRINT("Magnitude (Ω) = "+ABS(Z0));
PRINT("Phase Angle (°) ="+
STRING(ARG(Z0)*180/π));
PRINT("Current (amps) = "+
STRING(V/ABS(Z0)));
RETURN Z0;
END;
END;

TI-84+: RLCSERIE

a+bi   // Complex mode
Radian  // Radians mode
0→Z
Disp “BATTERY”
Disp “V = VOLT”
Disp “F = FREQ (HZ)”
Prompt V,F
Lbl 0
Menu(“CIRCUIT”,”+ RESISTOR”,1,”+ CAPACITOR”,2,
“+ INDUCTOR”,3,”CALCULATE”,4)
Lbl 1
Input “R (OHMS):”,R
Z+R→Z
Goto 0
Lbl 2
Input “C (FARAD):”,C
Z-i/(2πFC)→Z
Goto 0
Lbl 3
Input “L (HENRY):”,L
Z+i2πFL→Z
Goto 0
Lbl 4
Disp “IMPEDANCE=”
Pause Z
Disp “MAGNITUDE=”
Pause abs(Z)
Disp “PHASE ANGLE (°)=”
Pause angle(Z)*180/π
Disp “CURRENT (AMPS)=”
Pause V/abs(Z)

Sources:
ElectronicsTutorials.  Series RLC Circuit Analysis  URL: 
Retrieved February 22, 2015

Van Valkenburg, Mac E. (Editor) and Wendy M. Middelton (Editor)
"Reference Data for Engineers: Radio, Electronics, Computer, and
Communications"  9th Edition.  Newnes, Butterworth-Heinemann:  Wolburn,
MA  2002.  Print.



This blog is property of Edward Shore.  2015.

Thursday, February 19, 2015

HP Prime & TI-84+: Equation of Time (One Way of Calculating It)

Introduction

We normally associate a day that lasts 24 hours long.  However, the true solar is day not constant and varies during the time of the year.  The true solar day is defined as two successive transits through a given point.  For example, think of it as the time it would take for the sun to make a round trip from the highest point in the sky only to return to the same point again. 

What causes the true solar day to not be constant?  The sun moves along the ecliptic and the speed about the ecliptic isn’t constant.  Earth’s orbit around the sun is not a perfect but it is an elliptical orbit.  The speed of the orbit is greatest when the Earth is nearest to the Sun (about January 3), and the slowest when the Earth is furthest away from the sun (about July 3). 

The equation of time describes the difference in time (seconds, minutes, or hours) between the true solar time and time as we normally know it (a day takes 24 hours).  If we used a sundial to measure time and compare it against a mechanical watch, the equation of time would demonstrate the approximate difference. 

For the program and the equation presented in this blog entry, if the result is positive, that means the watch is “slow” compared to the true solar time.  If the result is negative, that means that the watch is “fast” compared to the true solar time. 

I am curious to see if the clock apps on our smart phones follow the mechanical watches or true solar time. 

The equation presented in the program EQT was developed by GS Campbell and JM Norman (An Introduction to Environmental Biophyiscs).  This is one of many ways the equation of time is calculated.  A simple internet research and research through books and articles will show many forms of the equation of time. 

The angle measurement used in this equation is radians.

EQT (in hours) =3600^-1*(−104.7*SIN(F)+596.2*SIN(2*F)+4.3*SIN(3*F)-12.7*SIN(4*F)-
429.3*COS(F)-2*COS(2*F)+19.3*COS(3*F))

where F=π/180*(279.5+360/365*n);

A 365 day year assumed. 


Note:  Please keep in mind that every equation of time is an approximation.

Equation of Time (HP Prime)
HP Prime:  EQT

EXPORT EQT(n)
BEGIN
// n = day number (1 to 365)
// 2015-02-18
// hours, UC Berkeley approx
LOCAL F,E;
// radian mode
HAngle:=0;
F:=π/180*(279.5+360/365*n);
E:=3600^-1*(−104.7*SIN(F)+596.2*SIN(2*F)
+4.3*SIN(3*F)-12.7*SIN(4*F)-
429.3*COS(F)-2*COS(2*F)+19.3*COS(3*F));
RETURN E;
END;


TI-84+:  EQT

Disp “N=DAY NO.”
Prompt N
Radian
π/180*(279.5+360/365*N)→F
3600^-1*(−104.7*SIN(F)+596.2*SIN(2*F)
+4.3*SIN(3*F)-12.7*SIN(4*F)-
429.3*COS(F)-2*COS(2*F)+19.3*COS(3*F))→E
Disp “HOURS:”, E


Resources:

Baldocchi, Dennis.  “Lecture 7, Solar Radiation, Part 3, Earth-Sun Geometry”  September 10, 2012.  Retrieved February 17, 2015.  URL:  http://nature.berkeley.edu/biometlab/espm129/notes/Lecture%207%20Solar%20Radiation%20Part%203%20Earth%20Sun%20Geometry%20notes.pdf

Meeus, Jean.  “Mathematical Astronomy Morsels”  2nd Ed.  Willmann-Bell Inc.:  Richmond, VA  2000 pp. 337-346


This blog is property of Edward Shore – 2015.


Wednesday, February 18, 2015

HP Prime & TI-84+: Thermal Noise (Johnson-Nyquist Noise)

Introduction

The following program calculates the RMS (root-mean-square) voltage of a resistor at a certain temperature.  Thermal noise, also known as Johnson-Nyquist Noise is generated when the resistor has a temperature above absolute zero.  The equation to calculate the voltage is:

V = √(4*k*T*R*B) where

k = Boltzmann’s Constant = 1.3806488 * 10^-23 J/K
T = temperature in degrees Kelvin (K)
R = resistance in ohms (Ω)

B = noise bandwidth (Hz)

This program also calculates the noise power in decibels.  Yes, the power for most calculations for this application will be a negative quantity.   (I did a double take when I first learned about noise power.)   The equation for the noise power is:

P = −198.599167802+10*LOG(T*B)

where -198.599167802 = 10*LOG(k*1000) (see above)

HP Prime:  THNOISE

EXPORT THNOISE(R,T,B)
BEGIN
// 2015-2-18
// R = resistor (ohms)
// T = temp (°K)
// B = bandwidth (Hz)
LOCAL V,P;
// Boltzmann′s constant:
// can get retrieved by pressing Shift, Units, Const, 2, 2
V:=√(4*1.3806488ᴇ−23*T*R*B);
// volts
P:=−198.599167802+10*LOG(T*B);
// dBs
RETURN {V,P}; 
END;

TI-84+:  THNOISE

Disp "R=RESIS. (OHM)"
Disp "T=TEMP. (°K)"
Disp "B=BANDWIDTH (HZ)"
Prompt R,T,B
√(4*1.3806488ᴇ−23*T*R*B)→V
−198.599167802+10*LOG(T*B)→P
Disp "V=VOLTAGE"
Pause V
Disp "P = POWER"
Pause P


Example:

R = 1040 Ω
T = 300 K
B = 19000 Hz

Results:
V » 5.721708 * 10^-7 V
P » -131.040419 dB


Sources:  

John A. Ball.  "Algorithms for RPN Calculators"  John Wiley & Sons, Inc.  New York.  1978.  pg. 267

Johnson-Nyquist Noise.  http://en.wikipedia.org/wiki/Johnson%E2%80%93Nyquist_noise  Retrieved 2015-2-15



This blog is property of Edward Shore - 2015. 






Friday, February 13, 2015

Heart Curve: Happy Valentines Day!

As the world enters Valentine's Day (February 14, 2014), you can mathematically express your love by drawing the heart curve, which comes from the family of cardiod curves.  

What is graphed is one of the heart curves:

x = 16*(sin(t))^3
y = 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
-2*π ≤ t ≤ 2*π



A Heart Curve on HP Prime

You can get a selection of heart curves from this website:  http://mathworld.wolfram.com/HeartCurve.html 


Happy Valentines Day!

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