VC.01 Vectors Point the Way 
 BASICS

\(Off[General::spell]; 
Off[General::spell1]; 

    Off[ParametricPlot3D::ppcom]; 
Off[ParametricPlot::ppcom]; 

    Off[Plot::plnr]; 
SetOptions[Limit, Analytic -> True]; \)

CMView = {2.7, 1.6, 1.2};

Vector Drawer

(* :Title:  VectorDraw  *)
(* :Author: Bruce Carpenter *)
(* :Summary:  Construct 2 and 3 dimensional vectors,
     arrows, and arrowheads as graphics 
     objects.
*)
(* :Date:  Copyright 1997 by Bruce Carpenter. 
*)
(*  :Drawbacks:  Since the vectors are drawn out of 
     context, the shapes of the arrowheads are only 
     correct with AspectRatio set to Automatic.
*)
BeginPackage["Vector3D`","Graphics`Colors`"];

Axes3D::usage = "Axes3D[a, b] creates a Graphics3D object of cartesian axes with x, y, and z running from -a/3 to a, and with axes labels b units beyond the tips of the axes.  Axes3D[a] is Axes3D[a, a/8].";
Perpend::usage = "Perpend[a] returns a unit vector which is perpendicular to the vector a.";
Arrow::usage = "Arrow[a] produces a 2 or 3 dimensional vector from the origin to a. Arrow[a, Tail -> tail] gives a vector from tail to a.";
Vector::usage = "Vector[a, b] gives a 2D or 3D vector from a to b.";
ArrowHead::usage = "ArrowHead[a, vec] produces an arrowhead with its tip placed at the point a, pointing in the direction of the vector vec.";
Tail::usage = "Tail -> point puts the tail of the vector at point.";
Norm::usage = "Norm[vec] returns the Euclidean length of vec.";
Normalize::usage = "Normalize[vec] returns a unit vector in the direction of vec, provided vec is nonzero.";
Aperture::usage = "Aperture is the ratio of the radius of the base to the length of the head of a vector.";
TipSize::usage = "TipSize specifies an absolute size for the inner tip length of the head of a vector.";
TipRatio::usage = "TipRatio is the ratio of the inner length of the arrowhead to the length of the shaft of a vector.";
HeadRatio::usage = "HeadRatio is the ratio of the outer length of the arrowhead to the length of the shaft of a vector.";
HeadSize::usage = "HeadSize specifies an absolute size for the head of a vector.";
ScaleFactor::usage = "ScaleFactor specifies the amount to scale a vector in length and may be either a number or a pure function.";
ZeroVectorPointSize::usage = "ZeroVectorPointSize is the size of the point used to represent a zero vector.";
Options[Vector] = Options[Arrow] = Options[ArrowHead] =
{HeadRatio -> 0.18, TipRatio -> 0.14, Aperture -> 0.3, ScaleFactor -> 1, HeadType -> Polygon, ShaftQ -> True, EdgesQ -> True, VectorColor -> RGBColor[0,0,1], ShaftWidth -> 0.005, ZeroVectorPointSize -> 0.01};

Begin["`Private`"];
SetOptions[ParametricPlot,AspectRatio -> Automatic];
SetOptions[Plot,AspectRatio -> Automatic];
SetOptions[Graphics,AspectRatio -> Automatic];
Axes3D[u_,v_] := Graphics3D[{ {Blue,Line[{{-u/3,0,0},{u,0,0}}]},
    Text["x",{u + v,0,0}], {Blue,Line[{{0,-u/3,0},{0,u,0}}]},
    Text["y",{0, u + v,0}], {Blue,Line[{{0,0,-u/3},{0,0,u}}]},
    Text["z",{0,0,u + v}]}]; 
