Basic Vector Operatons
v+w v-w 3v -w
F={1, 3, -2}
G={-2, 5, 6}
F+G F-G -3F
The dot product is calculated with a "period" between the vectors.
v.w F.G
The norm or length can be calculated in two ways, using dot products or by defining a function to calculate it. If you use a function, you must make sure to evaluate the function each time you open the notebook.
Sqrt[v.v]
vnorm[v_]:=Sqrt[v.v]
vnorm[F]
To calculate the cross product, you must first load the Mathematica package for the cross product. You must evaluate this each time you start the notebook.
<<LinearAlgebra`CrossProduct`
Cross[v,w] Cross[F,G]
I have defined some functions to plot vectors. You must evaluate these cells each time you start the notebook. I have collected these functions in a small notebook "initializations.ma" that you can run before working with this notebook.
vector2DPlot[from_,to_]:=
Show[Graphics[{AbsolutePointSize[4],RGBColor[1,0,0],
Map[Point,to],Map[Line[{from[[#]],to[[#]]}]&,
Table[i,{i,Length[from]}]]}],
Axes->True,AspectRatio->Automatic]
vector3DPlot[from_,to_]:=
Show[Graphics3D[{AbsolutePointSize[4],RGBColor[1,0,0],
Map[Point,to],Map[Line[{from[[#]],to[[#]]}]&,
Table[i,{i,Length[from]}]]}],
Axes->True,AspectRatio->Automatic]
vectorPlot[from_,to_]:= If[Length[N[from[[1]]]]==2,Return[vector2DPlot[from,to]], Return[vector3DPlot[from,to]]];
These functions will plot a vector with tail at the point "from" and head at the point "to". The dot is at the head of the vector. These functions are designed to plot more than one vector. This means that the "from" and "to" arguments must be a LIST of vectors (even if you only have one vector in each). Here are some examples.
vectorPlot[{{0,0}},{{2,3}}];
vectorPlot[{{0,0},{0,0},{0,0}},{{1,1},{2,3},{3,5}}];
vectorPlot[{{1,3}},{{4,-6}}];
vectorPlot[{{0,0,0}},{{-4,2,5}}];
vectorPlot[{{0,0,0},{1,2,-2}},{{1,5,2},{2,4,6}}];Here is an illustration of the parallelogram law of vector addition.
{1,4}+{3,-6}
vectorPlot[{{0,0},{0,0},{0,0}},{{1,4},{3,-6},{1,4}+{3,-6}}];
{2,2,0}+{-3,1,0}
vectorPlot[{{0,0,0},{0,0,0},{0,0,0}},{{2,2,0},{-3,1,0},{2,2,0}+{-3,1,0}}];Here is an illustration of scalar multiplication.
2{1,4}
-{1,4}
vectorPlot[{{0,0},{0,0}},{{1,4},2{1,4}}];
vectorPlot[{{0,0},{0,0}},{{1,4},-{1,4}}];
3{2,2,0}
-{2,2,0}
vectorPlot[{{0,0,0},{0,0,0}},{{2,2,0},3{2,2,0}}];
vectorPlot[{{0,0,0},{0,0,0}},{{2,2,0},-{2,2,0}}];