Sunday, February 22, 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




Wednesday, February 4, 2015

Simple Polar Curves

Simple Polar Curves

** Updated 2/11/2015 - Thank you Mike for pointing out my mistake on the rose curve - it is much appreciated!   Eddie


Here are some of the basic curves in polar coordinates.  These are graphed using the HP Prime Emulator, where 0 ≤ θ ≤ 4*π.

Rose:  r = cos(n*θ)
If n is odd, then the rose has n pedals.
If n is even, then the rose has 2*n pedals.

r = cos(5*θ)
r = cos(5*θ)


r = cos(6*θ)


r = cos(6*θ)

Leminscate:  r = +/- sqrt(a^2 * cos (2*θ))

r = +/- sqrt(9 * cos (2*θ))


R1 = sqrt(9 * cos (2*θ)),R2 = -R1


Cardiod:  r = 2*a*(1 + cos θ)

r = 8 * (1 + cos θ)


r = 8 * (1 + cos θ)


Limacon of a Pascal:  r = b + a*cos θ

r = 6 - 7*cos θ


r = 6 - 7*cos θ


And the most basic polar curve of them all:  
Spiral of Archidemeds:  r = a * θ

r = 3 * θ


r = 3 * θ



Source:
Murray R. Spiegel, Ph.D.,  Seymour Lipschutz, Ph.D., John Liu, Ph.D.   "Schuam's Outlines:  Mathematicals Handbook of Formulas and Tables."  3rd Edition.  2009.

This blog is property of Edward Shore.  2015

HP Prime: Pixel Art (Pixel Noise)

And now for a fun experiment:  take a certain function, any functions f(x,y) and g(x,y) where x and y represent the pixels of a calculator screen, and plot their results.  I let x range from 1 to 318 and y range from 1 to 218 and plot the resulting components f(x,y) and g(x,y), respectively, on the screen.  In order to keep all results on the screen, I format the functions like this:

k = f(x,y) MOD 318
j = g(x,y) MOD 218

where pixel coordinate (k,j) gets plotted.  I would like to share some results.  If you are interested, I list all the programs involved with each picture at the end of this blog.  Here is the general format:  

// General Format

