All published worksheets from http://sagenb.org
Image: ubuntu2004
Vector fields arise naturally in the physical world, where most fall into two types, velocity fields and force fields.
Example of a 2D velocity field
Perhaps the following approximates two-dimensional fluid flow (an example of a velocity field) around an obstruction. Sage plots the vectors (arrows) so that the length from tail to head is equal to the length of the vector. Thus, longer arrows correspond to faster flow.
Example of a 2D gravitational (force) field
The previous cell suggests flow of any kind is associated with a velocity (vector) field. Some examples of force fields include electric and gravitational fields. Consider the gravitational field about a star in a 2D universe, with coordinate frame chosen so that the star is at the origin. At each point in the plane there is a vector pointing at the origin with magnitude equal to the gravitational force felt at that point; the closer a point is to the origin the stronger the force. The cell below draws such a field in red. To avoid being drawn into the star, satellites might orbit at faster or slower speeds, depending on distance to the star. If orbits are required to be everywhere orthogonal to the gravitational field (something that is not so in our solar system), the resulting velocity field will look like the one depicted in blue below.
Gradient fields
If vector fields arise naturally in the physical world, they do so in multivariable calculus as well. A scalar function of variables requires numeric inputs and produces a single numeric output. Such a function, if it is differentiable, has partial derivatives, one for each input variable. A very natural thing is to consider the gradient vector, the vector which has, as its components, each of the partial derivatives. Since there is a gradient vector for each point of differentiability in -space, the original function induces a gradient (vector) field. Such a field is portrayed in the next cell for a function of variables, along with the surface .
3D Vector Fields
There is really little difference in plotting 3-dimensional vector fields, beyond a slight change to the name of the function.
Below, we see a surprisingly interesting looking field given it has the simple formula
Fi j k.
If you don't like the color scheme used for the various arrows, you may dictate they be all of one color, say, red, by adding the switch: colors='red'.
The following cell draws the same field (in blue) as the previous cell, and then draws (in red) the trajectories of three separate free particles whose paths are everywhere tangent to the velocity field, one beginning at position (0, 1.42, 0.1), another at the nearby point (0, 1.42, 0), and a third beginning at (0, 2.84, -0.01).
Example of a 3D gradient field
Recall from MATH 162 that a gradient field is everywhere orthogonal to level sets of . For instance, the function of three variables
has level sets (whenever ) which are spheres. Its gradient field is . The next cell plots several level sets of (all that is plotted are half-spheres instead of full spheres) along with this gradient field. Notice that the arrows are orthogonal to the spheres.