# 40-th iteration by FindRoot

I tried to compute the 40-th iteration by FindRoot but without result. Please If any body solve that, I would to thank him. This question has a nonlinear system. And the solution for n=1 is solved. But there is problem when n=2,3, ...40.

The following code for computing the four unknowns for the nonlinear system. The four unknowns : u[0,n], u[1,n], u[2,n], u[3,n] ? Initial conditions:

 u[0, 0] := 0.4720012157682348; u[1, 0] := 0;
u[2, 0] := -0.4994032582704072; u[3, 0] := 0;

F1 = -u[0, n] + 99999.99999999999 (-u[0, -1 + n] + u[0, n]) +
0.7071067811865475 u[1, n] -
70710.67811865473 (-u[1, -1 + n] + u[1, n]) - 16. u[2, n] -
2.775557561562891*^-12 (-u[2, -1 + n] + u[2, n]) -
70710.67811865476 (u[3, -1 + n] - 1. u[3, n]) + (u[0, n] -
0.7071067811865475 u[1, n] - 2.7755575615628914*^-17 u[2, n] +
0.7071067811865477 u[3, n])^2 + 67.17514421272202 u[3, n]

F2 = 0. - u[0, n] + 99999.99999999999 (-u[0, -1 + n] + u[0, n]) -
0.7071067811865475 u[1, n] +
70710.67811865473 (-u[1, -1 + n] + u[1, n]) - 16 u[2, n] +
70710.67811865442 (u[3, -1 + n] - 1. u[3, n]) + (0. + u[0, n] +
0.7071067811865475 u[1, n] - 0.7071067811865444 u[3, n])^2 -
67.17514421272199 u[3, n]
F3 = u[0, n] - u[1, n] + u[2, n] - u[3, n]

F4 = u[0, n] + u[1, n] + u[2, n] + u[3, n]

n := 1

Sol =
FindRoot[{F1 == 0, F2 == 0, F3 == 0,
F4 == 0}, { {u[0, n], 0.4720012157682348}, {u[1, n],
0}, {u[2, n], -0.4994032582704072}, {u[3, n], 0}}] // Flatten

{u[0, 1] -> 0.4719281993760747, u[1, 1] -> 0.,
u[2, 1] -> -0.4719281993760747, u[3, 1] -> 0.}

• Can you explain a bit more? What do you mean by 40th iteration? What is wrong with the output of FindRoot? – anderstood Sep 8 '17 at 21:06
• Please edit the original question instead of re-posting it. If you fix the problems with it, it will be re-opened, and people might withdraw their downvotes. The problem is still not explained in words. Can you explain it in plain words, in such a way that it will be mostly understandable without having to read the code? – Szabolcs Sep 8 '17 at 21:14
• Thank you for advices. Actually I am new to this site. Yes I repeated this question, since I could not edit the last question because the icons not active. So I resent it and edited and added the question in the body of the post. This question has a nonlinear system. And the solution for n=1 is solved. But there is problem when n=2,3, ...40. – Khaled Sep 8 '17 at 22:01
• @Khaled your issue is in how you defined F1, F2, F3 and F4. Their explicit dependence of u[_,1] is the problem. You will want them to depend on u[_,n] instead. I suggest converting each into, e.g. F1[n_] where it constructs the expression with appropriate dependence on n. Then also make Sol a function, like Sol[n_], where you use F1[n]==0, F2[n]==0, etc. – b3m2a1 Sep 8 '17 at 23:48
• Thank you b3m2a1. I tried but without results. – Khaled Sep 9 '17 at 1:36

With the Fs defined as in the question, one way to iterate the calculation is

Sol = { u[0, 0] -> 0.4720012157682348, u[1, 0] -> 0,
u[2, 0] -> -0.4994032582704072, u[3, 0] -> 0};
Do[Sol = FindRoot[{F1, F2, F3, F4} /. Sol,
{{u[0, n], 0.4720012157682348}, {u[1, n], 0}, {u[2, n], -0.4994032582704072},
{u[3, n], 0}}] // Flatten // Chop; Print[Sol], {n, 40}]

(* {u[0,1]->0.471928,u[1,1]->0,u[2,1]->-0.471928,u[3,1]->0}
{u[0,2]->0.471855,u[1,2]->0,u[2,2]->-0.471855,u[3,2]->0}
...
{u[0,39]->0.469162,u[1,39]->0,u[2,39]->-0.469162,u[3,39]->0}
{u[0,40]->0.46909,u[1,40]->0,u[2,40]->-0.46909,u[3,40]->0} *)


Whether the results should be printed, as here, saved in an array, or post-processed in some way depends on how the results are to be used.

• Thank you very much bbgodfrey. – Khaled Sep 10 '17 at 20:49

I guess you want something like that:

fr1 = {u[0, 0] -> 0.4720012157682348, u[1, 0] -> 0,
u[2, 0] -> -0.4994032582704072, u[3, 0] -> 0}

F1[n_] = -u[0, n] + 99999.99999999999 (-u[0, -1 + n] + u[0, n]) +
0.7071067811865475 u[1, n] -
70710.67811865473 (-u[1, -1 + n] + u[1, n]) - 16. u[2, n] -
2.775557561562891*^-12 (-u[2, -1 + n] + u[2, n]) -
70710.67811865476 (u[3, -1 + n] - 1. u[3, n]) + (u[0, n] -
0.7071067811865475 u[1, n] - 2.7755575615628914*^-17 u[2, n] +
0.7071067811865477 u[3, n])^2 + 67.17514421272202 u[3, n]


Define the F2,F3,F4 the same way

Calculate a table of FindRoot solutions fr1[n], each time inserting fr1[n-1]

tab = Union[{fr1},
Table[fr1[n] =
FindRoot[{F1[n] == 0, F2[n] == 0, F3[n] == 0, F4[n] == 0} /.
fr1[n - 1], {{u[0, n], 1}, {u[1, n],
1}, {u[2, n], -1}, {u[3, n], 1}}], {n, 1, 40}]] // Flatten;


Plot the solution points

Table[ListPlot[Table[u[j, n] /. tab, {n, 0, 40}]], {j, 0, 3}] • Thank you very much Akku14. – Khaled Sep 10 '17 at 20:50