I'm working on the level set at z=0 of a complicated vector field, but I only get a blank screen each time I try to run it. Any thoughts? The functions I'm calling for the vector field seem to return positive values on their own, but nothing when I ask it to plot.
x,y,u = var('x y u')
def dist2(x,y):
return sqrt((x[0] - y[0])^2 + (x[1] - y[1])^2)
def setdist(x,S):
d = [dist2(x,S[i]) for i in range(len(S))]
return min(d)
C = parametric_plot((cos(u),sin(u)),(u,0,2*pi)) + parametric_plot((3*cos(u),3*sin(u)),(u,0,2*pi)) + parametric_plot((4*cos(u),4*sin(u)),(u,0,2*pi))
c1 = [(cos(i*2*pi/99*u), sin(i*2*pi/99*u)) for i in range(100)]
c3 = [(3*cos(i*2*pi/99*u), 3*sin(i*2*pi/99*u)) for i in range(100)]
c4 = [(4*cos(i*2*pi/99*u), 4*sin(i*2*pi/99*u)) for i in range(100)]
def h0(x,y):
if sqrt(x^2 + y^2)>=1 and sqrt(x^2 + y^2)<=3:
return 1
elif sqrt(x^2 + y^2) <1:
return 1-setdist((x,y),c1)
elif sqrt(x^2 + y^2) >=3 and sqrt(x^2 + y^2)<=4:
return 1-setdist((x,y),c3)
else:
return 0
def h1(x,y):
if sqrt(x^2 + y^2)>=1 and sqrt(x^2 + y^2)<=3:
return 0
elif sqrt(x^2 + y^2) <1:
return min(1,1-setdist((x,y),c1))
elif sqrt(x^2 + y^2) >=3 and sqrt(x^2 + y^2)<=4:
return min(1,1-setdist((x,y),c3))
else:
return 0
def dx(x,y):
return y*(h0(x,y))
def dy(x,y):
return (-1)*x*(h0(x,y)) + y*(h1(x,y))
VF = plot_vector_field((dx(x,y),dy(x,y)), (x, -4,4), (y, -4,4),plot_points=15)
VF + C