Axes3D[u_] := Axes3D[u,u/8];
Norm[a_?VectorQ] := N[Sqrt[a.a]];
Normalize[a_?VectorQ] := If[a.a == 0, a, a/Norm[a]];
Perpend[a_?VectorQ] := Normalize[{a[[2]],-a[[1]]}]/;Length[a]==2
Perpend[a_?VectorQ] := Normalize[If[a[[1]]==0,{1,0,0},{0,a[[3]],-a[[2]]}]]/;Length[a]==3
Base3D = Table[{Cos[2 k Pi/8.], Sin[2 k Pi/8.]},{k,0,8}]; 
Vector[from_?VectorQ, to_?VectorQ, opts___] := Module[
   {sq, sw, ht, hs, hr, tr, ap, sf, vc, zvps, diff = to - from, tip},
   {sq, sw, ht, hs, hr, ts, tr, ap, sf, vc, zvps} = {ShaftQ, ShaftWidth, HeadType, HeadSize, HeadRatio, TipSize, TipRatio, Aperture, ScaleFactor, VectorColor, ZeroVectorPointSize} /. {opts} /. Options[Vector];
   If[from==to, Return[Graphics[{PointSize[zvps],vc,Point[from]}]]];
   diff = If[NumberQ[N[sf]], sf diff, sf[diff]];
   tip = from + diff;
   If[NumberQ[hs], hr = hs/Norm[diff]; tr = 0.75 hr];
   If[NumberQ[ts], tr = ts/Norm[diff]];
   Graphics[{If[sq,{vc,Thickness[sw],Line[{from,tip - tr diff}]},{}],With[{trans = ap hr Norm[diff] Perpend[diff]},
      {vc, Thickness[sw], ht[{tip, (tip - hr diff + trans),
       (tip - tr diff), (tip - hr diff - trans),tip}]}]}]
] /; Length[from]==Length[to]==2
Vector[from_?VectorQ, to_?VectorQ, opts___] := Module[
   {sq, eq, sw, hs, hr, tr,ap, sf, vc, zvps, diff = to - from, tip},
   {sq, eq, sw, hs, hr, ap, sf, vc, zvps} = {ShaftQ, EdgesQ, ShaftWidth, HeadSize, HeadRatio, Aperture, ScaleFactor, VectorColor, ZeroVectorPointSize} /. {opts} /. Options[Vector];
   If[from==to, Return[Graphics3D[{PointSize[zvps],vc,Point[from]}]]];
   diff = If[NumberQ[N[sf]], sf diff, sf[diff]];
   tip = from + diff;
   If[NumberQ[hs], hr = hs/Norm[diff]];
   tr = hr/2;
   Graphics3D[{If[sq,{vc,Thickness[sw],Line[{from,tip-tr diff}]},{}], If[eq, {}, EdgeForm[]], {SurfaceColor[vc],
      With[{temp = Perpend[diff]},
      Polygon[Append[#,tip]]& /@ Partition[(tip - hr diff + #)&/@((ap hr Norm[diff] Base3D) . {temp,Normalize[Cross[temp,diff]]}),2,1]]}}]
] /; Length[from]==Length[to]==3
Arrow[a_, Tail->b_, opts___] := Vector[b,a+b,opts]
Arrow[a_, opts___] := Vector[Table[0,{Length[a]}],a,opts]
ArrowHead[a_, b_, opts___] := Vector[a-b,a,ShaftQ->False,opts]

End[];
EndPackage[];
Null

Graphics`Colors`GosiaGreen = RGBColor[0,  0.392187,  0];

Spherical Setup

\(Clear[polar]; 

    polar[{x_, y_, z_}] := {\@\(x\^2 + y\^2 + z\^2\), ArcTan[y\/x], 
        ArcCos[z\/\@\(x\^2 + y\^2 + z\^2\)]}; 
Clear[X, length]; 

    length[X_] := \@\(X . X\); 
\(rr = 3; \)\)R = 5; scale = 0.8; red = RGBColor[1, 0, 0]; blue = RGBColor[0, 0, 1]; color1 = RGBColor[0.8, 0.2, 0.8]; color2 = RGBColor[0.2, 0.8, 0.2]; black = RGBColor[0, 0, 0]; \(Clear[axes]; 

    axes := Graphics3D[{Line[{X, {1.5\ rr, 0, 0}}], 
          Line[{X, {0, 1.5\ rr, 0}}], Line[{X, {0, 0, 2\ rr}}]}]; 

    Clear[xyplane]; 

    xyplane := 
      Graphics3D[
        Polygon[{{\(-2\)\ rr, \(-2\)\ rr, 0}, {\(-2\)\ rr, 2\ rr, 0}, {2\ rr, 
              2\ rr, 0}, {2\ rr, \(-2\)\ rr, 0}}]]; 
\(X = {0, 0, 0}; \)\)origin = Graphics3D[{black, Point[X]}]; Z = {2, 3, 5}; \(Clear[point]; 

    point := Graphics3D[{red, PointSize[0.03], Point[scale\ Z]}]; 

    \(Z0 = {0, 0, length[0.8\ Z]}; \)\)\(Clear[zpoint]; 
zpoint = Graphics3D[{black, Point[Z0]}]; 

    \(XY = scale\ Z\ {1, 1, 0}; \)\)\(Clear[xypoint]; 
xypoint := Graphics3D[{black, Point[XY]}]; 

    \(X0 = {length[scale\ Z\ {1, 1, 0}], 0, 0}; \)\)xpoint = Graphics3D[{black, Point[X0]}]; Y0 = {0, length[scale Z {1, 1, 0}], 0}; ypoint = Graphics3D[{black, Point[Y0]}]; \(Clear[ray]; 
ray := Graphics3D[{blue, Line[{X, scale\ Z}]}]; 

    Clear[ray1]; 
ray1 := Graphics3D[{color1, Line[{scale\ Z, Z}]}]; 

    Clear[xyray]; 
xyray := Graphics3D[{red, Line[{X, Z\ {1, 1, 0}}]}]; 

    \(rays := {ray, xyray}; \)\)xyaux = 
      ((length[0.8 Z] (0.8 Z {1, 1, 0}))/length)[0.8 Z {1, 1, 0}]; 
    \(Clear[zarc]; 

    zarc = Graphics3D[{blue, 
          Line[Table[
              \(Cos[t]\ \) {0, 0, length[0.8\ Z]} + Sin[t]\ xyaux, {t, 0, 
                \(polar[0.8\ Z]\)[[3
                  ]],  .1}]]}]; 
Clear[zarc1]; 

    zarc1 = Graphics3D[{color1, 
          Line[Table[
              \(Cos[t]\ \) {0, 0, length[0.8\ Z]} + Sin[t]\ xyaux, {t, 
                \(polar[0.8\ Z]\)[[3]], 
                1,  .1}]]}]; 
Clear[zarc2]; 

    zarc2 = Graphics3D[{color1, 
          Line[Table[
              \(Cos[t]\ \) {0, 0, length[0.8\ Z]} + Sin[t]\ xyaux, {t, 
                \(-0.8\), 0,  .1}]]}]; 
Clear[xyarc]; 

    xyarc = Graphics3D[{blue, 
          Line[Table[
              Cos[t]\ X0 + Sin[t]\ Y0, {t, 0, 
                \(polar[XY]\)[[2
                  ]],  .1}]]}]; 
Clear[xyarc1]; 

    xyarc1 = Graphics3D[{color1, 
          Line[Table[Cos[t]\ X0 + Sin[t]\ Y0, {t, \(- .5\), 0,  .1}]]}]; 

    Clear[xyarc2]; 

    xyarc2 = Graphics3D[{color1, 
          Line[Table[
              Cos[t]\ X0 + Sin[t]\ Y0, {t, 
                \(polar[XY]\)[[2]], 
                \(polar[XY]\)[[2]] + 
                  0.3,  .1}]]}]; 
Clear[stick]; 

    stick = Graphics3D[{red, Line[{scale\ Z, XY}]}]; 

    \(xaxislabel = Text["x", {0.363, 0.26}]; \)\)yaxislabel = Text["y", {0.73, 0.3}]; zaxislabel = Text["z", { .5, 0.67}]; stickplot = 
      Show[xyplane, axes, ray, point, Boxed -> False, 
        ViewPoint -> {2.747, 1.594, 1.168}, 
        Epilog -> {xaxislabel, yaxislabel, zaxislabel}, 
        DisplayFunction -> Identity]; rho = Text["r", {0.53, 0.45}]; rlabel = 
      Show[xyplane, axes, ray, point, Boxed -> False, 
        ViewPoint -> {2.747, 1.594, 1.168}, 
        Epilog -> {rho, xaxislabel, yaxislabel, zaxislabel}, 
        DisplayFunction -> Identity]; phi = Text["s", {0.55, 0.57}]; slabel = 
      Show[xyplane, zpoint, axes, ray, point, zarc, zarc1, zarc2, 
        Boxed -> False, ViewPoint -> {2.747, 1.594, 1.168}, 
        Epilog -> {phi, xaxislabel, yaxislabel, zaxislabel}, 
        DisplayFunction -> Identity]; theta = Text["t", { .5, 0.3}]; tlabel = 
      Show[xyplane, axes, xypoint, xpoint, ray, stick, point, xyarc, xyarc1, 
        xyarc2, Boxed -> False, ViewPoint -> {2.747, 1.594, 1.168}, 
        Epilog -> {theta, xaxislabel, yaxislabel, zaxislabel}, 
        DisplayFunction -> Identity]; all = 
      Show[xyplane, axes, ray, stick, point, zpoint, xpoint, xypoint, xyarc, 
        xyarc1, xyarc2, zarc, zarc1, zarc2, Boxed -> False, 
        ViewPoint -> {2.747, 1.594, 1.168}, 
        Epilog -> {theta, phi, rho, xaxislabel, yaxislabel, zaxislabel}, 
        DisplayFunction -> Identity];

Crisscross

\(Clear[x]; 

    crisscross = 
      Plot[{Cos[x], Sin[x]}, {x, π\/8, \(3\ π\)\/8}, 
        PlotStyle -> {{RGBColor[1, 0, 0], Thickness[0.02]}}, 
        Axes -> None, AspectRatio -> 1\/3, 
        DisplayFunction -> Identity]; \)

B.1)  Vectors: 
How you move them, how you add them, how you subtract them, and how you multiply them by numbers

A vector X in the plane is a stick with: 
->  one end (its tail) at {0, 0} and 
->  the other end (its tip) at a specified location {x[1], x[2]}.
Most folks like to draw a vector as an arrow with the arrowhead at its tip.
Here's a look at the vector running from {0, 0} to {3, 4}:

X = {3, 4}; Show[Arrow[X, Tail -> {0, 0},  VectorColor -> Blue], 
      Axes -> True, PlotRange -> All, AxesOrigin -> {0, 0}];

Most folks like to see the arrowhead at the tip so they can tell which end of the stick is the tip. Here is the vector running from
       {0, 0} (tail) to {-5, 4} (tip):

X = {-5, 4}; Show[Arrow[X, VectorColor -> Red], Axes -> True, 
      PlotRange -> All, AxesLabel -> {"x", "y"}, 
      AxesOrigin -> {0, 0}];

Here are some others:

X = {-2, -4}; Show[Arrow[X], Axes -> True, PlotRange -> All, 
      AxesLabel -> {"x", "y"}, AxesOrigin -> {0, 0}];

X = {3, -1}; Show[Arrow[X], Axes -> True, PlotRange -> All, 
      AxesLabel -> {"x", "y"}, AxesOrigin -> {0, 0}];

Play with these by rerunning with vectors of your own choice.
A vector 
       X = {x[1], x[2]} 
is  written the same as the coordinates of its tip because everyone knows its tail is at {0, 0}.
You can also work with three-dimensional vectors by writing 
       X = {x[1], x[2], x[3]} 
for the vector whose tail is at {0, 0, 0} and whose tip is at    
       {x[1], x[2], x[3]}.
Here's the vector {1.5, 5.3, 2.0} shown along with the three-dimensional coordinate axes:

\(X = {1.5, 5.3, 2.0}; 
spacer\  = \ 0.2; 
h\  = \ 1; 


    threedims\  = \ Axes3D[h, \ spacer]; 


    Show[Arrow[X, VectorColor -> Red], threedims, PlotRange -> All, 
      ViewPoint -> CMView, Boxed -> False]; \)

Here's another:

X = {1, -3, 1}; Show[Arrow[X, VectorColor -> Red], threedims, 
      PlotRange -> All, ViewPoint -> CMView, Boxed -> False];

Here's a vector parallel to the yz-plane:

X = {0, 2, 1}; Show[Arrow[X, VectorColor -> Red], threedims, 
      PlotRange -> All, ViewPoint -> CMView, Boxed -> False];

Play by rerunning with three-dimensional vectors of your own choice.

B.1.a.i) Moving vectors

How do you move vectors to new positions?

Answer:

Very easily.
Here is a vector in two dimensions with its tail at {0, 0}:

X = {3, 4}; Show[Arrow[X, Tail -> {0, 0}], AxesLabel -> {"x", "y"}, 
      Axes -> True, AxesOrigin -> {0, 0}];

Here's the same vector X shown twice, once with its tail at {0, 0} and once with its tail at {2, 1}:

X = {3, 4}; \(\(Show[Arrow[X, Tail -> {0, 0}], Arrow[X, Tail -> {2, 1}], 

      	Axes -> True, AxesLabel -> {"x", "y"}, 
      PlotRange -> All, AxesOrigin -> {0, 0}]; \)\)

The two arrows have equal lengths and they both point in the same direction.
They're parallel.
Try it again for a different vector and a different tail:

X = {-1, 4}; \(\(Show[Arrow[X, Tail -> {0, 0}], 
      Arrow[X, Tail -> {\(-2\), 3}], 
	Axes -> True, 
      AxesLabel -> {"x", "y"}, PlotRange -> All, 
      AxesOrigin -> {0, 0}]; \)\)

Same length; same direction.
Here's a vector X shown with its tail at {0, 0}, and shown with a whole squadron of its transplants:

X = {2, 3}; Clear[tail, k]; tail[1] = {0, 0}; tail[2] = {6, 4}; tail[3] = {6, 6}; tail[4] = {6, 8}; tail[5] = {4, 8}; \(tail[6] = {2, 8}; 


    squadron = 
      Table[Arrow[X, Tail -> tail[k], VectorColor -> Red], {k, 1, 
          6}]; 

Show[squadron, Axes -> True, 
      AxesLabel -> {"x", "y"}, PlotRange -> All, 
      AxesOrigin -> {0, 0}]; \)

Check it out for a different X:

X = {-3, -2}; Clear[tail, k]; tail[1] = {0, 0}; tail[2] = {6, 4}; tail[3] = {6, 6}; tail[4] = {6, 8}; tail[5] = {4, 8}; \(tail[6] = {2, 8}; 


    squadron = 
      Table[Arrow[X, Tail -> tail[k], VectorColor -> Red], {k, 1, 
          6}]; 

Show[squadron, Axes -> True, 
      AxesLabel -> {"x", "y"}, PlotRange -> All, 
      AxesOrigin -> {0, 0}]; \)

Check it out in three dimensions:

X = {3, 0, 2}; Clear[tail, k]; tail[1] = {0, 0, 0}; tail[2] = {1, 0, 0}; tail[3] = {-1, 0, 0}; tail[4] = {0, 1, 0}; tail[5] = {0, -1, 0}; tail[6] = {0, 0, 1}; \(tail[7] = {1, 0, 1}; 


    squadron = 
      Table[Arrow[X, Tail -> tail[k], VectorColor -> Red], {k, 1, 
          7}]; 

Show[squadron, threedims, PlotRange -> All, 
      ViewPoint -> CMView, Boxed -> False]; \)

Same length; same direction.

B.1.a.ii)

Are there any rules about moving vectors to new positions?

Answer:

You can put the tail anywhere you like, but you must be careful not to change the direction or the length of the vector.

B.1.b) Adding vectors

How do you add vectors?

Answer:

Very easily.
For instance, if X = {3, 8} and Y = {5, 4} are vectors, then you add them to get
     X + Y = {3, 8} +  {5, 4} = {8, 12}
just by adding the corresponding components.
Mathematica can do this too:

X = {3, 8}; Y = {5, 4}; X + Y

You can add three-dimensional vectors:

X = {3, -5, 2}; Y = {3, 4, -7}; X + Y

You cannot add vectors from different dimensions:

X = {3, -5}; Y = {3, 4, -7}; X + Y

Here is a way of seeing what's happening in two dimensions:
Look at a picture of X = {3, 10} and Y = {8, 2} and X +  Y:

X = {3, 10}; Y = {8, 2}; Show[Arrow[X, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["X", (X/2)]], 
      Arrow[Y, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["Y", (Y/2)]], 
      Arrow[X + Y, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["X+Y", ((X + Y)/2)]], Axes -> Automatic];

X +  Y represents the combined push of X and Y.
See what happens when you move Y without changing its direction, so that its tail is at the tip of X:

Show[Arrow[X, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["X", (X/2)]], 
      Arrow[Y, Tail -> X, VectorColor -> Red], 
      Graphics[Text["Y", X + (Y/2)]], 
      Arrow[X + Y, Tail -> {0, 0}, VectorColor -> Blue], 
      Graphics[Text["X+Y", ((X + Y)/2)]], Axes -> Automatic];

A triangle!
This triangle shows that you have your choice of ways of getting from {0, 0} to the tip of X +  Y.
->  Route 1: You can walk directly on the vector X +  Y from its tail to its tip.
->  Route 2: You can walk on X to the tip of X, and then hook the tail of Y on the tip of X, and finish the trip by walking along Y to its tip.
Lazy folks usually take Route 1.
Rerun this for two-dimensional vectors of your own choice.

Now check out what happens in three dimensions:

X = {3, -4, 7}; \(Y = {1, 2, 3}; 


    Show[Arrow[X, Tail -> {0, 0, 0}, VectorColor -> Red], 
      Graphics3D[Text["X", X\/2]], 
      Arrow[Y, Tail -> {0, 0, 0}, VectorColor -> Red], 
      Graphics3D[Text["Y", Y\/2]], 
      Arrow[X + Y, Tail -> {0, 0, 0}, VectorColor -> Red], 
      Graphics3D[Text["X+Y", \(X + Y\)\/2]], threedims, 
      PlotRange -> All, ViewPoint -> CMView, Boxed -> False]; 
    \)

Again, in three dimensions, X +  Y represents the combined push of X and Y.
See what happens when you move Y without changing its direction so that its tail is at the tip of X:

Show[Arrow[X, Tail -> {0, 0, 0}, VectorColor -> Red], 
      Graphics3D[Text["X", (X/2)]], 
      Arrow[Y, Tail -> X, VectorColor -> Red], 
      Graphics3D[Text["Y", X + (Y/2)]], 
      Arrow[X + Y, Tail -> {0, 0, 0}, VectorColor -> Blue], 
      Graphics3D[Text["X+Y", ((X + Y)/2)]], threedims, 
      PlotRange -> All, ViewPoint -> CMView, Boxed -> False];

Another triangle.
Just as in two dimensions, this triangle shows that you have your choice of ways of getting from {0, 0} to the tip of X +  Y.  
->  Route 1: You can walk directly on the vector X +  Y from its tail to its tip.
->  Route 2: You can walk on X to the tip of X, and then hook the tail of Y on the tip of X, and finish the trip by walking along Y to its tip.
Rerun the pictures above for different vectors X and Y until you get the hang of vector addition.

B.1.c)

How do you subtract vectors?

Answer:

With no trouble.
For instance, if X = {8, 2} and Y = {3, 4} are vectors, then you subtract Y from X to get
       X - Y = {8, 2} - {3, 4} = {5, -2}.
Mathematica can do this too:

X = {8, 2}; \(Y = {3, 4}; 

X - Y\)

Here is a way of seeing what's happening.
Look at a picture of X = {8, 2}, Y = {3, 4}, and X -  Y:

X = {8, 2}; \(Y = {3, 4}; 


    Show[Arrow[X, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["X", X\/2]], 
      Arrow[Y, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["Y", Y\/2]], 
      Arrow[X - Y, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["X-Y", \(X - Y\)\/2]], Axes -> Automatic]; \)

This time X is the combined push of Y and X -  Y.
See what happens when you move X -  Y without changing its direction so that its tail is at the tip of Y:

Show[Arrow[X, Tail -> {0, 0}, VectorColor -> Blue], 
      Graphics[Text["X", (X/2)]], 
      Arrow[Y, Tail -> {0, 0}, VectorColor -> Red], 
      Graphics[Text["Y", (Y/2)]], 
      Arrow[X - Y, Tail -> Y, VectorColor -> Red], 
      Graphics[Text["X-Y", Y + ((X - Y)/2)]], Axes -> Automatic];

Another triangle.
You can get to the tip of X by going directly along X, or you can go from the tail of Y to the tip of Y, and then ride on X -  Y to the tip of X.
This is not a surprise because X = (X -  Y) +  Y.
Rerun for some other vectors of your own choice.
Here it is in three dimensions:

X = {4, 2, 8}; \(Y = {\(-2\), 6, \(-3\)}; 

spacer = 0.2; 
\(h = 1; \)\)\(threedims = Axes3D[h, \ spacer]; 
CMView = {2.7, 1.6, 1.2}; 


    Show[Arrow[X, Tail -> {0, 0, 0}, VectorColor -> Blue], 
	
      Graphics3D[Text["X", X\/2]], 
	
      Arrow[Y, Tail -> {0, 0, 0}, VectorColor -> Red], 
	
      Graphics3D[Text["Y", Y\/2]], 
	
      Arrow[X - Y, Tail -> Y, VectorColor -> Red], 
	
      Graphics3D[Text["X-Y", Y + \(X - Y\)\/2]], 
	threedims, 
      PlotRange -> All, ViewPoint -> CMView, Boxed -> False]; 
    \)

Here it is for two random vectors in three dimensions:

\(X = 2\ {Random[], Random[], Random[]}; 

    Y = 2 {Random[], Random[], Random[]}; 

spacer = 0.2; 
\(h = 1; \)\)\(threedims = Axes3D[h, \ spacer]; 
CMView = {2.7, 1.6, 1.2}; 


    Show[Arrow[X, Tail -> {0, 0, 0}, VectorColor -> Blue], 
	
      Graphics3D[Text["X", X\/2]], 
	
      Arrow[Y, Tail -> {0, 0, 0}, VectorColor -> Red], 
	
      Graphics3D[Text["Y", Y\/2]], 
	
      Arrow[X - Y, Tail -> Y, VectorColor -> Red], 
	
      Graphics3D[Text["X-Y", Y + \(X - Y\)\/2]], 
	threedims, 
      PlotRange -> All, ViewPoint -> CMView, Boxed -> False]; 
    \)

Rerun for other X and Y of your own choice until you get the picture down pat.

B.1.d)

