Sunday, December 31, 2017

Happy New Year!

Happy New Year 2018!

#water #zen #love #prosperity #health #peace





See you in 2018!!!!

Eddie

Friday, December 22, 2017

Optics: Transmitted Angle, Critical Angle

Optics:  Transmitted Angle, Critical Angle



Formulas Used

Reflected Angle:  θr = θ

Transmitted Angel:  θt = asin((n1 * sin θ)/n2)

Critical Angle:  θc = asin(n1/n2),  n2 > n1

Perpendicular Frensel Parameters (t, r):

t = (2 * n1 * cos θ) / (n1 * cos θ + n2 * cos θt)

r = (n1 * cos θ – n2 * cos θt) / (n1 * cos θ + n2 * cos θt)

Parallel Fresnel Parameters (t, r):

t = (2 * n1 * cos θ) / (n1 * cos θt + n2 * cos θ)

r = (n1 * cos θt – n2 * cos θ) / (n1 * cos θt + n2 * cos θ)

Table of Indices of Reflection (n)

Air
1.00
Moissanite (SiC)
2.65
Carbon Dioxide (CO2)
1.0045
Pyrex
1.47
Cubic Zirconia
2.15
Salt (NaCl)
1.54
Diamond
2.42
Sapphire
1.76
Glass
1.52
Silicon
3.45
Ice
1.31
Water
1.33

HP Prime Program FLATOPTIC

EXPORT FLATOPTIC()
BEGIN
// 2017-12-17 EWS
// Solar Energy

// Change to degree
HAngle:=1;

// index of refraction

LOCAL L0:={1,1.0045,2.15,2.42,
1.52,1.31,2.65,1.47,
1.54,1.76,3.45,1.33};

LOCAL L1:={"Air","CO2",
"Cubic Zirconia","Diamond",
"Glass","Ice",
"Moissanite (SiC)","Pyrex",
"Salt (NaCl)","Sapphire",
"Silicon","Water"};

LOCAL L2:={"Perpendicular",
"Parallel",
"None"};

LOCAL n1,n2,k1,k2,θ,t,r;
LOCAL θc,θt,θr,x;

INPUT({{k1,L1},{k2,L1},θ,{x,L2}},
"Optic - Flat Interface",
{"Medium 1: ","Medium 2: ",
"Angle (°): ","Polarized?"}
);

// Calculation
PRINT();

θr:=θ;
PRINT("Reflect Angle: "+θr+"°");

n1:=L0(k1); n2:=L0(k2);
IF n2>n1 THEN
θc:=ASIN(n1/n2);
PRINT("Critical Angle: "+θc+"°");
END;

θt:=ASIN(n1*SIN(θ)/n2);
PRINT("Transmitted Angle: "+
θt+"°");

IF x==1 THEN
t:=(2*n1*COS(θ))/
(n1*COS(θ)+n2*COS(θt));
r:=(n1*COS(θ)-n2*COS(θt))/
(n1*COS(θ)+n2*COS(θt));
PRINT("t: "+t);
PRINT("r: "+r);
END;

IF x==2 THEN
t:=(2*n1*COS(θ))/
(n1*COS(θt)+n2*COS(θ));
r:=(n1*COS(θt)-n2*COS(θ))/
(n1*COS(θt)+n2*COS(θ));
PRINT("t: "+t);
PRINT("r: "+r);
END;

END;

TI-84 Plus CE Program

"EWS 2017-12-17"
{1,1.0045,2.15,2.42,1.52,1.31,2.65,1.47,1.54,1.76,3.45,1.33}→L6
Degree
For(K,1,2)
Disp "1. AIR 2. CO2 3. CUB.ZIC.","4. DIAMOND 5. GLASS 6. ICE","7. MOISANITE","8. PYREX 9. NACL","10. SAPPHIRE 11. SIL.","12. WATER"
Input M
If K=1:M→N
End
L6(N)→N:L6(M)→M
Input "INCIDENT: °",θ
sin^-1(N*sin(θ)/M)→A
Disp "TRANSMITED: °",A
If M>N:Then
sin^-1(N/M)→C
Disp "CRITICAL: °",C
End
Pause
Menu("POLARISE?","PERPENDICULAR",1,"PARALLEL",2,"NONE",3)
Lbl 1
(2Ncos(θ))/(Ncos(θ)+Mcos(A))→T
(Ncos(θ)-Mcos(T))/(Ncos(θ)+Mcos(T))→R
Disp "T",T,"R",R
Goto 3
Lbl 2
(2Ncos(θ))/(Ncos(T)+Mcos(θ))→T
(Ncos(T)-Mcos(θ))/(Ncos(T)+Mcos(θ))→R
Disp "T",T,"R",R
Lbl 3



Source:
Klaus Jäger, Olindo Isabella, Arno H.M. Smets, René A.C.M.M. van Swaaij, Miro Zeeman  Solar Energy: Fundamental, Technology, and Systems  Delft University of Technology, 2014
(no money is made from this blog entry)

