Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Image: ubuntu2204
Vector Calculus with SageMath
The 3-dimensional Euclidean space
We can declare the 3D Euclidean space , with as cartesian coordinates.
Vector fields
We define a vector field on from its components in the vector frame .
We can access to the components of the vector field via the square bracket operator.
A vector field can evaluate at any point of .
Vector fields can be plotted (see the list of options for customizing the plot).
We may define a vector field with generic components.
Algebraic operations on vector fields
Dot product
The dot (or scalar) product of the vector fields and is obtained by the method dot_product, which admits dot
as a shortcut alias:
Norm
The norm of a vector field is
Cross product
Scalar triple product
Let us introduce a third vector field. As a example, we do not pass the components as arguments of vector_field, as we did for and ; instead, we set them in a second stage, via the square bracket operator, any unset component being assumed to be zero.
The scalar triple product of the vector fields , , and is obtained as follows.
Let us check that the scalar triple product of and is .
Differential operators
While the standard operators grad, div, curl, etc. involved in vector calculus are accessible via the dot notation (e.g. v.div()
), let us import functions grad, div, curl, etc. that allow for using standard mathematical notations (e.g. div(v)).
Gradient of a scalar field
We first introduce a scalar field, via its expression in terms of Cartesian coordinates. In this example, we consider a unspecified function of .
Divergence
Curl
Laplacian
In the above formula, u[[i]] return the -th component of as a scalar field, while would have returned the coordinate expression of this scalar field; besides, is the Cartesian frame.