- #1
kaizen.moto
- 98
- 0
Dear all,
I am just wondering why I did not get the right outputs from the Do-Loop iteration. When I run the Do-loop, I got the wrong results as compared to the results I obtained for an individual iteration.
For instance:
Case 1 with Do-Loop run from m = 1,3,5 and n = 1,3,5:
In[1]:= Do[Clear[...];...;Print[def],{m,1,5,2},{n,1,5,2}]
Out[2]:= def(1,1) = 4.153374;def(1,3) = -0.512811; def(1,5) = 0.18633; def(3,1) = -0.528550;def(3,3) = 0.127743; def(3,5) = -0.055111; def(5,1) = 0.174747; def(5,3) = -0.055370; def(5,5) = 0.027538;
Case 2 with Do-Loop run individually from (1,1), (1,3), (1,5),(3,1), (3,3), (3,5), (5,1), (5,3) and (5,5):
In[1]:= Do[Clear[...];...;Print[def],{m,1,1,1},{n,1,1,1}]
Out[1]:= def(1,1) = 4.153374
In[2]:= Do[Clear[...];...;Print[def],{m,1,1,1},{n,3,3,1}]
Out[2]:= def(1,3) = -0.372935
In[3]:= Do[Clear[...];...;Print[def],{m,1,1,1},{n,5,5,1}]
Out[3]:= def(1,5) = 0.116199
In[4]:= Do[Clear[...];...;Print[def],{m,3,3,1},{n,1,1,1}]
Out[4]:= def(3,1) = -0.4518628
In[5]:= Do[Clear[...];...;Print[def],{m,3,3,1},{n,3,3,1}]
Out[5]:= def(3,3) = 0.09195776
In[6]:= Do[Clear[...];...;Print[def],{m,3,3,1},{n,5,5,1}]
Out[6]:= def(3,5) = -0.02938316251
In[7]:= Do[Clear[...];...;Print[def],{m,5,5,1},{n,1,1,1}]
Out[7]:= def(5,1) = 0.19833664459
In[8]:= Do[Clear[...];...;Print[def],{m,5,5,1},{n,3,3,1}]
Out[8]:= def(5,3) = -0.06710907582
In[9]:= Do[Clear[...];...;Print[def],{m,5,5,1},{n,5,5,1}]
Out[9]:= def(5,5) = 0.021204373
The correct results are shown in case2.
Could anyone please let me know why case 1 is not the same as case 2. Please let me know how to fix this case1 so that it would match to the results to case 2.
Thank you for any feedback.
I am just wondering why I did not get the right outputs from the Do-Loop iteration. When I run the Do-loop, I got the wrong results as compared to the results I obtained for an individual iteration.
For instance:
Case 1 with Do-Loop run from m = 1,3,5 and n = 1,3,5:
In[1]:= Do[Clear[...];...;Print[def],{m,1,5,2},{n,1,5,2}]
Out[2]:= def(1,1) = 4.153374;def(1,3) = -0.512811; def(1,5) = 0.18633; def(3,1) = -0.528550;def(3,3) = 0.127743; def(3,5) = -0.055111; def(5,1) = 0.174747; def(5,3) = -0.055370; def(5,5) = 0.027538;
Case 2 with Do-Loop run individually from (1,1), (1,3), (1,5),(3,1), (3,3), (3,5), (5,1), (5,3) and (5,5):
In[1]:= Do[Clear[...];...;Print[def],{m,1,1,1},{n,1,1,1}]
Out[1]:= def(1,1) = 4.153374
In[2]:= Do[Clear[...];...;Print[def],{m,1,1,1},{n,3,3,1}]
Out[2]:= def(1,3) = -0.372935
In[3]:= Do[Clear[...];...;Print[def],{m,1,1,1},{n,5,5,1}]
Out[3]:= def(1,5) = 0.116199
In[4]:= Do[Clear[...];...;Print[def],{m,3,3,1},{n,1,1,1}]
Out[4]:= def(3,1) = -0.4518628
In[5]:= Do[Clear[...];...;Print[def],{m,3,3,1},{n,3,3,1}]
Out[5]:= def(3,3) = 0.09195776
In[6]:= Do[Clear[...];...;Print[def],{m,3,3,1},{n,5,5,1}]
Out[6]:= def(3,5) = -0.02938316251
In[7]:= Do[Clear[...];...;Print[def],{m,5,5,1},{n,1,1,1}]
Out[7]:= def(5,1) = 0.19833664459
In[8]:= Do[Clear[...];...;Print[def],{m,5,5,1},{n,3,3,1}]
Out[8]:= def(5,3) = -0.06710907582
In[9]:= Do[Clear[...];...;Print[def],{m,5,5,1},{n,5,5,1}]
Out[9]:= def(5,5) = 0.021204373
The correct results are shown in case2.
Could anyone please let me know why case 1 is not the same as case 2. Please let me know how to fix this case1 so that it would match to the results to case 2.
Thank you for any feedback.