# Singularities using VectorPlot

I am trying to plot a vector function of a fluid flow given by

$\vec{V} = (\frac{-\cos(\theta)}{r^2},-\frac{\sin(\theta)}{r^2})$

I am trying to plot it in Mathematica using the command below, I converted to Cartesian coordinates by the way. But this does not run in Mathematica. Without the Exclusions option, I only get one arrow at the origin. Can you help me with this plot?

VectorPlot[
{-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2))},
{x, -1, 1}, {y, -1, 1},
Exclusions -> {(x^2 + y^2)^(3/2) == 0}
]


You can make use of option VectorScale - see the "More Information" section, and some singular examples at the end. Setting None will cause all the vectors to have the same length. Or you can improvise with a custom function to make the best view of the arrows (#5 the fifth argument is vector's norm):

VectorPlot[{-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2))}, {x, -1, 1}, {y, -1, 1},
VectorScale -> {Automatic, Automatic, #}] & /@ {None, Function[If[#5 > 50, None, #5^.3]]} You can also use StreamPlot

StreamPlot[{-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2))}, {x, -1, 1}, {y, -1, 1}] In your case potential is easily computed as integral over corresponding coordinates. Note automating clipping in the plot range. Here is the result with VectorPlot:

Show[ContourPlot[1/Sqrt[x^2 + y^2], {x, -1, 1}, {y, -1, 1},
ContourStyle -> Directive[Red, Dashed], ColorFunction -> "Rainbow", Contours -> 20],
VectorPlot[{-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2))}, {x, -1, 1}, {y, -1, 1},
VectorScale -> {Automatic, Automatic,
Function[If[#5 > 50, None, #5^.3]]}, VectorStyle -> Black]] and StreamPlot styled a bit differently

Show[ContourPlot[1/Sqrt[x^2 + y^2], {x, -1, 1}, {y, -1, 1},
ContourStyle -> Directive[Red, Dashed], ColorFunction -> "GrayTones"],
StreamPlot[{-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2))}, {x, -1, 1}, {y, -1, 1},
StreamStyle -> White]] • Thanks for this! This is for a fluid flow by the way. Is there an easy way to quickly draw the streamfunction and potential function (prependicular to each other) on the same graph? – l3win Oct 21 '12 at 17:14
• @l3win I updated the post – Vitaliy Kaurov Oct 22 '12 at 0:14

Exclusions is not an option of VectorPlot. As an alternative, you could use Boole to exclude part of the plot:

VectorPlot[
Boole[x^2 + y^2 > 0.08] {-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2))},
{x, -1, 1}, {y, -1, 1}
] Combining this with the potential:

Show[
DensityPlot[1/Sqrt[x^2 + y^2], {x, -1, 1}, {y, -1, 1},
ColorFunction -> "SolarColors"],
VectorPlot[
Boole[x^2 + y^2 >
0.1] {-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2))}, {x, -1,
1}, {y, -1, 1}]
] • Thank you all for the messages, you have been very helpful. I have one more question. The above was my vector field. Is there any way I can plot the potential function of my vector field? $\vec{V} = \nabla(f)$ How can I plot f? – l3win Oct 21 '12 at 18:34
• I still get a different scalar potential. This seems to me like a single sink, I get a dipole... Thanks for all the replies though – l3win Oct 22 '12 at 16:53
• @I3win have you calculated the gradient of 1/Sqrt[x^2+y^2]? I got the vector field in your code example. The vector plot is consistent with tat, not with te field of a dipole. – Sjoerd C. de Vries Oct 22 '12 at 19:09