How do you multiply vectors by numbers?

Answer:

You just do it.
For instance, if X = {3, 1} , then 2  X = {6, 2}.   
Mathematica can do this too:

X = {3, 1}; 2 X

Here are X and 2  X both shown with their tails at {0, 0}:

X = {3, 1}; \(\(Show[Arrow[2\ X, Tail -> {0, 0}, VectorColor -> Red], 
\ \ 
      \ \ \ \ \ \ \ \ 	Graphics[Text["2X", \(3\ X\)\/2]], 
\ \ \ \ \ \ \ \ 
      \ \ 	Arrow[X, Tail -> {0, 0}, VectorColor -> Blue], 
\ \ \ 
      \ \ \ \ \ \ \ 	Graphics[Text["X", X\/2]], Axes -> Automatic]; 
    \)\)

2  X points the same direction as X, but 2  X is twice as long as X.  That makes some sense because 2  X is the same thing as X +  X.
Here are X and 0.3  X both shown with their tails at {0, 0}:

\(\(Show[Arrow[0.3\ X, Tail -> {0, 0}, VectorColor -> Red], 
\ 
      \ \ \ \ \ \ \ \ \ 	Graphics[Text["0.3 X", \(0.3\ X\)\/2]], 
\ \ \ \ \ 
      \ \ \ \ 	Arrow[X, Tail -> {0, 0}, VectorColor -> Blue], 
\ 
      \ \ \ \ \ \ \ \ 	Graphics[Text["X", X\/2]], Axes -> Automatic]; 
    \)\)

