Mathematica Labs | Denis Shubleka

Subject: Calculus

Topic: Dot Product

Goal: Use Mathematica to explore the operation of dot product between two vectors.

Task 1

A vector in 2-space is represented as a list of length 2. For higher dimension spaces, simply define a vector as a longer list. We start with a simple vector addtion in 2-space:

{1, 9} + {-3, 1}

Scalar multiplication in 3-space works as one would expect:

3{-1,1,1}

We can also define a few vectors and perform operations on them, such as, for
example, a linear combination:

u={1,1,1};
v={-1, 2, 4};
2u+3v

Task 2

Mathematica computes the dot product operation between two vectors when we place a period in between them:

{a,b}.{c,d}

Feel free to try it it with two specific vectors in 3-space.

The norm (or length) of a vector is determined using the Norm command:

Norm[{x,y,z}]

To find the angle between two vectors we first define them, and then ask
Mathematica to compute the arc cosine:

u={1,1,1};v={1,0,0};
ArcCos[((u.v)/(Norm[u]Norm[v]))]//N

The output is in radian measure, so we convert the result (%) to degrees:

% / Degree

We conclude this task by showing how Mathematica displays vectors in 2-space:

Graphics[{Arrow[{{0,0},{1,1}}],Arrow[{{0,0},{-1,3}}]},Axes->True]

Note that rendering vectors in 3-space requires the Graphics3D package. For 
example, to plot vectors (1, 1, 1) and (-1, 1, -1) execute the following:

Graphics3D[{Arrow[{{0,0,0},{1,1,1}}],Arrow[{{0,0,0},{-1,1,-1}}]},Axes->True,Boxed->False]

Related Exercises/Notes:

ap-calc.github.io