What does ejωt / e-jωt mean in terms of coding?
I know it is ejωt = cos(ωt)+jsin(ωt). But if you have it in terms of an algorithm how do you program it?
There's a special function to raise e to a power, called exp
. So you want:
exp(j*w*t)
Or:
exp(-j*w*t)
To use this function you'll need to #include <math.h>
, and when compiling on Linux systems add the -lm
flag to link the math library.
EDIT:
If j
is the imaginary unit, you can use the cexp
function to raise e to a complex power:
cexp(I*w*t)
You can store the result in a variable of type double complex
and use the creal
and cimag
functions to extract the real and imaginary parts. Also, you 'll need to #include <complex.h>
As you say, e^(jωt) = cos(ωt)+jsin(ωt)
While e^(-jωt) = cos(ωt)-jsin(ωt) <- sign-change for second term
Therefore, e^(jωt) / e^(-jωt)
is simply
( cos(ωt)+jsin(ωt) ) / ( cos(ωt)-jsin(ωt) )
You may find the following paper useful. http://web.mit.edu/6.02/www/s2007/lec3.pdf