0.3  X points in the same direction as X points. 
The only difference is that the length of 0.3  X is 0.3 times the length of X.
The same idea carries over to three dimensions as well.

B.2)  Tangent vectors, velocity vectors, and tangent lines

B.2.a.i) Tangent and velocity vectors

Here's a curve in two dimensions:

Clear[x, y, t, P]; x[t_] = 3 Sin[t]; y[t_] = Cos[t]; \(P[t_] = {x[t], y[t]}; 


    curveplot = 
      ParametricPlot[{P[t]}, {t, 0, 5}, AspectRatio -> Automatic, 
		
        PlotStyle -> {{Thickness[0.01], Blue}}]; \)

Here's what you get when you add plots of the vectors 
       P'[t]={x'[t],y'[t]} 
with their tails at P [t] for some choices of t:

hotplot=Show[curveplot,
		Table[Arrow[P'[t],Tail -> P[t],VectorColor -> Red],
			{t, 0, 5, (5/6)}]];

Hot plot.
Describe what you see in terms of tangent vectors and velocity vectors.

The vectors you see are 
       P'[t]={x'[t],y'[t]} 
plotted with their tails at 
       P [t] = {x[t], y[t]} 
for selected t's.  The vectors are tangent to the curve. 
If you imagine t to be time, and you agree that you are at 
       P [t] = {x[t], y[t]} 
at time t, then the vector P'[t] measures your velocity at time t.
Take another look at the plot:

Show[hotplot];

The direction of P'[t] measures the instantaneous direction you are moving at time t.
The length of P'[t] measures your instantaneous speed at time t.  The plot above shows that you start at the top at time t = 0, moving rather quickly to the right. As you enter the turn on the right, you slow down until the curve flattens out. Then you speed up, slowing down as you go into the turn on the left.

B.2.a.ii)

