








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
How to perform vector calculus operations in Mathematica, a software used for mathematical operations. It introduces new concepts such as loading supplemental packages, three-dimensional graphing, and labeling axes. how to perform vector addition and subtraction, dot product, cross product, and how to plot vector fields, level curves, and surfaces. It also explains how to rotate graphs and observe them from multiple angles. useful for students studying engineering, mathematics, or physics.
Typology: Lecture notes
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Craig Beasley Department of Electrical and Systems Engineering Washington University in St. Louis St. Louis, MO
March 21, 2012
Vector calculus is a staple of the engineering disciplines. Many of the phenomena we deal with have directions associated with them, and those directions need to be preserved during mathematical operations. The mathematics involved can become tedious and cumbersome, especially in three dimensions. Furthermore, three dimensional problems tend to be difficult to visualize and draw. The ability to perform the proper calculations quickly and accurately combined with a visual model of what’s going on is an enormous boon for problem-solving.
Several new concepts will be introduced that are not exclusively related to vectors: Most notably, loading supplemental packages, three-dimensional graphing, and labeling axes.
Vector Addition & Subtraction
Since a vector is just a matrix with only one row, addition and subtraction with vectors works exactly like it does for matrices. You will not need the MatrixForm command, and because of the way the MatrixForm command interacts with other Mathematica operations, its use should be discouraged.
Dot Product
The dot product operation can be performed in one of two ways. The first is to refer back to matrix multiplication and use a period. The second is to use the Dot command, and since that follows the same syntax as the TI-89, this guide will use that exclusively.
Cross Product
Like its counterpart, the cross product operation has two means of entry. The first is to use the cross operator located on the template. The second is to use the Cross command. This guide will focus on the second, for the reason indicated above.
Below is an example of syntax for how to enter a cross product.
VectorPlot
The VectorPlot command will plot a vector field. The proper syntax to produce a generic two- dimensional vector field that uses the default graphical settings is:
VectorPlot[vector,{first axis,low,high},{second axis,low,high}]
Vector functions can also be plotted with the VectorPlot command.
VectorPlot3D
Attaching 3D to the end of any type of Plot command will generate the appropriate three-dimensional graph. Doing so requires a range be set for an additional axis.
Labeling Axes and Rotating Graphs
With so much going on inside of the previous graph, it starts to become apparent why there is a need for changing the size and quantity of the vector arrows. Unfortunately, it’s difficult to make sense of that graph because the axes aren’t labeled. It is a standard procedure in an engineering environment to clearly label the axes of a graph or figure so that the reader understands what it is they’re looking at. Computer modeling not only allows us to draw complicated objects, but also to rotate the figure and observe it from multiple angles.
Mathematica allows a three-dimensional graph to be rotated by clicking on the graph and sweeping the mouse in the desired direction of rotation. Two more screenshots will follow. The axes have also been renamed to give you a better feel for how the AxesLabel command works.
ContourPlot & ContourPlot3D
Level curves and surfaces can be plotted in Mathematica. These are the constant-value regions of a particular function. The command behaves very much like the Plot and VectorPlot command. The result of a standard ContourPlot command will show up color-coded. Warm colors are large values and cool colors are small values. By inserting a double equal sign, a specific level curve can be plotted.
The hot/cold color coding does not hold for three-dimensional plots. When looking at the general case, it is difficult to tell what is going on, as you will see in the images below
The ParametricPlot3D command can also be used to plot a parametric surface.
Needs VectorAnalysis
In order to utilize some of the vector calculus operations, Mathematica needs to load an extra package. The VectorAnalysis package is loaded thusly:
Note that there is a tilde on the end of VectorAnalysis. Do not forget that, or the package won’t load.
The VectorAnalysis package requires special variable definitions. In the forthcoming topics, pay attention to the form of the variables used by each of the commands. If you try to use any other variables besides those loaded with VectorAnalysis, the computer will not understand what you want it to do and your command will fail to execute properly.
Since the three following operations are defined differently for Cartesian, cylindrical, and spherical coordinate systems, the VectorAnalysis package loads all three. The default is Cartesian, but this can be changed with the SetCoordinates command.
Gradient
Mathematica has a Gradient command embedded natively. This is the wrong command. I can’t stress this heavily enough. Everybody’s favorite upside-down triangle is the Grad command, just the same as it’s abbreviated in calculus textbooks.
Compare that to the following functions in cylindrical and spherical coordinates. Also note that Mathematica can be told inside of the command which coordinate system to use, rather than having to set a new default every time.
Divergence
Just like the Grad command, divergence uses the same abbreviation as a standard calculus manual. Do not forget that the input to the divergence command is a vector instead of a scalar.
Line Integrals
If you can take an integral, you can take a line integral. Some work is required to set up a parametric curve and plug that into a vector function. After that, a line integral is evaluated by taking a dot product and integrating over bounded region.
Using Example #2 from page 415 of the textbook, where F = [z,x,y]:
A TI-89 is able to compute line integrals in the same manner.
Construction of a Normal Vector
A surface integral operates very much like a line integral. The hardest part is finding a normal vector. First, the surface must be parameterized. A normal vector is found by taking partial derivatives and then calculating a cross product.
Using Example #1 from page 444-445 of the textbook, where F = [3z^2,6,6xz]:
Surface Integrals
We are now ready to calculate a surface integral. The process will look much like a line integral. Instead of calculating all of the individual pieces by hand, I am going to plug everything into an integral. The machine itself is capable of doing all of the intermediary steps: partial derivatives, dot products, and cross products. This is something that can also be put into a TI-89.
Still using Example #1 from page 444-445 of the textbook, here is what comes out:
Broken down into parts, it looks like this: