# error using NDSolve

The code is not running. However instead of i^2 in the second term if I use i then it is working. But with i^2 fails.

    Xmax = 500; Tmax = 1; eqn =
Table[Subscript[u, i]'[
t] == (2*(Subscript[u, i + 1][t] - 2 Subscript[u, i][t] +
Subscript[u, i - 1][t]) + (i i -
Sum[i i Subscript[u, i][t], {i, -Xmax, Xmax}]) Subscript[u,
i][t])/Sum[Subscript[u, i][t], {i, -Xmax, Xmax}], {i,
1 - Xmax, Xmax - 1}]

bcs = {Subscript[u, -Xmax][t] == 0, Subscript[u, Xmax][t] == 0}; iv =
Table[If[(i >= -10) && (i <= 10), Subscript[u, i][0] == 1/21,
Subscript[u, i][0] == 0], {i, -Xmax, Xmax}]; s =
NDSolveValue[{eqn, iv, bcs},
Table[Subscript[u, i][t], {i, -Xmax + 1, Xmax - 1}], {t, 0,
Tmax}]; {Plot[s, {t, 0, Tmax}, AxesLabel -> {"t", u}],
ListLinePlot[Table[s, {t, 0, Tmax}], AxesLabel -> {x, u},
PlotRange -> All]}

• This works, for example, for Xmax = 15 – Alex Trounev Jul 26 '18 at 12:03
• What do you mean by "not running"? Does it return an error, or is it just not returning an answer promptly? If you're trying to solve a system of 999 coupled non-linear ODEs, you shouldn't expect an instantaneous result. – Michael Seifert Jul 26 '18 at 13:46
• No I understand but it is showing error namely "At t == 0.019485983068404454`, step size is effectively zero; singularity or stiff system suspected". – Sachin Kaushik Jul 26 '18 at 16:58
• and i cant set Xmax small because then it will give junk answer. – Sachin Kaushik Jul 26 '18 at 17:17