5
$\begingroup$

When I run this simple code, which repeats many times the exact same operation (a differential equation), the runtime (given by Timing) increases systematically, from roughly 1 second to 5.

I am using Math 9.0.1.0 on a MacBook Air. (Edit: the problem is not reproduced when running the same code with Mathematica 7 on a Linux machine.)

Can somebody else reproduce this? Does anybody know why and what can I do to avoid it?

Clear[delta];
delta := NDSolve[{y''[n] + y'[n] - y[n] == 0, y[-3] == 1, y'[-3] == 1}, y, {n, -3, 0}];
Do[{time = Timing[Do[delta, {a, 1000}]]; Print[time]}, {i, 10}]
$\endgroup$
3
  • 1
    $\begingroup$ I could not reproduce the problem in version 7 under Windows. $\endgroup$
    – Mr.Wizard
    Jul 9, 2014 at 0:15
  • $\begingroup$ I can reproduce this problem using Mathematica 9.0.1.0 on a 2012 MacBook Air with OS X 10.9.3 - my times are 1.8 to 7.2 seconds. $\endgroup$ Jul 9, 2014 at 9:08
  • $\begingroup$ It's a duplicate. Nevertheless, please do report the problem to support at wolfram.com. I can reproduce this in Mathematica 10 on OS X 10.9.4. $\endgroup$
    – Szabolcs
    Jul 10, 2014 at 14:48

1 Answer 1

4
$\begingroup$

Change to

delta := Module[{y}, 
  NDSolve[{y''[n] + y'[n] - y[n] == 0, y[-3] == 1, y'[-3] == 1}, y, {n, -3, 0}]]

This is a possible bug.

$\endgroup$

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