0

Please, help me to understand... Im solving system of equations

 `f1[\[Lambda]1_, t_] := \[Lambda]1*Exp[-\[Lambda]1*t];
    f2[\[Lambda]2_, t_] := \[Lambda]2*Exp[-\[Lambda]2*t];
    f3[\[Lambda]3_, t_] := \[Lambda]3*Exp[-\[Lambda]3*t];
    f4[\[Lambda]4_, t_] := \[Lambda]4*Exp[-\[Lambda]4*t];
    f5[\[Lambda]5_, t_] := \[Lambda]5*Exp[-\[Lambda]5*t];
    f6[\[Lambda]6_, t_] := \[Lambda]6*Exp[-\[Lambda]6*t];
    f7[\[Lambda]7_, t_] := \[Lambda]7*Exp[-\[Lambda]7*t];
    f8[\[Lambda]8_, t_] := \[Lambda]8*Exp[-\[Lambda]8*t];
    f9[\[Lambda]9_, t_] := \[Lambda]9*Exp[-\[Lambda]9*t];
    f10[\[Lambda]10_, t_] := \[Lambda]10*Exp[-\[Lambda]10*t];`
   `p = ( {
    {0, 1, 0, 0, 0, 0, 0},
    {0, 0, 1, 0, 0, 0, 0},
    {0, 0.3, 0, 0.6, 0.1, 0, 0},
    {0, 0.4, 0, 0, 0.1, 0.5, 0},
    {0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 1},
    {0, 0, 0, 0, 0, 0, 0}
   } );`

   `fun[t_] := ( {
    {0, f1[1/6, t], 0, 0, 0, 0, 0},
    {0, 0, f2[1/2, t], 0, 0, 0, 0},
    {0, f6[1/1, t], 0, f4[1/1, t], f3[1/1, t], 0, 0},
    {0, f7[1/5, t], 0, 0, f5[1/2, t], f8[1/8, t], 0},
    {0, 0, 0, 0, 0, 0, f9[1, t]},
    {0, 0, 0, 0, 0, 0, f10[1, t]},
    {0, 0, 0, 0, 0, 0, 0}
   } );`
    `T := 0.01;
    q[t_] := p*fun[t];
    q[t] // MatrixForm

    r[n_] := Table[
    q[n*T][[k, j]] + 
    Sum[Sum[T*q[n*T - i*T][[m, j]]*Subscript[\[Phi], m][i*T], {i, 0, 
       n}], {m, 1, 7}], {j, 1, 7}, {k, 1}];
    r[1] // MatrixForm
    aa[n_] := 
    Table[Subscript[\[Phi], j][n*T] == r[n][[j, 1]], {j, 1, 7}];
    bb[n_] := Table[Subscript[\[Phi], j][n*T], {j, 1, 7}];`


    Sol[n_] := Solve[aa[n], bb[n]] /. Solve[aa[n - 1], bb[n - 1]];
    Sol[1] // MatrixForm 

I have values for Sol[0] and Sol[1], but for Sol[2], Sol[3], etc. Mathematica don't substitute previous values...

