Showing posts with label intensity. Show all posts
Showing posts with label intensity. Show all posts

Sunday, April 23, 2023

HP Prime: Edge Diffraction Parametric Plot

HP Prime:  Edge Diffraction Parametric Plot



Introduction


The program EDGEDIFFRAC plots the complex amplitude of edge diffraction.  The equation is:


φp = φ0 / √2 * ( CS(t) + 1/2 * (1 + i) )


where:

φp = complex amplitude 

φ0 = unobstructed amplitude, can be a complex number

CS(t) = Cornu Spiral, defined as CS(t) = C(t) + i * S(t)


Cosine Fresnel Integral

C(t) = ∫( cos (π * s^2 / 2) ds for s = 0 to t)


Sine Fresnel Integral

S(t) = ∫( sin (π * s^2 / 2) ds for s = 0 to t)


i = √-1




HP Prime Program:   EDGEDIFFRAC


Notes:


1.  This program runs in the Parametric app.


2.  To allow for the program to be run from any app, the STARTAPP command is placed in the beginning of the program.


3.  To allow editing in any app, the Parametric. prefix is added to the variables Tmin, Tmax, and Tstep.   


4.  The QUOTE command is used to store functions to the graphing variables X1 and Y1.  


5.  The program runs faster in the emulator than the hardware calculator.  


6.  x1(t) is the real part of φp, and y1(t) is the imaginary part of φp. 


Code:


EXPORT EDGEDIFFRAC()

BEGIN

// Edge Diffraction 

// 2023-02-19 EWS

STARTAPP("Parametric");


// set radians mode

HAngle:=0;

// local variables

LOCAL ch,l,lc,pc;

LOCAL y,λ,z,w,φp;

 

// plot application

INPUT(Z0,"Unobstructed Amplitude",

"φ0:");


CHOOSE(l,"Change Color","Red","Indigo",

"Blue","Orange","Green");