Does this good stuff work in three dimensions as well?

Try it and see:

Clear[x, y, z, t, P]; x[t_] = (Sqrt[t + 1]) Cos[t]; y[t_] = (Sqrt[t + 1]) Sin[t]; z[t_] = t; P[t_] = {x[t], y[t], z[t]};

curveplot = 
        ParametricPlot3D[P[t], {t, 0, 10}, DisplayFunction -> Identity]
          ;

tangentvectors=Table[Arrow[P'[t],Tail -> P[t],VectorColor -> Red],{t, 0, 10}];

threedims = Axes3D[2, 0.2];

Show[threedims, curveplot, tangentvectors, ViewPoint -> CMView, 
        Boxed -> False, DisplayFunction -> $DisplayFunction];

Sure it does.

B.2.b.i) Tangent lines

Here's a curve shown with a certain point on the curve:

Clear[x, y, t, P]; x[t_] = (t^2); y[t_] = t + Cos[3 t]; \(P[t_] = {x[t], y[t]}; 


    curveplot = 
      ParametricPlot[{P[t]}, {t, 0, 3}, 
        PlotStyle -> {{Thickness[0.01], Blue}}, 
        AxesLabel -> {"x", "y"}, 
        Epilog -> {PointSize[0.05], Red, Point[P[1.9]]}]; \)

The special point is:

P[1.9]

Plot the line tangent to this curve at this special point.

As a first step, show the plot above along with the tangent vector at P [1.9]:

Show[curveplot,Arrow[P'[1.9],Tail -> P[1.9],VectorColor -> Red]];

The line tangent to the curve at P [1.9] runs right through the shaft of the arrow. Here's how you can use the tangent vector P'[1.9] to come up with a plot of the tangent line.

Clear[tanline, s];
tanline[s_]=P[1.9]+s P'[1.9];

tanlineplot = 
        ParametricPlot[tanline[s], {s, 0, 2}, 
          PlotStyle -> Thickness[0.01], DisplayFunction -> Identity]
          ;

Show[curveplot,Arrow[P'[1.9],Tail -> P[1.9],VectorColor -> Red],tanlineplot];

That's only part of the tangent line; you got it by plotting 
       P [1.9]+ s P'[1.9] 
with s running from 0 to 2. To get the stuff on the left, run s through some negative numbers as well as positive numbers:

Clear[tanline, s];
tanline[s_]=P[1.9]+s P'[1.9];

tanlineplot = 
        ParametricPlot[tanline[s], {s, -2, 2}, 
          PlotStyle -> Thickness[0.01], DisplayFunction -> Identity]
          ;

Show[curveplot,Arrow[P'[1.9],Tail -> P[1.9],VectorColor -> Red],tanlineplot];

There's that tangent line in all its glory.
The upshot of all this is:
If you have a curve described by the plot of P [t] for a ≤ t ≤ b and you want to plot the tangent line through a point P [c] on the curve, you plot 
       P [c]+ s P'[c]
and run s from negative to positive.
Here's how it goes for a different curve:

Clear[x, y, s, t, tanline, P]; a = -4; b = 3; \(c = 1.7; 

x[t_] = t + Sin[3\ t]; 
\(y[t_] = 2\ Cos[t]; \)\)P[t_] = {x[t], y[t]};

tanline[s_]=P[c]+s P'[c];

curveplot = 
        ParametricPlot[P[t], {t, a, b}, 
          PlotStyle -> {{Thickness[0.01], Blue}}, 
          DisplayFunction -> Identity];

tanlineplot = 
        ParametricPlot[tanline[s], {s, -2, 2}, 
          PlotStyle -> {{Thickness[0.01], Red}}, 
          DisplayFunction -> Identity];

pointplot = Graphics[{PointSize[0.05], Red, Point[P[c]]}];

Show[curveplot, tanlineplot, pointplot, 
        AxesLabel -> {"x", "y"}, 
        DisplayFunction -> $DisplayFunction];

Play with this.

B.2.b.ii)

Does this work in three dimensions too?

Get a life!
Of course it works in three dimensions. Take a look:

Clear[x, y, s, t, tanline, P]; a = 0; b = 2; \(c = 0.5; 

x[t_] = t + Sin[3\ t] + 1; 
\(y[t_] = 2\ Cos[t]; \)\)z[t_] = t; P[t_] = {x[t], y[t], z[t]};

tanline[s_]=P[c]+s P'[c];

curveplot = 
        ParametricPlot3D[P[t], {t, a, b}, DisplayFunction -> Identity]
          ;

tanlineplot = 
        ParametricPlot3D[tanline[s], {s, -1.5, 1.5}, 
          DisplayFunction -> Identity];

pointplot = Graphics3D[{PointSize[0.03], Red, Point[P[c]]}];

threedims = Axes3D[1.2, 0.2];

Show[threedims, curveplot, tanlineplot, pointplot, 
        ViewPoint -> CMView, Boxed -> False, PlotRange -> All, 
        DisplayFunction -> $DisplayFunction];

Hard to resist.

B.3)  Length of a vector, dot product, and distance between two points

B.3.a) Dot products

Here are two cleared vectors   
       X = {x[1], x[2]} and Y = {y[1], y[2]}
 in two dimensions:

\(Clear[X, Y, x, y]; 
X = {x[1], x[2]}\)

Y = {y[1], y[2]}

Here is the dot product, X . Y, of these vectors:

X . Y

Here are two vectors   
       X = {x[1], x[2], x[3]} and Y = {y[1], y[2], y[3]}
 in three dimensions:

\(Clear[X, Y, x, y]; 
X = {x[1], x[2], x[3]}\)

Y = {y[1], y[2], y[3]}

Here is the dot product, X . Y, of the three-dimensional vectors X and Y:

X . Y

Describe how dot products are calculated.

In two or three dimensions, the dot product X . Y just multiplies each slot in X by the corresponding slot in Y, and then adds them up.
Check it out:

{1, 2} . {0, 1}

{1, 2} . {0, 1} == 1 0 + 2 1

{-1, 1} . {8, 2}

{-1, 1} . {8, 2} == -8 + 2

{1, 0, 1} . {1, 2, 3}

{1, 0, 1} . {1, 2, 3} == 1 + 0 + 3

You cannot take the dot product of vectors from different dimensions:

X = {1, 0}; Y = {2, 1, 4}; X . Y

That hacked off Mathematica.

B.3.b)  Dot product and length

Given a two-dimensional vector, 
       X = {x[1], x[2]}, 
the length of X is measured by
       ‖X‖ = 
        (Sqrt[x[1]^( 2) +  x[2]^( 2)]).

Given a three-dimensional vector,
       X = {x[1], x[2], x[3]}, 
the length of X is measured by
       ‖X‖ = 
        (Sqrt[x[1]^( 2) +  x[2]^( 2) +  x[3]^( 2)]).
Explain why the formula
       ‖X‖  =  
        (Sqrt[X . X])
works in either dimension.

Try it out in two dimensions:

\(Clear[x]; 
X = {x[1], x[2]}; 
length = \@\(x[1]\^2 + x[2]\^2\)\)

(Sqrt[X . X])  is given by:

(Sqrt[X . X])

This tells you that the formula  
       ‖X‖  =  
        (Sqrt[X . X]) works in two dimensions.
Try it out in three dimensions:

\(Clear[x]; 
X = {x[1], x[2], x[3]}; 

    length = \@\(x[1]\^2 + x[2]\^2 + x[3]\^2\)\)

(Sqrt[X . X])  is given by:

(Sqrt[X . X])

This tells you that the formula  
       ‖X‖  =  
        (Sqrt[X . X]) works in three dimensions too.
Handy little formula
And it's nothing more or less than your old friend, the Pythagorean theorem, in action.

B.3.c.i) Dot products and distance between points

Why does 
       ‖X - Y‖ = 
        (Sqrt[(X - Y) . (X - Y)])
calculate the distance between the tip of X and the tip of Y when X and Y are positioned so that their tails are at the origin?

Look at a picture:

X = {7, 3}; \(Y = {\(-4\), 7}; 


    Show[Arrow[X, Tail -> {0, 0}, VectorColor -> Blue], 
	
      Graphics[Text["X", X\/2]], 
	
      Arrow[Y, Tail -> {0, 0}, VectorColor -> Blue], 
	
      Graphics[Text["Y", Y\/2]], 
	
      Arrow[X - Y, Tail -> Y, VectorColor -> Red], 
	
      Graphics[Text["X - Y", Y + \(X - Y\)\/2]], Axes -> True]; \)

Rerun for different vectors X and Y, and you will see that the distance between the tip of X and the tip of Y is the same as the length of X -  Y.
The length of X -  Y is 
       (Sqrt[(X - Y) . (X - Y)]),
so the distance between the tip of X and the tip of Y is given by
       ‖X - Y‖ = 
        (Sqrt[(X - Y) . (X - Y)]) .
That's all there is to it.

B.1.c.ii)

Measure the distance between {2, 7} and {3, -5} in two dimensions.
Measure the distance between {2, 7, -6} and {3, -5, 6} in three dimensions.

You measure thedistance between the points {2, 7} and {3, -5} in two dimensions by running:

X = {2, 7}; Y = {3, -5}; N[(Sqrt[(X - Y) . (X - Y)])]

You measure distance between the points {2, 7, -6} and {3, -5, 6} in three dimensions by running:

X = {2, 7, -6}; Y = {3, -5, 4}; N[(Sqrt[(X - Y) . (X - Y)])]

B.4)  The push of one vector in the direction of another, and the formula 
       X . Y = 
        ‖X‖ 
          ‖Y‖ Cos[b], 
