1
$\begingroup$

I have a code like,

ReplaceAll[Table [ Subscript[u,n] == (0.2 Subscript[u, n + 1] + 0.8 Subscript[u, n - 1]) +Subscript[u, n]^3, {n, 1, 20} ], {Subscript[u, 0] -> 0, Subscript[u, 21] -> 0} ]

NSolve[%26, {Subscript[u, 1], Subscript[u, 2], Subscript[u, 3], Subscript[u, 4], Subscript[u, 5], Subscript[u, 6], Subscript[u, 7], Subscript[u, 8], Subscript[u, 9], Subscript[u, 10], Subscript[u,11], Subscript[u, 12], Subscript[u, 13], Subscript[u, 14], Subscript[u, 15], Subscript[u, 16], Subscript[u, 17], Subscript[u, 18], Subscript[u, 19], Subscript[u, 20]}]

and when I run it, SystemException["MemoryAllocationFailure".warnings I got. Is there any way to calculate these nonlinear equations?

Thanks for your help...

$\endgroup$
2
$\begingroup$

No chance to solve it with NSolve. I think you would need a future quantum computer.

Define a version for general number of parameters.

rp[nmax_] := 
  ReplaceAll[
   Table[Subscript[u, 
 n] == (2/10 Subscript[u, n + 1] + 8/10 Subscript[u, n - 1]) + 
 Subscript[u, n]^3, {n, 1, nmax}], {Subscript[u, 0] -> 0, 
 Subscript[u, nmax + 1] -> 0}]

pars[nmax_] := Table[Subscript[u, j], {j, 1, nmax}]

(nsol3 = NSolve[rp[3], pars[3]]) // Timing

(*   {0.047, {{Subscript[u, 1] -> -1.10821 - 0.0022525 I, 
Subscript[u, 2] -> 1.26395\[VeryThinSpace]+ 0.0302327 I, 
Subscript[u, 3] -> 
0.673588\[VeryThinSpace]- 0.564175 I}, {Subscript[u, 
1] -> -1.10821 + 0.0022525 I, 
Subscript[u, 2] -> 1.26395\[VeryThinSpace]- 0.0302327 I, 
Subscript[u, 3] -> 0.673588\[VeryThinSpace]+ 0.564175 I},
......
{Subscript[u, 1] -> 0., Subscript[u, 2] -> 0., 
Subscript[u, 3] -> 0.}}}   *)

(nsol4 = NSolve[rp[4], pars[4]]) // Timing

You get 27 solutions for nsol3 in 0.047 seconds. For 4 parameters you get 81 solutions in 0.266 seconds, for nsol5 243 solutions in 1.734 seconds. Number of solutions raises with a factor 3^nmax and calculation time raises by a factor of about 7^nmax.

For 20 parameters you would get 27*3^17 = 3486784401 solutions in 0.047*7^17 seconds, that are about 347441 years.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Since it is recurrent system the linear part (without u[n]^3) is easily solved by RSolve/RSolveValue. Unfortunately, RSolve cannot solve it with the nonlinear part. If one could think how to utilize the solution of linear part, then may be one have a chance? $\endgroup$ – user18792 Apr 14 at 6:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.