CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 3036
## Below are the Sage commands for plotting 2D and 3D vector fields.
## As always, start by declaring that x, y, and z are variables. (Hit ctrl+enter to execute a line of code.)
x, y, z = var('x y z')
## F is vector-valued function to plot as a vector field. Change the expressions inside the parentheses as needed.
## Below is the command for plotting a 2D vector field. The x- and y-ranges of the plot can be changed. The aspect ratio parameter is optional, but setting it to 1 guarantees a square-looking plot.
*** WARNING: Code contains possible implicit multiplication *** *** Check if any of [ 2i, 3j, 5j ] need a "*" sign for multiplication, e.g. 5x should be 5*x ! *** Error in lines 2-2 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags) in namespace, locals File "<string>", line 1 c=t**2i+t**ComplexNumber(0, '3') ^ SyntaxError: invalid syntax
x, y, z = var ('x y z') G = (1, 0, 1) plot_vector_field3d(G, (x,-5,5), (y,-5,5), (z, -5, 5), aspect_ratio = 1)
3D rendering not yet implemented
x, y = var ('x y') F = (0.3*x, -0.4*y) plot_vector_field(F, (x,-5,5), (y,-5,5), aspect_ratio = 1)
x, y = var ('x y') F = (y*x, (x+y)*y) plot_vector_field(F, (x,-5,5), (y,-5,5), aspect_ratio = 1)
## You can also plot 3D vector fields. Your vector-valued function would have 3 output coordinates. G = (-x, -y, -z)
x, y, z = var ('x y z') G = (z, 0, 0) plot_vector_field3d(G, (x,-5,5), (y,-5,5), (z, -5, 5), aspect_ratio = 1)
3D rendering not yet implemented