6
$\begingroup$

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}]

enter image description here

(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?

$\endgroup$
  • 1
    $\begingroup$ 1) what is the difference between the two code fragments? 2) Could you provide an English translation of your error? $\endgroup$ – MarcoB Aug 10 '15 at 13:22
  • $\begingroup$ @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. $\endgroup$ – rcollyer Aug 10 '15 at 13:28
  • $\begingroup$ What version of Mathematica are you using? $\endgroup$ – rcollyer Aug 10 '15 at 13:29
  • $\begingroup$ @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/…. $\endgroup$ – WateSoyan Aug 10 '15 at 13:30
  • $\begingroup$ @rcollyer I have told you in my tiltle. $\endgroup$ – WateSoyan Aug 10 '15 at 13:31
1
$\begingroup$

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
$\endgroup$
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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