Template Notebook
Generate

Mathematica Lesson 12: Line Integrals

In the menu at the top, click Make Your Own Copy to work in Mathematica Online, or click Download to use it in Mathematica.​
​​
​When asked "Do you want to automatically evaluate all the initialization cells in the notebook...?" I recommend "No" so that you can work through each cell one-at-a-time.

Vector Fields

Question 1

First, let's bring in a command we've seen before. Using Grad in Mathematica, find the gradient vector field for ​
​f(x,y,z)=exp(3x)+y²+ycos(z):
​

Information

Next we look at defining and plotting vector fields of the form F⃗(x,y)=⟨P(x,y),Q(x,y)⟩ or  F⃗(x,y,z)=⟨P(x,y,z),Q(x,y,z),R(x,y,z)⟩.​
​​
​For the rest of the course, I recommend enclosing inputs in curly brackets. This insists that we are plugging vectors into our functions and will make composition (to evaluate line and surface integrals) much easier.​
​​
​To create the vector field F⃗(x,y)=⟨x²,1−y⟩ in Mathematica, use this:
In[]:=
F[{x_,y_}]:={x^2,1-y}
(Notice the curly brackets around the inputs x and y.)​
​​
​You can see this vector field on the domain {(x,y) ∈ ℝ² : −3 ≤ x ≤ 3, −3 ≤ y ≤ 3} using VectorPlot:
In[]:=
VectorPlot[F[{x,y}],{x,-3,3},{y,-3,3}]
It may be easier to get a picture of the "flow" or motion of a vector field using StreamPlot:
In[]:=
StreamPlot[F[{x,y}],{x,-3,3},{y,-3,3}]

Question 2

Below, use our new convention to define the vector field F⃗(x,y,z)=⟨x−y,cos(y),z²⟩. Be sure to use Mathematica syntax, and omit any spacing.
​
Note that you can plot this in 3-D using
VectorPlot3D[F[{x,y,z}],{x,-3,3},{y,-3,3},{z,-3,3}]