# Revision history [back]

### Vector field returning blank screen

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


### Vector field plot_vector_field returning blank screen

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 non-zero values on their own, but nothing appears when I ask it to for the 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


### plot_vector_field returning blank screen

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 non-zero values on their own, but nothing appears when I ask for the plot.

This is actually a small part of a level set for a flow on all of R^3. In R^3, I take an infinite sequence of nested tori, and the differential equation at each point is described by an infinite series, with each term having a coefficient determined by the distance from that point to each torus in the space. c1 and c3 represent the inner and outer radii of the first torus. c4 represents the boundary of the second torus, which is 4 times as large as the first, and rotated from the xy-plane to the yz-plane, and completely contains the first torus. So that's why I'd discretized everything, since I'd already done that for the torus case, and was just trying to scale down. If I call the region between c1 and c3 T0, then h0(x,y) should return the minimum of 1 and 1-d((x,y),T0). If I call the union of the region bounded by c1 and the region between c3 and c4 T1, then h1(x,y) should return the minimum of 1, d((x,y),T0) and 1-d((x,y),T1).

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


### plot_vector_field returning blank screen

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 non-zero values on their own, but nothing appears when I ask for the plot.

This is actually a small part of a level set for a flow on all of R^3. In R^3, I take an infinite sequence of nested tori, and the differential equation at each point is described by an infinite series, with each term having a coefficient determined by the distance from that point to each torus in the space. c1 and c3 represent the inner and outer radii of the first torus. c4 represents the boundary of the second torus, which is 4 times as large as the first, and rotated from the xy-plane to the yz-plane, and completely contains the first torus. So that's why I'd discretized everything, since I'd already done that for the torus case, and was just trying to scale down. If I call the region between c1 and c3 T0, then h0(x,y) should return the minimum of 1 and 1-d((x,y),T0). If I call the union of the region bounded by inside of c1 and the region between c3 and c4 T1, then h1(x,y) should return the minimum of 1, d((x,y),T0) and 1-d((x,y),T1).

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