var('x y') plot_vector_field((x,y), (x,-5,5), (y,-5,5))
# Stewart section 16.3, example 2, not a conservative field plot_vector_field((x-y, x-2), (x, -10, 10), (y,-10,10))
# Stewart section 16.3, example 3, a conservative field plot_vector_field((3+2*x*y, x^2-3*y^2), (x,-2,2), (y,-2,2))
plot_vector_field((cos(x), sin(y)), (x,-3,3), (y,-3,3))
plot_vector_field((y, (cos(x)-2)*sin(x)), (x,-pi,pi), (y,-pi,pi))
var('x y z') plot_vector_field3d((x, y, z), (x,0,pi), (y,0,pi), (z,0,pi), viewer='threejs')
plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi), viewer='threejs')
f(x,y) = x^2 * sin(2*y) f.gradient()
plot_vector_field(f.gradient(), (-3,3), (-3,3))
f(x,y,z) = z * exp(-x*y) plot_vector_field3d(f.gradient(), (x,-1,1), (y,-1,1), (z,-1,1), viewer='threejs')
f(x,y) = x^2 + y^2 p1 = plot_vector_field(f.gradient(), (x,-2,2), (y,-2,2)) p2 = contour_plot(f, (x,-2,2), (y,-2,2), fill=False) show(p1 + p2)