Bug introduced in 11.3 or earlier and persisting through 12.0.0 or later

EDIT: Reported to Wolfram Support, currently CASE:4238258.

For some reason, attempting to evaluate a simple StreamPlot will not only cause the StreamPlot evaluation to "fail" (although no error message is outputted), it will also completely wipe any variables that were generated by Mathematica that session, even if they were unrelated to the StreamPlot.

The following single line of code replicates the issue:

StreamPlot[{v, -Sin[x]*(1/2 - 10*Cos[8*0.525858])}, {x, Pi - 0.05, Pi + 0.05}, {v, -0.05, 0.05}, StreamPoints -> Fine]

Making the plotting range bigger prevents the issue for this case, but it will then occur again for different values in the cosine term. There doesn't appear to be any kind of singularity or obvious scaling issue in the expression, either—is there a simple workaround/fix or is this a bug?

To exemplify the strangeness of the issue, the following nearly identical expression will run just fine:

StreamPlot[{v, -Sin[x]*(1/2 - 10*Cos[8*0.496686])}, {x, Pi - 0.05, Pi + 0.05}, {v, -0.05, 0.05}, StreamPoints -> Fine]
  • 1
    $\begingroup$ Funny example. What is your version? $\endgroup$ Mar 23, 2019 at 22:48
  • 2
    $\begingroup$ The symptoms you describe are of a crash, not a "memory wipe." $\endgroup$
    – Michael E2
    Mar 23, 2019 at 22:53
  • $\begingroup$ @AlexTrounev I am running Mathematica 11.3, Student Edition. Also, an evaluation of MemoryAvailable[] at the beginning of a blank session will return about 3 GBs. $\endgroup$ Mar 23, 2019 at 22:55
  • 1
    $\begingroup$ Remove the StreamPoints -> Fine option and it seems to work fine. So it's probably running out of memory when it tries to calculate with more points. $\endgroup$
    – bill s
    Mar 23, 2019 at 22:56
  • 1
    $\begingroup$ I also noticed that in version 11.3 there are problems with memory. In this example, 12 GB was used. $\endgroup$ Mar 23, 2019 at 22:59

1 Answer 1


Here is the simplest example I've found that causes trouble (it uses a lot of memory):

(* runs forever, causes crash *)
StreamPlot[{v, 5 x}, {x, -0.05, 0.05}, {v, -0.05, 0.05}, StreamPoints -> Fine]

The number 5 is the smallest integer coefficient that causes the problem, though I didn't think it would be helpful to identify the minimal Real number.

A simple workaround is to use an interval that is not symmetric around the critical point:

StreamPlot[{v, 5 (x - Pi)},
 {x, Pi - 0.05 + 10^-6, Pi + 0.05}, {v, -0.05, 0.05}, StreamPoints -> Fine]

The same trick works on the OP's example. I suspect that StreamPlot ends up trying to solve an IC that gets close to the equilibrium. I suppose it takes a large number of steps, although I'm not sure why there isn't a MaxSteps limit. It probably should be considered a bug.

  • $\begingroup$ Thanks Michael—because your answer solves my example, I'll be sure to upvote and mark it correct very soon. I should note that I received a crash with your workaround on my original example for another parameter value in the cosine term, which means that the workaround is specific to some cases. $\endgroup$ Mar 23, 2019 at 23:31
  • $\begingroup$ @aghostinthefigures I can't respond without a specific example. -- I found one, too, and the same trick worked if I change the interval to {x, Pi - 0.05 + 10^-5, Pi + 0.05}. So you might want to take the idea and play with it. $\endgroup$
    – Michael E2
    Mar 23, 2019 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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