If I draw a vector field, for example, in matplotlib, I usually write a formula for each component to avoid problems, for example, using forms and translation. However, in somewhat more complex formulas, the code becomes messy, writes and reads.
Consider the following example where I want to build a vector field defined by this formula: 
Is there any convenient way to enter the formula more mathematically using vector operations, as in my (not working) pseudo code below?
%matplotlib inline
from pylab import *
def B_dipole(m, a, x,y):
return (3*(x - a[0])*(m[0]*(x - a[0]) + m[1]*(y-a[1]))/((x - a[0])**2 + (y-a[1])**2)**(5/2.0) -m[0]/((x - a[0])**2 + (y-a[1])**2)**(3/2.0),3*(y - a[1])*(m[0]*(x - a[0]) + m[1]*(y-a[1]))/((x - a[0])**2 + (y-a[1])**2)**(5/2.0) -m[1]/((x - a[0])**2 + (y-a[1])**2)**(3/2.0))
x0, x1=-10,10
y0, y1=-10,10
X=linspace(x0,x1,55)
Y=linspace(y0,y1,55)
X,Y=meshgrid(X, Y)
m = [1,2]
a = [3,4]
Bx,By = B_dipole(m,a,X,Y)
fig = figure(figsize=(10,10))
ax = fig.add_subplot(1, 1, 1)
ax.streamplot(X, Y, Bx, By,color='black',linewidth=1,density=2)
show()
Output:

Edit:
Error message of my inoperative code:
ValueError Traceback (most recent call last)
<ipython-input-2-43b4694cc590> in <module>()
26 a = [3,4]
27
29
30 fig = figure(figsize=(10,10))
<ipython-input-2-43b4694cc590> in B_dipole(m, a, x, y)
10 def B_dipole(m, a, x,y):
11 r = array([x,y])
13 mrs = dot(m,rs)
14 RS = dot(rs,rs)**0.5
ValueError: operands could not be broadcast together with shapes (2,55,55) (2,)
Error message if I do not shift r:
ValueError Traceback (most recent call last)
<ipython-input-4-e0a352fa4178> in <module>()
23 a = [3,4]
24
26
27 fig = figure(figsize=(10,10))
<ipython-input-4-e0a352fa4178> in B_dipole(m, a, x, y)
8 r = array([x,y])
9 rs = r
11 RS = dot(rs,rs)**0.5
12 ret = 3*mrs*rs/RS**5 - m/RS**3
ValueError: shapes (2,) and (2,55,55) not aligned: 2 (dim 0) != 55 (dim 1)