Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 61
Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2204
Kernel: SageMath 9.8
var('x y') plot_vector_field((x,y), (x,-5,5), (y,-5,5))
Image in a Jupyter notebook
# Stewart section 16.3, example 2, not a conservative field plot_vector_field((x-y, x-2), (x, -10, 10), (y,-10,10))
Image in a Jupyter notebook
# 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))
Image in a Jupyter notebook
plot_vector_field((cos(x), sin(y)), (x,-3,3), (y,-3,3))
Image in a Jupyter notebook
plot_vector_field((y, (cos(x)-2)*sin(x)), (x,-pi,pi), (y,-pi,pi))
Image in a Jupyter notebook
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()
(x, y) |--> (2*x*sin(2*y), 2*x^2*cos(2*y))
plot_vector_field(f.gradient(), (-3,3), (-3,3))
Image in a Jupyter notebook
f(x,y,z) = z * exp(-x*y) plot_vector_field3d(f.gradient(), (x,-1,1), (y,-1,1), (z,-1,1), viewer='threejs')
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In [10], line 2 1 __tmp__=var("x,y,z"); f = symbolic_expression(z * exp(-x*y)).function(x,y,z) ----> 2 plot_vector_field3d(f.gradient(), (x,-Integer(1),Integer(1)), (y,-Integer(1),Integer(1)), (z,-Integer(1),Integer(1)), viewer='threejs') File /ext/sage/9.8/src/sage/plot/plot3d/plot_field3d.py:148, in plot_vector_field3d(functions, xrange, yrange, zrange, plot_points, colors, center_arrows, **kwds) 146 return G 147 else: --> 148 G = sum([plot(v, color=cm(v.norm()), **kwds).translate(p) for v, p in zip(scaled_vectors, points)]) 149 G._set_extra_kwds(kwds) 150 return G File /ext/sage/9.8/src/sage/plot/plot3d/plot_field3d.py:148, in <listcomp>(.0) 146 return G 147 else: --> 148 G = sum([plot(v, color=cm(v.norm()), **kwds).translate(p) for v, p in zip(scaled_vectors, points)]) 149 G._set_extra_kwds(kwds) 150 return G File /ext/sage/9.8/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/matplotlib/colors.py:714, in Colormap.__call__(self, X, alpha, bytes) 712 xa = np.array(X, copy=True) 713 if mask_bad is None: --> 714 mask_bad = np.isnan(xa) 715 if not xa.dtype.isnative: 716 xa = xa.byteswap().newbyteorder() # Native byteorder is faster. TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
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)
Image in a Jupyter notebook