where b is the angle between X and Y

Here are two vectors in two dimensions shown with their tails at {0, 0} in true scale:

X = {1.3, 1.7}; \(Y = {1, 0.5}; 


    Show[Arrow[X, Tail -> {0, 0}], 
	Graphics[Text["X", X\/2]], 
      Arrow[Y, Tail -> {0, 0}, VectorColor -> Red], 
	
      Graphics[Text["Y", Y\/2]], PlotRange -> {{0, 2}, {0, 2}}, 
      AspectRatio -> Automatic, Axes -> True, 
      AxesLabel -> {"x", "y"}]; \)

The question addressed here is how to measure the push of X in the direction of Y. 
The answer is that the push of X in the direction of Y is calculated by the clean formula:
       XpushalongY=((X·Y)/(Y·Y))Y.
Take a look:

\(XpushalongY = \(X . Y\/Y . Y\) Y; 


    Show[Arrow[X, Tail -> {0, 0}], 
	Graphics[Text["X", X\/2]], 
      Arrow[XpushalongY, Tail -> {0, 0}, VectorColor -> Red], 
	
      Graphics[Text["X push along Y", XpushalongY\/2]], 
      PlotRange -> {{0, 2}, {0, 2}}, AspectRatio -> Automatic, 
      Axes -> True, AxesLabel -> {"x", "y"}]; \)