EXPORT PIX09()
BEGIN
LOCAL x,y,j,k,n,l,s;
// set background color
RECT_P(#0h);
// add a counter if necessary
n:=0;
// list colors (if you want more than one colored pixel - optional)
l:={#FF0000h,#87CEEBh,#FFFF00h,#FF00h};
// main loop
FOR x FROM 1 TO 318 DO
FOR y FROM 1 TO 218 DO
// next two lines needed if l is defined
n:=n+1;
s:=1+n MOD 4;
// k and j represent functions of x and y - they really can be anything
// The MOD 318 and MOD 218 commands are needed to keep the pixels inbound
k:=IP((x^2*y)^3+(x*y^2)^3) MOD 318;
j:=IP(e^(x)+e^(y)) MOD 218;
// draw a pixel 
PIXON_P(k,j,l(s));
END;
END;
// this just tells the user "I'm done"
TEXTOUT_P("DONE",0,219,3,#FFFFFFh);
FREEZE;
END;

Enjoy and try this if you want.   

Eddie

PIX05:  This looks like mist. 


PIX05
PIX09:  This is what TV looked like at light night before Cable and Satellite TV.  Yes, I just aged myself.  
PIX09



PIX10:
PIX10

PIX11:
PIX11

PIX12: Could this be a view of a forest or jungle from a helicopter?  

PIX12

PIX14:  This looks like a fabric pattern.  
PIX14

This blog is property of Edward Shore - 2015.

PROGRAMS:

EXPORT PIX05()
BEGIN
LOCAL x,y,j,k;
RECT_P(#0h);
FOR x FROM 1 TO 318 DO
FOR y FROM 1 TO 218 DO
k:=IP(√x+√y+√(x*y)) MOD 318;
j:=(x^2+y^2+x*y) MOD 218;
PIXON_P(k,j,#87CEEBh);
END;
END;
TEXTOUT_P("DONE",0,219,3,#FFFFFFh);
FREEZE;
END;

EXPORT PIX09()
BEGIN
LOCAL x,y,j,k,n,l,s;
RECT_P(#0h);
n:=0;
l:={#FF0000h,#87CEEBh,#FFFF00h,#FF00h};
// main loop
FOR x FROM 1 TO 318 DO
FOR y FROM 1 TO 218 DO
n:=n+1;
s:=1+n MOD 4;
k:=IP((x^2*y)^3+(x*y^2)^3) MOD 318;
j:=IP(e^(x)+e^(y)) MOD 218;
// draw a pixel 
PIXON_P(k,j,l(s));
END;
END;
TEXTOUT_P("DONE",0,219,3,#FFFFFFh);
FREEZE;
END;

EXPORT PIX10()
BEGIN
LOCAL x,y,j,k,n,l,s;
RECT_P(#0h);
n:=0;
l:={#1560BDh,#87CEEBh,#FFFF00h,#9E60h};
FOR x FROM 1 TO 318 DO
FOR y FROM 1 TO 218 DO
n:=n+1;
s:=1+n MOD 4;
k:=IP(e^(x)+2*e^(y)) MOD 318;
j:=IP(2*e^(x)+e^(y)) MOD 218;
PIXON_P(k,j,l(s));
END;
END;
TEXTOUT_P("DONE",0,219,3,#FFFFFFh);
FREEZE;
END;


EXPORT PIX11()
BEGIN
LOCAL x,y,j,k,n,l,s;
RECT_P(#0h);
n:=0;
l:={#C0C0C0h,#FFFFFFh,#D4AF37h,#FFFF00h};
FOR x FROM 1 TO 318 DO
FOR y FROM 1 TO 218 DO
n:=n+1;
s:=1+n MOD 4;
k:=IP(x-y) MOD 318;
j:=IP(−2*e^(x)+.5*e^(y)) MOD 218;
PIXON_P(k,j,l(s));
END;
END;
TEXTOUT_P("DONE",0,219,3,#FFFFFFh);
FREEZE;
END;


EXPORT PIX12()
BEGIN
LOCAL x,y,j,k,n,l,s;
RECT_P(#4000h);
n:=0;
l:={#FFFF00h,#FF00h,#964B00h,#0h};
FOR x FROM 1 TO 318 DO
FOR y FROM 1 TO 218 DO
n:=n+1;
s:=1+n MOD 4;
k:=IP(x*y) MOD 318;
j:=IP(x^2+y^2) MOD 218;
PIXON_P(k,j,l(s));
END;
END;
TEXTOUT_P("DONE",0,219,3,#FFFFFFh);
FREEZE;
END;


EXPORT PIX14()
BEGIN
LOCAL x,y,j,k,n,l,s;
RECT_P(#400000h);
n:=0;
l:={#C0C0C0h,#FFFFCCh,#C0C0C0h,#FFFFCCh};
FOR x FROM 1 TO 318 DO
FOR y FROM 1 TO 218 DO
n:=n+1;
s:=1+n MOD 4;
k:=IP(21800*SIN(x)) MOD 318;
j:=IP(31800*√(y)) MOD 218;
PIXON_P(k,j,l(s));
END;
END;
TEXTOUT_P("DONE",0,219,3,#FFFFFFh);
FREEZE;
END;

Sunday, January 25, 2015

Goodies!

Shout out to Texas Instruments for sending me a TI-84 Plus C graphing calculator last month. Thank you! (Apologizes on being late about it.)

My first graphing calculator was a TI-81, which I still have and it's working. I think I currently have four of the TI-84 family (83+ Silver, 84+, and two 84 color editions).

My Amazon order came in last week: "Mathematical Astronomy Morsels" by Jean Meeus. It can shrink wrapped, which is nice. I found out that Meeus calculated how long the Age of Pisces was going to last (until 2597). Here, the definition of age is determined the placement of the vernal equinox.

Thanks Agena Astroproducts for quick delivery.


Just wanted to show you some of the goodies.

Eddie



This blog is property of Edward Shore. 2015

HP Prime: Calculator Art

Programs will follow.  Enjoy!   Eddie  

DRAW3DCUBE:  3D Cube - not as easy as it seems.  
DRAW3DCUBE
DRAW3DCYN:  My first one I did this weekend.  This looks like a tall glass of water.


DRAW3DCYN
DRAW3DSPH:  Sphere.  I like the effect the HP Prime does with ARC in a FOR loop.


DRAW3DSPH

DRAW3DWAVE:  I wanted something to be drawn using a sine wave.  


DRAW3DWAVE

DRAWSUNSET - This is probably my favorite, since I like sunsets.  



DRAWSUNSET



Tip:  The HP Prime screen is 318 pixels wide and 240 pixels deep.  If you want to leave room for custom menus, then the canvas is 318 pixels by 218 pixels.  The x axis increases to the right, but unlike the Cartesian plane, the y axis increases downward instead of upward.  

Eddie

-------------
Programs:

DRAW3DCUBE

EXPORT DRAW3DCUBE()
BEGIN
LOCAL t,a,b,c,d,s;
RECT();
// coord
a:=159-50*COS(45°);
b:=109-50*SIN(45°);
c:=159+50*COS(45°)+1;
d:=159-50*SIN(45°);

// drawing
LINE_P(a+50*COS(45°),b-SIN(45°),a,b);
LINE_P(a,b,159,109);
LINE_P(159,109,c,b);
LINE_P(c,b,a+50*COS(45°),b-SIN(45°));

LINE_P(a,b,a,d);
LINE_P(a,d,159,159);
LINE_P(159,159,159,109);

LINE_P(159,159,c,d);
LINE_P(c,d,c,b);

// left/right side shade
FOR t FROM b TO d DO
LINE_P(a,t,159,t+50*SIN(45°),#FF0000h);
LINE_P(c,t,159,t+50*SIN(45°),#FFh);
END;

// top shade
FOR t FROM 1 TO 50 DO
LINE_P(a+t*COS(45°),b-t*SIN(45°),
a+t*COS(45°),b+t*SIN(45°),#FFFF00h);
END;

FOR t FROM 50 DOWNTO 1 DO
LINE_P(c-t*COS(45°),b-t*SIN(45°),
c-t*COS(45°),b+t*SIN(45°),#FFFF00h);
END;

WAIT(0);   // I prefer WAIT(0) to FREEZE;

END;

DRAW3DCYN

EXPORT DRAW3DCYN()
BEGIN
LOCAL t;
HAngle:=0;
RECT();
// cylinder shell
FOR t FROM 0 TO 100 STEP 1 DO

ARC_P(159,70+t,20,0,π,#7DF9FFh);

ARC_P(159,70+t,20,π,2*π,#1560BDh);
END;
// sides
LINE_P(139,70,139,170,#1560BDh);
LINE_P(179,70,179,170,#1560BDh);
ARC_P(159,70,20,0,2*π,#1560BDh);
WAIT(0);

END;



DRAW3DSPH

EXPORT DRAW3DSPH()
BEGIN
// 2015-01-22
LOCAL t;
RECT();

// sphere loop
FOR t FROM 100 DOWNTO 1 DO
ARC_P(159,109,t,0,2*π,#808080h);
END;

// outside
FOR t FROM 59 TO 259 DO
PIXON_P(t,−.0025*t^2+.795*t+70.975);
END;

WAIT(0);

END;

DRAW3DWAVE

EXPORT DRAW3DWAVE()
BEGIN
LOCAL t,a,b;
RECT();
HAngle:=0;

FOR t FROM 0 TO 318 DO
a:=25*SIN(3.95168887244ᴇ−2*t-π)+100;
b:=a+25;
PIXON_P(t,a,#FFh);
PIXON_P(t,b,#FFh);

LINE_P(t,a+1,t,b-1,#87CEEBh);
LINE_P(t,b+1,t,218,#964B00h);

END;

LINE_P(0,100,0,125,#FFh);
LINE_P(318,100,318,125,#FFh);

LINE_P(0,125,0,218,#D4AF37h);
LINE_P(318,125,318,218,#D4AF37h);
LINE_P(0,218,318,218,#D4AF37h);

WAIT(0);

END;



DRAWSUNSET

EXPORT DRAWSUNSET()
BEGIN

RECT(#87CEEBh);
LOCAL t,a,b;
HAngle:=0;

// sun
FOR t FROM 50 DOWNTO 40 DO
ARC_P(159,109,t,0,2*π,#FFA500h);
END;
FOR t FROM 40 DOWNTO 0 DO
ARC_P(159,109,t,0,2*π,#FFFF00h);
END;

// horizon
LINE_P(0,108,318,108);


// ground and water
FOR t FROM 0 TO 159 DO
a:=1.855525955687ᴇ−4*t^3
-5.05717802449ᴇ−2*t^2
+3.67070350319*t+109;
LINE_P(t,a,t,109,#80h);
LINE_P(t,a+1,t,242,#964B00h);
END;

FOR t FROM 159 TO 318 DO
a:=1.23858063728ᴇ−4*t^3
-9.61799073419ᴇ−2*t^2
+23.6382711212*t
-1664.83052851;
LINE_P(t,a,t,109,#80h);
LINE_P(t,a+1,t,242,#964B00h);
END;

// lines
LINE_P(120,111,188,111,#C0C0C0h);
LINE_P(125,113,183,113,#C0C0C0h);
LINE_P(130,115,178,115,#C0C0C0h);
LINE_P(135,117,173,117,#C0C0C0h);

WAIT(0);
END;


This blog is property of Edward Shore.  2015



Friday, January 16, 2015

fx-5800p: Large Factorials, Length of Daylight, & Moments/Skewness

fx-5800p: Large Factorials, Length of Daylight, & Moments/Skewness

Large Factorials

This allows the user to calculate n! for any positive n, even n > 69.

Program BIGFACT
"N"?→N
Σ(log(K),K,1,N) → S
"N = "
10^(Frac(S)) ◢
"* 10^( )"
Int(S)


Examples:
36! ≈ 3.719933268 * 10^ 41
134! ≈ 1.992942746 * 10^ 228

Length of Daylight

D = days after March 21. A 365 day year is assumed.

Program DAYLIGHT
"DAYS AFTER"
"MARCH 21"? → D
Deg
23.45 * sin(D*.9856) → T
"LATITUDE"
"D ● M ● S ●"? → L // for ● press [ ° ' " ]
cos⁻¹ (-tan(L) * tan(T) ) → A
2 * A / 15 → H
"HOURS="
H


Example:
D = 302 (January 17)
L = 40° N (+40°)
Result: H = 9.525548719 hours

D = 302 (January 17)
L = 40° S (-40°)
Result H = 14.47445128

Moments/Skewness

Source: HP 33 Math Pak, 1979

Formulas:

1st Moment: A = Σx ÷ n
2nd Moment: B = Σ(x^2) ÷ n - A^2
3rd Moment: C = (Σ(x^3) - 3 * A * Σ(x^2)) ÷ n + 2 * A^3
Coefficient of Skewness: D = C / B^1.5

Program MOMENTS
0 → N // Initialization
0 → U
0 → V
0 → W
Lbl 0 // Main Loop
N + 1 → N
U + X → U
V + X^2 → V
W + X^(3) → W
"NO. OF PTS."
N ◢
"ANOTHER PT.?" // are you done?
"0=NO 1=YES"
? → Y
Y ≠ 0 ⇒ Goto 0
U ÷ N → A // analysis
V ÷ N - A^2 → B
(W - 3*A*V) ÷ N + 2 * A^(3) → C
C ÷ B^(1.5) → D
"1ST MOMENT"
A ◢
"2ND MOMENT"
B ◢
"3RD MOMENT"
C ◢
"SKEWNESS"
D


Example:

Data: 1.5, 2.8, 2.9, 3.6, 4.7

Results:
1st Moment = 3.1
2nd Moment = 1.1
3rd Moment = 0.018
4th Moment = 0.0156021151

See you all next time - have a great weekend! Go have some fun!

This blog is property of Edward Shore. 2015

HP 15C: The I Squared Rule and HHC 2026

HP 15C: The I Squared Rule and HHC 2026 HHC 2026 Videos Before we start, the videos for HHC 2026 are up! Please take a look, ev...