Message Boards Message Boards

0
|
5500 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Loop statement inside an Exponential

Posted 11 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}]
POSTED BY: sean roubion
3 Replies
Posted 11 years ago
In[1]:= 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[4]= {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 BY: Bill Simpson
Posted 11 years ago
Thanks, Bill. Now I have to take the Output and apply to a Discrete Fourier Tranform.
POSTED BY: sean roubion
Posted 11 years ago
If you are only using this for calculations and don't care about the exact formatting then this might be simpler
In[4]:= k = 1;A = 5; n = 4;Table[Exp[-I*2*Pi*k*i/A], {i, 0, n}]

Out[6]= {1, E^(-((2 I \[Pi])/5)), E^(-((4 I \[Pi])/5)), E^((4 I \[Pi])/5), E^((2 I \[Pi])/5)}
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract