Mathematica 10.2 break downs when StreamPlot-ing

Bug introduced in 9.0.0 and fixed in 12.0 or earlier

This code meets error:

 f[{v1_, v2_}, {x_, y_}] :=
StreamPlot[
Evaluate[{v1/(1 + x^2 + y^2)^(3/2), v2/(1 + x^2 + y^2)^(
3/2)} /. {x -> u/Sqrt[1 - u^2 - v^2],
y -> v/Sqrt[1 - u^2 - v^2]}], {u, -1, 1}, {v, -1, 1}]
f[{2 x y, 1 + y - x^2 + y^2}, {x, y}]


(I notice that this error sometimes but not alaways happens,but when you run it again and again for many times,i.e. 3 times the error comes.)

while this code doesn't:

f[{v1_, v2_}, {x_, y_}] :=
StreamPlot[
Evaluate[{v1/(1 + x^2 + y^2)^(3/2), v2/(1 + x^2 + y^2)^(
3/2)} /. {x -> u/Sqrt[1 - u^2 + v^2],
y -> v/Sqrt[1 - u^2 + v^2]}], {u, -1, 1}, {v, -1, 1}]
f[{2 x y, 1 + y - x^2 + y^2}, {x, y}]


So what on earth happens?

• 1) what is the difference between the two code fragments? 2) Could you provide an English translation of your error? Commented Aug 10, 2015 at 13:22
• @MarcoB the difference is in the normalization of x and y. In the first version, they are divided by Sqrt[1 - u^2 - v^2], in the second version Sqrt[1 - u^2 + v^2], and, yes, I had to look very closely as well. I presume he's seeing a kernel crash. Commented Aug 10, 2015 at 13:28
• What version of Mathematica are you using? Commented Aug 10, 2015 at 13:29
• @MarcoB 1) The difference is the sign in the rule 2)The error window tells us that kernel breaks down---just similar to that in my previous question e.g,mathematica.stackexchange.com/questions/88862/…. Commented Aug 10, 2015 at 13:30
• @rcollyer I have told you in my tiltle. Commented Aug 10, 2015 at 13:31

You can use Surd instead of Sqrt.

f[{v1_, v2_}, {x_, y_}] :=
StreamPlot[Evaluate[{v1/(1 + x^2 + y^2)^(3/2),
v2/(1 + x^2 + y^2)^(3/2)} /. {x -> u/Surd[1 - u^2 - v^2, 2],
y -> v/Surd[1 - u^2 - v^2, 2]}], {u, -1, 1}, {v, -1, 1}]
f[{2 x y, 1 + y - x^2 + y^2}, {x, y}] // Quiet


The below explanation is fairly plausible, but either way the answer is to build up the data in a table and ListStreamPlot it

I had a similar problem with StreamPlot[{1, Sqrt[1 - x^2] Cos[y + 1]}, {x, -1, 1}, {y, 0, 1}].

My conjecture is that since streamlines require numerically integrating the field, fields that are hard to integrate (require small step size) take too long and the plotter crashes. The above code runs fine on my machine when I only take x to 0.1. NDSolveing the associated ODE shows the default number of steps becomes insufficient somewhere in the middle.