Here are two new vectors X and Y:

X = {-8, 6}; \(Y = {\(-4\), 0.6}; 


    Show[Arrow[X, Tail -> {0, 0}], 
	Graphics[Text["X", X\/2]], 
	
      Arrow[Y, Tail -> {0, 0}, VectorColor -> Red], 
	
      Graphics[Text["Y", Y\/2]], AspectRatio -> Automatic, 
      Axes -> True, AxesLabel -> {"x", "y"}]; \)

Here are X and XpushalongY=X . (Y/Y) . YY:

\(XpushalongY = \(X . Y\/Y . Y\) Y; 


    Show[Arrow[X, Tail -> {0, 0}], 
	Graphics[Text["X", X\/2]], 
	
      Arrow[XpushalongY, Tail -> {0, 0}, VectorColor -> Red], 
	
      Graphics[Text["X push along Y", XpushalongY\/2]], 
      AspectRatio -> Automatic, Axes -> True, 
      AxesLabel -> {"x", "y"}]; \)

Try it for other X's and Y's until the plots make sense to you.

B.4.a)

According to what was done above, you calculate the push of a vector X in the direction of another vector Y by calculating
       XpushalongY = X . (Y/Y) . Y Y.
Explain where this formula comes from, and explain what the push of X in the direction of Y means.

Go with cleared vectors X and Y.
Put
       f[t] = 
        ‖X  -  t Y‖ = 
          (Sqrt[(X -  t Y) . (X -  t Y)]).
The function f[t] measures the distance between the tip of X and the tip of the vector t Y when both vectors have their tails at {0, 0}.

