3

I've been trying to plot the radial vector field given by a point charge. The basic shape of the field is very easy to obtain, given by:

VectorPlot[{x, y}, {x, -5, 5}, {y, -5, 5}].

However this does not take into account the fact that the strength of the electric field drops of proportional to $\frac{1}{r^2}$ (where $r$ is the radial distance from the charge), giving vectors which increase in magnitude as you vary further from the charge.

I would like to scale the vectors so that their magnitude drops off as a function of $\frac{1}{r^2}$; I know it will involve VectorScale, however am new to how to use it exactly.

aidangallagher4
  • 289
  • 1
  • 6

1 Answers1

7

Getting the field right

There are two issues involved:

  • The magnitude of your vector needs to be (proportional to) $\frac{1}{r^2}$
  • You need to multiply the magnitude by the unit direction

The unit direction is {x,y}/(x^2+y^2)^(1/2).

Scaling by the magnitude of 1/(x^2+y^2), you obtain

electricField = {x,y}/(x^2+y^2)^(1/2)

Getting the plot right

(This issue is essentially a duplicate of this question. What follows is borrowed heavily from the answers there.)

Naively you'd write

Plot[electricField, {x, -5, 5}, {y, -5, 5}]

but since the field diverges at the origin, this is nearly useless.

Instead, you can do

VectorPlot[
   If[x^2 + y^2 > 0.2, electricField, 0], 
   {x, -5, 5}, {y, -5, 5},
   RegionFunction -> Function[{x, y}, x^2 + y^2 > 0.2]
]

Fixed vector plot

  • The RegionFunction tells VectorPlot to ignore points close to the origin
  • The If statement, while seemingly redundant, makes sure VectorPlot doesn't put an extraneous vector at the origin.
jjc385
  • 3,473
  • 1
  • 17
  • 29