Bug introduced in 9.0 and persisting through 11.0.1
I have noted that in Mathematica 9 my code, which involves a lot of calls to NDSolve, slows down considerably after some time.
Apparently, the problem is NDSolve itself and it seems to be related to Mathematica 9, as the following example shows:
RunNDSolve := Timing[Do[NDSolve[{f''[x] == -f[x], f[0] == 1, f'[0] == 0},
{f[x]}, {x, 0, 1}], {1000}]][[1]]
RunNDSolve integrates a simple differential equation 1000 times using NDSolve and returns the time needed to carry out the integrations.
In Mathematica 9, RunNDSolve takes longer and longer times as it is called again, as the following example shows:
Table[{j, RunNDSolve}, {j, 50}]
In Mathematica 9 (extract of the full result):
j, RunNDSolve
1, 0.712
10, 2.649000
20, 4.869000
30, 7.326000
50, 13.372000
In Mathematica 8 (extract of the full result):
j, RunNDSolve
1, 0.5880000000000001`
10, 0.593`
20, 0.5719999999999992`
30, 0.5670000000000002`
40, 0.5770000000000017`
50, 0.5850000000000009`
Does anyone have an idea what the problem could be and how to fix it?
Comments
Post a Comment