\(Clear[f, t, x, y, X, Y]; 
X = {x[1], x[2]}; 
\(Y = {y[1], y[2]}; 


    f[t_] = \@\(\((X - t\ Y)\) . \((X - t\ Y)\)\)\)\)

f[t] is as small as it can be when f'[t]=0:

Solve[f'[t]==0,t]

This is the same as bestt=X . (Y/Y) . Y:

bestt = X . (Y/Y) . Y

This is the t that makes
       f[t] = 
        ‖X -  t Y‖ 
as small as it can be.
But you already know that
       XpushalongY=X . (Y/Y) . YY.
The upshot:
The push of X in the direction of Y is that multiple of Y whose tip is closest to the tip of X when you put the tails of both vectors at {0, 0}.
This works in three dimensions as well.

B.4.b)

Take a look at 
->  X and XpushalongY with their tails at {0, 0}, and  
->  (X -  XpushalongY) with its tail at the tip of XpushalongY for two sample vectors X and Y in true scale:

X = {1, 2}; \(Y = {4, 1}; 

XpushalongY = \(X . Y\ Y\)\/Y . Y; 


    Show[Arrow[X, Tail -> {0, 0}], 
	Graphics[Text["X", X\/2]], 
	
      Arrow[XpushalongY, Tail -> {0, 0}, VectorColor -> Red], 
	
      Graphics[Text["X push along Y", XpushalongY\/2]], 
	
      Arrow[X - XpushalongY, Tail -> XpushalongY, 
        VectorColor -> Red], Graphics[Line[{\(-0.2\)\ Y, 0.8\ Y}]], 
      AspectRatio -> Automatic, Axes -> True, 
      AxesLabel -> {"x", "y"}]; \)

The line is the plot of the tips of relevant multiples t Y of Y.
Describe what you see and explain why you see it.

You see a right triangle. 
And this is what you'll see for any two vectors X and Y unless X and Y are parallel.
Reason:
->  The push of X in the direction of Y is the multiple of Y whose tip is closest to the tip of X when you put the tails of both vectors at {0, 0}. 
The upshot:
The tip of XpushalongY is the closest point on the line to the tip of X.  And the shortest distance between the line and the tip of X is the perpendicular distance.

B.4.c)  The formula (X . Y) = 
        ‖X‖ 
          ‖Y‖ Cos[b] where b is the angle between X and Y

Take another look at 
->  X and XpushalongY with their tails at {0, 0}  and  
->  (X -  XpushalongY) with its tail at the tip of XpushalongY for two sample vectors X and Y in true scale:

X = {2.8, 1.9}; \(Y = {1.2, 0.2}; 

XpushalongY = \(X . Y\/Y . Y\) Y; 


    plot = Show[Arrow[X, Tail -> {0, 0}], 
		
        Graphics[Text["X", X\/2]], 
		
        Arrow[XpushalongY, Tail -> {0, 0}, VectorColor -> Red], 
	
        	Graphics[Text["X push along Y", XpushalongY\/2]], 
		
        Arrow[X - XpushalongY, Tail -> XpushalongY, 
          VectorColor -> Red], Axes -> True, 
        AxesLabel -> {"x", "y"}]; \)

Use the plot to help explain the formula
       (X . Y) = 
        ‖X‖ 
          ‖Y‖ Cos[b] 
where 
       b is the angle between X and Y,
       ‖X‖ = 
        (Sqrt[X . X]), and
       ‖Y‖ = 
        (Sqrt[Y . Y]).

The goal is to explain the formula
       X . Y = 
        ‖X‖ 
          ‖Y‖ Cos[b], 
where b is the angle between X and Y when their tails are at the origin.  Take another look:

Show[plot];

Remembering that 
       Cos[b] = (adjacent/hypotenuse),
read off 
       Cos[b]=t‖Y
                  (‖/‖)X
                  ‖
where 
       t=X  . (Y/Y) . Y
because 
       XpushalongY=X  . (Y/Y) . YY.
Now you know why
       ‖X‖ Cos[b] = 
        t ‖Y‖.
Next, multiply both sides by ‖Y‖ to get
       ‖X‖ 
          ‖Y‖ Cos[b] = 
        t ‖Y(‖^2).
 This tells you that to explain why
       X . Y = 
        ‖X‖ 
          ‖Y‖ Cos[b], 
you gotta explain why
       t ‖Y(‖^2) = 
        X . Y.
This is easy because 
       t=X  . (Y/Y) . Y; 
so
       t ‖Y(‖^2) = 
        t Y . Y 
       =X  . (Y/Y) . Y(Y . Y)=X . Y.
That's it.
This formula also works in three dimensions.

B.5) X . Y = 0 means X is perpendicular to Y

B.5.a.i)

Look at 
       X = {1, (4/3), (7/2)} and Y = {-(1/3), -5, 2}
with their tails at {0, 0, 0}:

X = {1, (4/3), (7/2)}; \(Y = {\(-\(1\/3\)\), \(-5\), 2}; 

threedims = Axes3D[1.5, 0.2]; 


    Show[Arrow[X, VectorColor -> Red], 
\ \ \ \ \ \ \ \ \ \ 	
      Arrow[Y, VectorColor -> Red], 
\ \ \ \ \ \ \ \ \ \ 	threedims, 
      PlotRange -> All, ViewPoint -> CMView, Boxed -> False]; 
    \)

These vectors look like they might be perpendicular.
How can you tell for sure?

Just look at X . Y:

X . Y

Now you know that X . Y = 0; so you know for sure that X is indeed perpendicular to Y.

B.5.a.ii) The perpendicularity test

Explain the statement: 
If X . Y = 0, then X is perpendicular to Y.

Well, if X . Y = 0, then because
       (X . Y) = 
        ‖X‖ 
          ‖Y‖ 
          (Cos[b]), 
you know that
       Cos[b] = 0 = Cos[(π/2)] = Cos[-(π/2)].
This tells you that the angle between X and Y is a right angle.

B.5.b)

How do you know that 
       X = {6, 2} 
is perpendicular to 
       Y = {3, -9}?

Check to see that X . Y = 0:

X = {6, 2}; Y = {3, -9}; X . Y

Yep; X = {6, 2} is perpendicular to Y = {3, -9}.