lc:={#FF0000h,#400080h,#FFh,

#FFA500h,#C000h};

X1(COLOR):=lc[l];

Parametric.Tmin:=-5;

Parametric.Tmax:=5;

Parametric.Tstep:=0.25;


A:=RE(Z0);

B:=IM(Z0);

X1:=QUOTE(A/√2*(∫(COS(π*S^2/2),S,0,T)+1/2)

-B/√2*(∫(SIN(π*S^2/2),S,0,T)+1/2));

Y1:=QUOTE(A/√2*(∫(SIN(π*S^2/2),S,0,T)+1/2)

+B/√2*(∫(COS(π*S^2/2),S,0,T)+1/2));

CHECK(1);

STARTVIEW(10);


END;



Examples



Example 1:   φ0 =  2 + 6i






Example 2:  φ0 = 2.29






Source


Woan, Graham.  The Cambridge Handbook of Physics Formulas.  Cambridge University Press:  Cambridge, New York.   2003



All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Monday, May 20, 2019

Intensity/Illumination, Days Since Jan. 1, Derivatives: HP 20S and 21S

Intensity/Illumination, Days Since Jan. 1, Derivatives: HP 20S and 21S

Table of contents

1.  Intensity and Illumination
2.  Days Since January 1
3.  Numerical Derivative

Disclaimer: I believe the key codes for the programs in this blog entry are the all the same even though the HP 20S and HP 21S have slightly different codes.  Format:   Step  Key: Key Code.  I took turns programming the HP 20S and HP 21S.

1.  Intensity and Illumination

The follow equation relates the luminous intensity (measured in candelas, cd) and illuminance (measured in lux) of a light source.  The equation assumes the light source radiates a spherical matter.

E = I / R^2

E = illuminance
I = luminous intensity
R = radius of the sphere's light (meters)

LBL A:  Solve for E
LBL B:  Solve for I
LBL C:  Solve for R

Registers:
R0 = E
R1 = I
R2 = R

Store the following values in the register and execute the appropriate label.

Program:

01  LBL A:  61,41,A
02 RCL 1:  22, 1
03 ÷:  45
04 RCL 2:  22, 2
05 x^2:  51, 11
06 =: 74
07 STO 0:  21, 0
08 R/S:  26
09 LBL B:  61,41,B
10  RCL 0: 22,0
11  *:  55
12  RCL 2: 22,2
13  x^2:  51,11
14  =:  74
15  STO 1: 21, 1
16  R/S:  26
17  LBL C: 61,41,C
18  RCL 1: 22,1
19 ÷: 45
20 RCL 0: 22,0
21  =:  74
22 √:  11
23 STO 2: 21, 2
24 R/S:  26

Example 1:
R1 = I = 400, R2 = R = 2.
Solve for E,  XEQ A returns 100

Example 2:
R0 = E = 180, R2 = R = 3
Solve for I, XEQ B returns 1620

Example 3:
R1 = I =420, R0 = E = 195
Solve for R, XEQ C returns 1.467598771

2.  Days Since January 1

Calculate the number of days since January 1.  For more information, please see:  http://edspi31415.blogspot.com/2019/03/ti-84-plus-and-hp-41c-number-of-days.html

Input:
R1:  day
R2: month
R3: 0 if we are working in a non-leap year, 1 if we are working in a leap year

Output:
R4:  number of days since January 1

Program:

01 LBL A: 61,41,A
02 RCL 1:  22,1
03 STO 4: 21, 4
04 3:  3
05 5:  5
06 STO - 4:  21,65,4
07 RCL 2: 22,2
08  INPUT:  31
09  2:  2
10  x ≤ y?:  61,42
11  GTO 2:  51,41,2
12  RCL 2: 22,2
13  *:  55
14  3:  3
15  0:  0
16  . : 73
17 6:  6
18  +:  75
19  1:  1
20  .  : 73
21  6:  6
22  =:  74
23  IP:  51, 45
24  STO + 4:  21,75,4
25  RCL 3:  22,3
26  STO + 4:  21,75,4
27  RCL 4: 22,4
28  RTN:  61, 26
29  LBL 2:  61,41,2
30  RCL 2:  22,2
31   *:  55
32  3:  3
33  0:  0
34  .  : 73
35  6:  6
36  +:  75
37  3:  3
38  6:  6
39  8:  8
40:  .  : 73
41  8:  8
42 =: 74
43  IP:  51,45
44  STO + 4:  21,75,4
45  3:  3
46  6:  6
47  5:  5
48  STO - 4:  21,65,4
49  RCL 4:  22,4
50  RTN:  61,26

Example 1:
1/1/2019 - 5/7/2019  (non-leap year)
R1:  7,  R2:  5,  R3:  0
Result:  R4 = 126

Example 2:
1/1/2020 - 11/14/2020  (leap year)
R1:  14,  R2:  11, R3:  1
Result:  R4 = 318

3.  Numerical Derivative

f'(x0) ≈ ( f(x0 + h) - f(x0 - h) ) / ( 2*h )

x = point
h = small change of x, example h = 0.0001

LBL A:  Main Progam
LBL F:  f(X), where R0 acts as X

Input variables:
R1 = h
R2 = point x0

Used variables:
R0 = x   (use R0 for f(x), LBL F)

Calculated Variables:
R3 = f'(x)

Radians mode will be set.

Program:

01  LBL A:  61,41A
02  RAD:  61,24
03  RCL 2:  22,2
04  +:  75
05  RCL 1:  22, 1
06  =:  74
07  STO 0:  21,0
08 XEQ F:  41,F
09  STO 3:  21, 3
10  RCL 2: 22,2
11 -:  65
12 RCL 1: 22,1
13 =:  74
14 STO 0: 21,0
15 XEQ F:  41,F
16 STO - 3:  21,65,3
17 2:  2
18 STO ÷ 3:  21,45,3
19  RCL 1:  22,1
20 STO ÷ 3: 21,45,3
21  RCL 3:  22,3
22 R/S:  26
23 LBL F:  61,41,F
...
xx  RTN:  61,26  (end f(X) with RTN)

Example:  e^x * sin x

LBL F
RCL 0
e^x
*
RCL 0
SIN 

RTN

R1 = 0.0001
R2 = x0 = 0.03
Result:  1.060899867

R1 = 0.0001
R2 = x0 = 1.47
Result:  4.7648049


Note:  I am going on vacation this week and I have jury duty in June. So far, I have blog entries scheduled to be posted throughout June 22.  I plan to have a weekly post every Saturday in June.  - E

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Monday, May 13, 2019

HP 42S/DM42/Free42: Room Cavity Ratio, Luminous Intensity and Illuminance

HP 42S/DM42/Free42:  Room Cavity Ratio, Luminous Intensity and Illuminance

Room Cavity Ratio



The room cavity ratio is used to assist in calculating lighting efficiency in determining where to place ceiling lights in an office room.  The formula is:

RCR = INT( ( 5 * H * ( L + W ) ) / ( L * W ) )

where:
L = length of the room
H = height difference between floor cavity and ceiling cavity
W = width of the room

HP 42S/DM42/Free42:  Solver RCR

LBL "RCR"
MVAR "H"
MVAR "L"
MVAR "W"
MVAR "RCR"
5
RCL * "H"
RCL "L"
RCL + "W"
*
RCL "L"
RCL * "W"
÷
IP
RCL - "RCR"
END

Examples

Example 1: 
Input:  H = 5.5, L = 16.8, W = 13.7.   Result:  RCR = 3

Example 2:
Input: H = 5.5, L = 16.8, RCR = 4.  Result:  H = 7.1650

Sources:

Dilouie, Craig.  "Lighting Design:  Example of Role Surfaces Play in Lighting Efficiency"  LightNOW  https://www.lightnowblog.com/2010/06/example-of-role-surfaces-play-in-lighting-efficiency/  June 16, 2010.  Retrieved March 31, 2019

"Room Cavity Ratio, RCR" Illuminating Engineering Society.  https://www.ies.org/definitions/room-cavity-ratio-rcr/  July 5, 2018.  Retrieved April 28, 2019

Luminous Intensity and Illuminance

The follow equation relates the luminous intensity (measured in candelas, cd) and illuminance (measured in lux) of a light source.  The equation assumes the light source radiates a spherical matter. 

E = I / R^2

E = illuminance
I = luminous intensity
R = radius of the sphere's light (meters)

HP 42S/DM42/Free42:  Solver ILSPH

LBL "ILSPH"
MVAR "E"
MVAR "I"
MVAR "R"
RCL "E"
RCL "I"
RCL "R"
x ↑ 2
÷
-
END

Examples

Example 1:
Input:  I = 10 cd, R = 2 m.  Result:  2.5 lux

Example 2:
Input:  R = 3.65 m, E = 30 lux.  Result:  I = 399.6750 cd

Sources:

Daryanani, Sital  Building Systems Design With Programmable Calculators Architectural Record Books.  McGraw-Hill Book Company: New York.  1980.  ISBN 0-07-015415-5

Zumtobel "The Lighting Handbook" Zumtobel Lighting GmbH.  Dornbirn, Austria.  6th Edition: 2018  https://www.zumtobel.com/PDB/Ressource/teaser/en/Lichthandbuch.pdf

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

RPN HP 12C: Fibonacci and Lucas Sequences

  RPN HP 12C: Fibonacci and Lucas Sequences Golden Ratio, Formulas, and Sequences Let φ be the Golden Ratio: φ = (1 + √5) ÷ 2...