Hopefully you find this useful.

Eddie


This blog is property of Edward Shore, 2017

HP Prime and TI-84 Plus CE: Digamma Function

HP Prime and TI-84 Plus CE: Digamma Function

Calculation

The HP Prime and TI-84 Plus CE program DIGAM ( ψ  ) calculates the digamma function for any positive integers and multiples of 1/2 (such as 3/2, 5/2, 7/2,etc) using the formulas:

ψ(1/2) = -γ – ln 4 = -1.963510026

ψ(1) = -γ = -0.5772156649

ψ(n) = Σ(1/x, x, 1, n-1) - γ for n is an integer

ψ(n) = Σ(2/(2*x+1), x, 0, n-3/2) - γ – ln 4 for n a multiple of 1/2 for the form p/2, p is odd

where γ = 0.577215664901533 (Euler-Mascheroni constant)

HP Prime Program DIGAM

EXPORT DIGAM(N)
BEGIN
// EWS 2017-12-17
LOCAL K,D,E:=0.577215664901533;
CASE
IF N==1 THEN
RETURN −E; END;
IF N==0.5 THEN
RETURN −E-LN(4); END;
IF FP(N)==0 AND N>1 THEN
RETURN Σ(1/K,K,1,N-1)-E; END;
IF FP(N)==0.5 AND N>1 THEN
RETURN Σ(2/(2*K+1),K,0,N-3/2)-E-LN(4); END;
DEFAULT RETURN "Error: Invalid N";
END;
END;

TI-84 Plus CE Program DIGAM

"DIGAMMA 2017-12-17 EWS"
0.577215664901533→E
0→K
Input "N?",N
If fPart(N)≠0 and fPart(N)≠0.5
Then
Disp "INVALID N"
Stop
End
If N=1
Then
­E→D
End
If fPart(N)=0 and N>1
Then
Σ(1/K,K,1,N-1)-E→D
End
If N=0.5
Then
­E-ln(4)→D
End
If fPart(N)=0.5 and N>1
Then
Σ(2/(2*K+1),K,0,N-1.5)-E-ln(4)→D
End
Disp D

Examples

DIGAM(2) = 0.422784335098
DIGAM(3) = 0.922784335098
DIGAM(4) = 1.25611766843

DIGAM(3/2) = 0.03648997398
DIGAM(5/2) = 0.70315664065
DIGAM(7/2) = 1.10315664065

Source:
Keith Oldham, Jan Myland, & Jerome Spainer.  An Atlas of Functions.  2nd Edition.  Springer: New York.  2009  ISBN 13: 978-0-387-48806-6

Eddie


This blog is property of Edward Shore, 2017

HP Prime and TI-84 Plus CE: Smith Chart Conversion (Post # 800)

HP Prime and TI-84 Plus CE: Smith Chart Conversion (Post # 800)
  
Happy Post 800!  Thank you readers and fans!  I wouldn’t be here without you!

Eddie

Introduction

The program SMITHCHART for the HP Prime and SMITH for the TI-84 Plus CE calculates one of two sets of conversions:

Return Loss (RL) to Standing Wave Ratio (SWR, in decibels):  RL to ρ (reflection coefficient) to σ (voltage standing ratio) to SWR

Standing Wave Ratio to Return Loss:  SWR to σ to ρ to RL

HP Prime Program SMITHCHART

EXPORT SMITHCHART()
BEGIN
// 2017-12-17 EWS
// Smith Chart Conversions
// HP 32S Engineering Applications
LOCAL k,x,RL,p,s,SWR;
INPUT({
{k,{"RL to SWR","SWR to RL"}},
x},"Smith Chart",
{"Starting at: ","Value: "});

IF k==1 THEN
// RL to SWR
RL:=x;
p:=ALOG(−RL/20);
s:=(1+p)/(1-p);
SWR:=20*LOG(s);
ELSE
// SWR to RL
SWR:=x;
s:=ALOG(SWR/20);
p:=(s-1)/(s+1);
RL:=20*LOG(1/p);
END;
// Results
PRINT();
PRINT("Results");
PRINT("Return Loss: "+RL);
PRINT(" ");
PRINT("Reflection Coefficient");
PRINT("ρ: "+p);
PRINT(" ");
PRINT("Voltage Standing Wave Ratio");
PRINT("σ: "+s);
PRINT(" ");
PRINT("SWR (dB): "+SWR);
END;

TI-84 Plus CE Program SMITH

"EWS 2017-12-17"
"HP 32S ENGINEERING"
Menu("SMITH CHART","RL TO SWR",1,"SWR TO RL",2)
Lbl 1
Input "RL: ",R
10^(­R/20)→P
(1+P)/(1-P)→I
20log(I)→S
Goto 3
Lbl 2
Input "SWR: ",S
10^(S/20)→I
(I-1)/(I+1)→P
20log(1/P)→R
Goto 3
Lbl 3
Disp "RETURN LOSS",R,"REFLECT COEFF.",P,"VOLT. STANDING WAVE",I,"SWR (DB)",S

Examples

SWR to RL:  Given 11.95 dB SWR

Results:
Return Loss:  4.48590571028
ρ: 0.59662948831
σ: 3.95822064836
SWR:  11.95

RL to SWR:  Given RL at 6.35 dB

Results:
Return Loss:  6.35
ρ: 0.481393254
σ: 2.85648666437
SWR:  9.11664401758

Source:
Hewlett-Pacakrd. Step by Step For Your HP Calculator:  Engineering Applications.  Ed. 1. Corvallis, OR January 1988

Eddie


This blog is property of Edward Shore, 2017

Wednesday, December 13, 2017

HP Prime: Area by Quadratic Splines


HP Prime:  Area by Quadratic Splines

Introduction

The program QUADSUM calculates the area under the curve described by the set of points (x_n, y_n).  The points are connected, in groups of three, by quadratic splines.  Thus, points (x1, y1), (x2, y2), and (x3, y3) are connected by a quadratic spline, (x3, y3), (x4, y4), (x5, y5) are connected by another quadratic spline, and so on.

Screen shot by HP Prime, labels I added using MS Paint (the old one)

  
The number of points for QUADSUM must be odd. 

HP Prime Program QUADSUM

EXPORT QUADSUM(LX,LY)
BEGIN
// EWS 2017-12-10
// Area by connecting
// points using quadratic
// curves
// number of points must be odd
LOCAL A,S,T; // A=0
S:=SIZE(LX);
IF FP(S/2)==0 THEN
RETURN "Invalid: Number of
points must be odd";
KILL;
END;
LOCAL T,M,MA,MB,MC;
FOR T FROM 1 TO S-2 STEP 2 DO
M:=CAS.LSQ([[1,LX(T),LX(T)^2],
[1,LX(T+1),LX(T+1)^2],
[1,LX(T+2),LX(T+2)^2]],
[[LY(T)],[LY(T+1)],[LY(T+2)]]);
MA:=M(3,1);
MB:=M(2,1);
MC:=M(1,1);
A:=A+
(MA*LX(T+2)^3/3+MB*LX(T+2)^2/2+
MC*LX(T+2))-
(MA*LX(T)^3/3+MB*LX(T)^2/2+
MC*LX(T));
END;
RETURN A;
END;

Example

Find the area under the curve with these points connected by quadratic splines:
(0,2), (1,1), (2,2), (3,6), (4,4)



Note that the point (2,2) ends the first spline and starts the second.

QUADSUM({0,1,2,3,4}, {2,1,2,6,4}) returns 12.6666666667

FYI:  The polynomial described would be the piecewise equation:
y = { x^2 -2x + 2 for 0 < x ≤ 2,  -3x^2 + 19x – 24 for 2 < x ≤ 4

Eddie


This blog is property of Edward Shore, 2017

Monday, December 11, 2017

HP Prime: Perigee and Apogee of a Conic Section

HP Prime:  Perigee and Apogee of a Conic Section

Introduction

The program CONICAP determines three characteristics of a conic section:

Eccentricity:
E = 0, circle
0 < E < 1, ellipse
E = 1, parabola (this case is not covered)
E > 1, hyperbola

Periapsis (Perigee):
The point on the conic section where it is closest to a primary focus (which is designated at one of the two foci F or F’).

Apoapsis (Apogee):
The point on the conic section where it is furthest away from a primary focus.  Note for a hyperbola and a parabola, the apogee is ∞. 

 The inputs are the lengths of the semi-major axis (A) and the semi-minor axis (P).  For a hyperbola, input A as negative. 



HP Prime Program CONICAP

EXPORT CONICAP(A,P)
BEGIN
// EWS 2017-12-10
// Fundamentals Of Astrodynamics
// ABS(A)≥P
LOCAL E;
E:=√(1-P/A);
PRINT();
PRINT("Perigee: "+STRING(A*(1-E)));
IF A≥0 THEN
PRINT("Apogee: "+STRING(A*(1+E)));
END;
PRINT("Eccentricity: "+E);
IF E==0 THEN
PRINT("Circle");
END;
IF E>0 AND E<1 THEN
PRINT("Ellipse");
END;
IF E>1 THEN
PRINT("Hyperbola");
END;
END;

Examples


A = 8, P = 3
A = 5, P = 5
A = -8, P = 3
Perigee
1.67544467966
5
1.38083151968
Apogee
14.3245553203
5
N/A
Eccentricity
0.790569415042
0
1.17260393996

Source:
Roger R. Bate, Donald D. Mueller, Jerry E. White.  Fundamentals of Astrodynamics Dover Publications: New York.  1971. ISBN-13: 978-0-486-60061-1

Eddie


This blog is property of Edward Shore, 2017.

Numworks (Python): Determining Earth’s Acceleration of Gravity

Numworks (Python): Determining Earth’s Acceleration of Gravity Introduction Note: We will only be using SI units on this blog en...