Register to reply 
Iteration in Mathematica 
Share this thread: 
#1
May1212, 03:47 PM

P: 94

What I want to do with Mathematica is this:
1. Given are 4×1 matrices e and u, and 4×4 matrix V. Matrices e and V are constant. 2. Solve the system u=V.f for f, where f is 4×1 matrix. 3. Define 4×1 vector g such as g1=f1*Exp(e1*t), g2=f2*Exp(e2*t) etc, where g1 is the first component of g, f1 is the first component of f, e1 is the first component of e etc and t=0.1 or 1 or whatever small number. 4. Compute p, where p=V.g 5. Print p and t*(the number of current step in the iteration) 6. Redefine u=p and do it all over again. Mathematica gives examples where only one expression is to be computed, while I want to compute more expressions in one step. I have no idea how to tell Mathematica to do this. Any idea will be appreciated. You can also give me (if you know one) a link or a title of a book where such kind of problems are explained. Please help :) 


#2
May1212, 04:16 PM

P: 94

Ok, I have found out how iterations could be made with function Do. But one problem I can't solve is this: how to tell Mathematica the new input to be equal to the last output? It seems that Mathematica doesn't change the input at all. Also, how to print the number of the step of the iteration?



#3
May1212, 04:23 PM

P: 94

Here is my code. At the end I have written u:=p, to tell Mathematica to start the next step with last result. But it won't :(
Do[u := ({ {152100000}, {0}, {0}, {29290} }); f = LinearSolve[V, u]; g := ({ {Part[f, 1]*Exp[Part[e, 1]*10]}, {Part[f, 2]*Exp[Part[e, 2]*10]}, {Part[f, 3]*Exp[Part[e, 3]*10]}, {Part[f, 4]*Exp[Part[e, 4]*10]} }); p := V.g; Print[p]; u := p, {10}] 


#4
May1212, 06:54 PM

P: 1,043

Iteration in Mathematica
Fix a number of mistakes
In[1]:= e={1.,2.,3.,4.}; V={{1,2,6,3},{6,1,5,4},{3,5,2,7},{8,4,5,1}}; u={152100000,0,0,29290}; Do[ f=LinearSolve[V,u]; g={Part[f,1]*Exp[Part[e,1]*10], Part[f,2]*Exp[Part[e,2]*10], Part[f,3]*Exp[Part[e,3]*10], Part[f,4]*Exp[Part[e,4]*10]}; p=V.g; Print[p]; u=p, {10} ] From In[1]:= {3.796667*^24, 5.063140*^24, 8.862560*^24, 1.264638*^24} From In[1]:= {8.941114*^41, 1.192148*^42, 2.086260*^42, 2.980371*^41} From In[1]:= {2.104606*^59, 2.806142*^59, 4.910749`*^59, 7.01535*^58} From In[1]:= {4.953934*^76, 6.605245*^76, 1.155917*^77, 1.651311*^76} From In[1]:= {1.166083*^94, 1.554777*^94, 2.720860*^94, 3.886943*^93} From In[1]:= {2.744787*^111, 3.65971*^111, 6.40450*^111, 9.14929*^110} From In[1]:= {6.460826*^128, 8.61443*^128, 1.50752*^129, 2.15360*^128} From In[1]:= {1.520783*^146, 2.02771*^146, 3.54849*^146, 5.06927*^145} From In[1]:= {3.579699*^163, 4.77293*^163, 8.35263*^163, 1.19323*^163} From In[1]:= {8.426086*^180, 1.12347*^181, 1.96608*^181, 2.80869*^180} You can also simplify your code using some features of Mathematica using g=f Map[Exp[#*10]&,e]; instead of g = {Part[f, 1]*Exp[Part[e, 1]*10], Part[f, 2]*Exp[Part[e, 2]*10], Part[f, 3]*Exp[Part[e, 3]*10], Part[f, 4]*Exp[Part[e, 4]*10]}; I wonder why this f = u.Inverse[V]; produces results that are not the same as this f = LinearSolve[V, u]; 


#5
May1312, 10:55 AM

P: 94

Thank you very, very much.
Although Mathematica has good help, it has no advice for any situation one may come in :( Thank you 


Register to reply 
Related Discussions  
Can someone determine what this iteration works out to, where x'  Calculus  8  
Total number of cancer cells inside a tumor: 100Each cell has a 10%  Engineering, Comp Sci, & Technology Homework  0  
Mathematica:Iteration of pairs in a list  Math & Science Software  3  
Grover iteration  Advanced Physics Homework  0  
Xn+1 = Xn(2  NXn) can be used to find the reciprocal  General Math  4 