Often we want to manipulate a point {a,b}, such as moving it, rotating it around a point, or extending it in the direction from origin (scaling). It helps greatly to think of a point {a,b} as a line from the Origin to {a,b}. When a point is thought of this way, we call it a vector.

Length of a Vector

The length of a vector is the distance from origin to the vector. If a vector is {a,b}, then by Pythagorean Theorem of a right triangle, its length is Sqrt[a^2+b^2]. Thus we define the length of a vector to be:

Length[{a,b}] := Sqrt[a^2+b^2]

Zero Vector: The vector {0,0} is interesting because it is the only vector whose length is 0. We give it a name the “zero vector”. It is special and useful in the same way the point {0,0} is also called Origin.

Vector Addition

A point {a,b} moved horizontally by c units and vertically by d units, will be at {a+c,b+d}. We can think of this as addition of two vectors {a,b} and {c,d}.

We define the addition of two vectors {a,b} and {c,d} as the sum of their components. We denote the vector addition operator as ⊕. That is:

{a,b} ⊕ {c,d} := {a+c, b+d}

We define a vector addition because it is very useful. It simplifies discussion and expression. Think of a vector {a,b} as a arrow from the origin {0,0} to destination {a,b} on the coordinate system. Then, the sum of A and B is simply moving from origin by A's components, then by B's components, to end at {a+c,b+d}.

Scaling (scalar multiplication)

We define another function called Scaling, which takes two arguments: a real number and a vector, and returns a vector.


For convenience, we define a alternative syntax or notation for Scaling. We write c⊙{a,b} to mean Scaling[c,{a,b}]. So, the symbol “⊙” is used between a number and a pair.

Note: This function Scaling, is traditionally called “scalar multiplication”.

Geometrically, the Scaling function is scaling of a vector. If the scaling factor c, is greater than 1, it expands the vector. If c is 1, then no change. If c is greater than 0 but less than 1, then the vector is shrinked. If c is 0, the vector is shrinked to a point and becomes the zero vector. If c is negative, the vector is changed to the opposite direction.

Vector Representation with Length and Angle

For any vector, we can write it as r⊙{Cos[α],Sin[α]}, where α is the angle of the vector and r is its length.

Dot Product

We define a “dot product” function for vectors. The dot product of two vectors is defined as the sum of their products of components. That is, the dot product of 2 vectors {a,b} and {c,d} is the number a*c+b*d. We denote the definition of Dot function like this:

Dot[{a,b},{c,d}] := a*c+b*d

If A and B are vectors, we also write it like this: “A ∙ B”.

We define the dot product this way because it is very useful, and it has a particular property, namely: two vectors are orthogonal if their dot product is 0.

Here we want to prove that if A ∙ B == 0, then A and B are orthogonal. Suppose A is {1,0} and B is {0,1}. They form a right angle, and their dot product is 0. Now, suppose we rotate this rigid right angle by a tiny amount anti-clockwise. (say, 1°) We have A:={a,b} and B:={c,d}. Now, a is smaller than before, and b is a bit larger. Similarly, the c becomes larger and d smaller. The increase in quantity are symmetric between A and B. That is if A and B forms a right angle as {1,0} and {0,1}, as we rotate this right angle, A's first component shrinks the same rate as B's second component shrinks, and A's second component grows as B's first component grows. That is to say, a and c increase the same rate as b and d shrinks. So, if now we look at their dot product a*c+b*d, we see that a and d decrease and c ad b increase all at the same rate. But now c is negative, so the sum cancels out and is still 0. This holds out as we rotate the right angle all the way to Pi/2 radians, at which point A becomes {0,1} and B becomes {-1,0}

We keep thinking this way by increasing the angle, we see that as long as A and B are unit length vectors, and as long as their are orthogonal, their dot product is 0. Now what happens if one of the vector is not unit length? That is, scaled by a scalar s? Well, in that case their dot product is {s*a*c+s*b*d}, which is s⊙{a*c+b*d}, so still 0 if they are 0 to begin with. So here we see that if the dot product of two vectors is 0, increasing or decreasing one or both vector doesn't effect it.

Now, we know that if two vectors are orthogonal, their vector product is 0. Now by the symmetry of the dot product a*c+b*d, and by proportion as our argument above, we argue in reverse that the only time when the dot product is 0 is when two vectors are orthogonal.

The Geometric Nature of the Dot Product

Now we want to investigate what is the nature of the dot product. That is, what happens if one vector changes direction or length.

Suppose we have two vectors:


where α is the angle of the vector A and r is its length. And, β is the angle of B and s is its length. Now, their dot product, after simplification is:

r * s * (Cos[α]*Cos[β]+Sin[α]*Sin[β])

By the trig identity “Cos[a+b] = Cos[a] Cos[b] - Sin[a] Sin[b]”, it further simplifes to:


From this we see, that the lengths of the vectors effect the dot product as the multiplier r*s. If a vector is fixed and the other is scaled by c, their dot product is also multiplied by c.

Also, from the Cos[α-β] part, we see that the dot product behaves like a cosine function. That is, if one vector is fixed, and we rotate the other vector, then their dot product will behave like a cosine function. It reaches max value when the two vectors make a angle of Pi or 0, and becomes 0 when they make a angle of Pi/2.

Also, note that the quantity (α-β) is the angle between the vectors. It doesn't matter which vector has angle α and which has angle β, because cosine is a even function, meaning that Cos[a]==Cos[-a] for any “a”, therefore Cos[α-β] == Cos[β-α].

Vector Dot Product

Taken all these together, we have this identity:

A∙B == Length[A]*Length[B]*Cos[θ]

, where θ is the angle between the vectors. If we write the vectors as components, we have this identity.

a1*b1+a2*b2 == Sqrt[a1^2+a2^2] * Sqrt[b1^2+b2^2] * Cos[α-β]

The dot product with the above is rather miraculous, because it links together the coordinate component of 2 points with their lengths and angle.

Some Properties of Dot Product

Some easily verified properties of dot product:

Some properties involving lengths: