3
$\begingroup$

In versions 11.3 through 12.1, the following causes StreamPlot to fail:

StreamPlot[{
2.1 - 4 u - (8 (u - v) (1 - E^(8 (v - u)^2) + E^(8 (v - u)^2) (2 v - 1)^2 - (2 u - 1)^2))/
(E^(4 (2 u - 1)^2 - 8 (2 u - 1) (2 v - 1) + 4 (2 v - 1)^2) - 1), 
2.1 - 4 v - (8 (v - u) (1 - E^(8 (u - v)^2) + E^(8 (u - v)^2) (2 u - 1)^2 - (2 v - 1)^2))/
(E^(4 (2 u - 1)^2 - 8 (2 u - 1) (2 v - 1) + 4 (2 v - 1)^2) - 1)}
, {u, 0, 1}, {v, 0, 1}]

After some Power::infy and Infinity::indet warnings, the final error is Throw::nocatch -- Uncaught Throw[Null, IntraStepEvaluationException]returned to top level.

In versions 11.2 and before, I get Mathematica graphics

Yes, the arguments definitely aren't well-defined when u == v (they're automatically generated within another function). However slightly changing any number of things (e.g. replacing 2.1 with 2.2, or changing the limits to {u, 10^-8, 1}, {v, 10^-8, 1}) results in valid output.

Maybe related to this problem?

Any thoughts on a general workaround for this idiosyncratic problem?

$\endgroup$
3
  • 2
    $\begingroup$ In early versions, Plot used symmetric sampling and included the end points and allow Power::infy messages to come through. Then at some point WRI made it more robust at handling sinularities, and continued to improve it. Maybe because of user complaints. Maybe a similar approach will work for StreamPlot. $\endgroup$
    – Michael E2
    Commented Oct 17, 2019 at 10:58
  • $\begingroup$ @MichaelE2 Maybe! To be clear, I don't mind the Power::infy warnings, it's the Throw::nocatch -- Uncaught Throw[Null, IntraStepEvaluationException] returned to top level. error with no output that bothers me. $\endgroup$
    – Chris K
    Commented Oct 17, 2019 at 11:14
  • 1
    $\begingroup$ The domain {u, 0.0001, 1}, {v, 0, 1} leads to the same problem with Throw, so it's not simply a symmetric domain or a problem at {0, 0}. Raising WorkingPrecision works in this case, too. As I meant to imply earlier, StreamPlot needs to be fixed to handle such exceptions. $\endgroup$
    – Michael E2
    Commented Oct 17, 2019 at 13:58

1 Answer 1

4
$\begingroup$

Here's another workaround: use arbitrary-precision numbers. (I suspect rounding errors lead to the exception.)

StreamPlot[{2.1 - 
   4 u - (8 (u - v) (1 - E^(8 (v - u)^2) + 
        E^(8 (v - u)^2) (2 v - 1)^2 - (2 u - 
           1)^2))/(E^(4 (2 u - 1)^2 - 8 (2 u - 1) (2 v - 1) + 
         4 (2 v - 1)^2) - 1), 
  2.1 - 4 v - (8 (v - u) (1 - E^(8 (u - v)^2) + 
        E^(8 (u - v)^2) (2 u - 1)^2 - (2 v - 
           1)^2))/(E^(4 (2 u - 1)^2 - 8 (2 u - 1) (2 v - 1) + 
         4 (2 v - 1)^2) - 1)},
 {u, 0, 1}, {v, 0, 1}, 
 WorkingPrecision -> 16]

enter image description here

$\endgroup$

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.