Mathematica graphics

Mathematica's Plot can handle plotting functions with singularities

From http://reference.wolfram.com/language/tutorial/BasicPlotting.html

You can plot functions that have singularities. The Wolfram Language will try to choose appropriate scales.

But StreamPlot and VectorPlot do not.

I am trying to plot functions using StreamPlot, but I do not know beforehand what these functions are, other than they depend on x and y. Some of them can have singularity at origin or somewhere else.

I selected a small region around the origin. Here is an example

f = (2*x*y)/(x^2 - y^2);

Mathematica graphics

Also Exclusions option is not supported by StreamPlot

What would be the correct way to StreamPlot such functions and avoiding 1/0 error?

  • $\begingroup$ You still get the (correct) plot though. Right ? $\endgroup$ – Lotus Jul 19 '18 at 10:00
  • $\begingroup$ @Lotus Yes, the plots comes out. Sorry I did not mention this. I just need a way to do it without the error message coming out, like with the Plot command. $\endgroup$ – Nasser Jul 19 '18 at 10:10
  • $\begingroup$ Nasser, does this work for you: dom = FunctionDomain[f, {x, y}]; StreamPlot[{1, If[dom, f]}, {x, -2,2},{y,-2,2}]? $\endgroup$ – kglr Jul 19 '18 at 11:35
  • $\begingroup$ Maybe try Quiet? $\endgroup$ – Mariusz Iwaniuk Jul 19 '18 at 11:39
  • $\begingroup$ @MariuszIwaniuk Yes, I know this is an option always, but I was hoping to see if there is a less brute force method. For me Quiet feels like hiding the main issue under the cover. Thanks. $\endgroup$ – Nasser Jul 19 '18 at 12:09
ClearAll[f, x, y];
StreamPlot[{1, If[dom, f]}, {x, -2, 2}, {y, -2, 2}]

enter image description here


Your Answer

