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. 


TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...