2
$begingroup$
This code for the first five iterations the speed is okay , but after that the speed is very slow, I cannot understand what is wrong with this? Would you please help me fix it? Clear[A, r, x, s, e] s := 0.3405 e := 1.6539*10^-21 u[0] := 0. u[1] := 0.1 A[r_] := A[r] = Piecewise[{{r - 2.5 s - 48*e *s^12*r^-13 + 24*e*s^6*r^-7, r > 2.5 s}, {-48*e*s^12*r^-13 + 24*e*s^6*r^-7, s [LessSlantEqual] r [LessSlantEqual] 2.5 s}, {r - s - 24*e*s^-1, r < s}}] For[i = 2, i < 101, i++, { u[i_] := x /. FindRoot[ u[i - 1] + 1/(i^2 (u[i - 1] - u[i - 2])^2) (u[i - 1] - u[i - 2]) - 0.9 A[x] == x , {x, 1.}]; Print[u[i]]}]
equation-solving iteration
...