`

I solved this system in Laplace domain. I tried to obtain the values in range from 0 to 50.

Danone
  • 1
  • 1
  • Thank you! I tried this, but == is a syntax of Solve in Mathematica. That’s why I substitute it. – Danone Feb 07 '23 at 10:57
  • Thank you,Bill! I understand. It was my irrational step to take this system because of I already tried to evaluate with RSolve, ReccurenceTable and it was unsuccessful for my level of using Mathematica. Intuitively and “on the paper” I understand that it might be something like recursion. – Danone Feb 07 '23 at 21:10
  • Thanks! For Sol[0] it works,- for others ,- no. – Danone Feb 08 '23 at 08:09
  • OK. I would try to do this! – Danone Feb 08 '23 at 17:59
  • I have a system of eq-s: 'r[n_] := Table[ q[n*T][[k, j]] + Sum[Sum[T*q[i*T][[m, j]]*Subscript[\[Phi], m][n*T - i*T], {i, 0, n}], {m, 1, 7}], {j, 1, 7}, {k, 1}]'. Then, for 'r[0]' we have: '(0. 0.166667 +0.0166667 Subscript[\[Phi], 1][0.]+0.03 Subscript[\[Phi], 3][0.]+0.008 Subscript[\[Phi], 4][0.] 0. +0.05 Subscript[\[Phi], 2][0.] 0. +0.06 Subscript[\[Phi], 3][0.] 0. +0.01 Subscript[\[Phi], 3][0.]+0.005 Subscript[\[Phi], 4][0.] 0. +0.00625 Subscript[\[Phi], 4][0.] 0. +0.1 Subscript[\[Phi], 5][0.]+0.1 Subscript[\[Phi], 6][0.])' And I solve it with 'Solve' – Danone Feb 08 '23 at 20:07
  • '{{Subscript[\[Phi], 1][0.]->0., Subscript[\[Phi], 2][0.]->0.166921, Subscript[\[Phi], 3][0.]->0.00834605,Subscript[\[Phi], 4][0.]->0.000500763,Subscript[\[Phi], 5][0.]->0.0000859643,Subscript[\[Phi], 6][0.]->3.12977*10^-6,Subscript[\[Phi], 7][0.]->8.90941*10^-6}}' – Danone Feb 08 '23 at 20:08
  • But for 'r[1]' solving (as you already wrote output in the thirst comment ) Solve don't work. My question is: how can I remember values ϕ[0], ϕ[0.01], etc. and substitute them in to r[n+1] system all together. Im learning documentation about Fold and Nest. Thank you! – Danone Feb 08 '23 at 20:17
  • Thank you, Bill. I tried with Flatten and your advise is interesting and helpful! It works strange, but for Sol[2] Mathematica gave me list of ϕ[0], list of ϕ[0.1] and list of ϕ[0.2] with the same result. But this result is really for ϕ[0.2]. For Sol[3] it don't work. – Danone Feb 09 '23 at 06:31
  • I think I found and fixed some of the things that I broke. Try this `aa[n_]:=Flatten[Table[Subscript[\[Phi],j][o*T]==r[o][[j,1]],{o,0,n},{j,1,7}]]; bb[n_]:=Flatten[Table[Subscript[\[Phi],j][o*T],{o,0,n},{j,1,7}]]; Sol[n_]:=Solve[aa[n],bb[n]]; Sol[3]` and check that for `Sol[0]` and `Sol[1]` and ... You can also use `N[]` on the output to see a smaller decimal approximation of the result, but that may not work with further pattern matching. It is likely this can be done faster, but I'm much more concerned about getting right before making changes to get it faster. Let me know if it is right. – Bill Feb 09 '23 at 07:12
  • Bill, it looks like magic, but it working for Sol[0],Sol[1],Sol[2]...But for Sol[3] Solve don't substitute ϕ[0.1] and ϕ[0.2] – Danone Feb 09 '23 at 07:35
  • You say it doesn't work for ϕ[0.1] and ϕ[0.2]. Have you eliminated all decimal points in all your numbers? Different issue, I thought I had a fix to only show the smaller list of results instead of all the results for all numbers, but I have to think about that more in the morning. – Bill Feb 09 '23 at 08:01
  • Thank you very much! Sorry, I didn't know where are you from( Its seems to me, that with your help we did this system. I set T (step) in 1/10 instead of 0.1 and it begin working well for all Sol!!! Its fantastic... – Danone Feb 09 '23 at 08:05
  • And you was right about calculation time. Several times ago I solved this system with help of Laplace transform. (With help of Solve and in another way in matrices. And I see, that with Solve it was much faster (probably, because Solve written on C or Fortran?) – Danone Feb 09 '23 at 08:11
  • Now learning from this, instead of just getting the answer, is most important. For example, compare each of these `Table[i,{i,0,1,1/10}]` `FullForm[%]` `Table[i,{i,0.,1.,.1}]` `FullForm[%]` to learn how two decimal numbers that seem the same when you print them can actually be different internally and maybe not correctly pattern match. The "decimal" versus "exact" is a FAR bigger issue to REALLY understand inside Mma. Then there is giving `Solve` all the equations do it can solve for what you want. Then "optimizing for speed" problems. LOTS for you to learn from this problem. I hope it works. – Bill Feb 09 '23 at 15:51
  • Thank you very much. I a bit more understood, how deep “ rabbit hole” , but it’s wonderful! – Danone Feb 09 '23 at 16:37

0 Answers0