0
$\begingroup$

I would to find the roots of the following system. The unknowns are

    u[0, n], u[1,n], u[2,n] and u[3,n].

The initial values are :

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

I tried using the solution from step n - 1 as the initial guess in FindRoot for step n. However, I could not get anything. If anybody help, I will thank him.

fr1[0] = {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];

F2[n_] = 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[n_] = u[0, n] - u[1, n] + u[2, n] - u[3, n];

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

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

The output of Mathematica

FindRoot::srect: Value u[0.,0.] in search specification {u[0,n],u[0,n-1]} is not a number or array of numbers. >>

FindRoot::srect: Value u[0.,0.] in search specification {u[0,n],u[0,n-1]} is not a number or array of numbers. >>

FindRoot::srect: Value u[0.,1.] in search specification {u[0,n],u[0,n-1]} is not a number or array of numbers. >>

General::stop: Further output of FindRoot::srect will be suppressed during this calculation. >>

$\endgroup$
  • 2
    $\begingroup$ Since there are no numerical values assigned to u[1,n] at any time, FindRoot complains about getting symbolic input rather numerical. Replacing u[0, n - 1] (and similar) in your FindRoot with u[0, n - 1]/.fr1[n-1] should do the trick. $\endgroup$ – mmeent Sep 26 '17 at 14:09
  • $\begingroup$ Thank you very much Sir mmeent. I try your advice and I got the result. $\endgroup$ – Khaled Sep 28 '17 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.