Solving Systems with Iteration in Mathematica

  • Mathematica
  • Thread starter nikolafmf
  • Start date
  • Tags
    Mathematica
In summary, I want to do 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.
  • #1
nikolafmf
114
0
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 :)
 
Physics news on Phys.org
  • #2
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
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
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];
 
Last edited:
  • #5
Thank you very, very much.

Although Mathematica has good help, it has no advice for any situation one may come in :(

Thank you
 

What is "Solving Systems with Iteration in Mathematica"?

"Solving Systems with Iteration in Mathematica" is a method used in the Mathematica software to solve systems of equations through repeated iterations. It is based on the concept of starting with an initial guess and refining it through a series of steps until a solution is reached.

What are the benefits of using "Solving Systems with Iteration" in Mathematica?

One of the main benefits of using this method is that it can handle more complex systems of equations compared to other methods. It also allows for greater control and customization of the iteration process, making it a useful tool for scientific research and analysis.

How does "Solving Systems with Iteration" work in Mathematica?

The method involves setting an initial guess for the variables in the system of equations, then using a series of steps to refine the guess until a solution is reached. This process is repeated until the solution is accurate enough, as determined by the user-defined tolerance level.

Can "Solving Systems with Iteration" be used for systems with multiple solutions?

Yes, this method can be used for systems with multiple solutions. However, the initial guess and iteration process may need to be adjusted to ensure that all solutions are found.

Are there any limitations to using "Solving Systems with Iteration" in Mathematica?

While this method is effective for many systems of equations, it may not be suitable for all types of equations. It also requires a good initial guess and careful selection of iteration steps to ensure accurate solutions. Additionally, it may be computationally intensive for very large systems of equations.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
544
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
568
  • Programming and Computer Science
Replies
8
Views
1K
  • Calculus and Beyond Homework Help
Replies
6
Views
3K
Back
Top