0
|
5087 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Loop statement inside an Exponential

Posted 10 years ago
 I'm trying to write a loop statement in Mathematica so that I get the output that looks a little something like this: { 1, Exp[-I*2*Pi/5], Exp[-I*2*Pi*2/ 5], Exp[-I*2*Pi*3/5], Exp[-I*2*Pi*4/5, ...}.Does anybody know what I must do to get it to give a simliar output above? The output doesn't have to be exact; it can be in aproximate form (real part + imaginary part). Thank you in advance. k = 1;A = 5;a0 = 0;a0 = a;n = 4;F0 = 0;Do[ F =  F - I*2*Pi*k*(a)/(A); Print[Exp[F]], {i, 0, n}]
3 Replies
Sort By:
Posted 10 years ago
 If you are only using this for calculations and don't care about the exact formatting then this might be simplerIn:= k = 1;A = 5; n = 4;Table[Exp[-I*2*Pi*k*i/A], {i, 0, n}]Out= {1, E^(-((2 I \[Pi])/5)), E^(-((4 I \[Pi])/5)), E^((4 I \[Pi])/5), E^((2 I \[Pi])/5)}
Posted 10 years ago
 In:= k = 1;A = 5;n = 4;Table[If[i==0, "1", StringReplace["Exp[-I*2*Pi*k*z]", "z"->ToString[InputForm[i/A]]]], {i, 0, n}]Out= {1, Exp[-I*2*Pi*k*1/5], Exp[-I*2*Pi*k*2/5], "Exp[-I*2*Pi*k*3/5], Exp[-I*2*Pi*k*4/5]}Will that do? It is producing strings to try to match your format exactly.If you then need to use this result for further calculations then ToExpression can convert it back.
Posted 10 years ago
 Thanks, Bill. Now I have to take the Output and apply to a Discrete Fourier Tranform.